Commit f927d082 authored by qinmin@chromium.org's avatar qinmin@chromium.org

Fix browser crash when calling MediaPlayerBridge::PrepareAsync

BUG=319956

Review URL: https://codereview.chromium.org/74293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235663 0039d316-1c4b-4281-b951-d872f2087c98
parent bb6f2784
......@@ -50,8 +50,14 @@ public class MediaPlayerBridge {
}
@CalledByNative
protected void prepareAsync() throws IllegalStateException {
getLocalPlayer().prepareAsync();
protected boolean prepareAsync() {
try {
getLocalPlayer().prepareAsync();
} catch (IllegalStateException e) {
Log.e(TAG, "Unable to prepare MediaPlayer.", e);
return false;
}
return true;
}
@CalledByNative
......
......@@ -118,8 +118,8 @@ void MediaPlayerBridge::SetVideoSurface(gfx::ScopedJavaSurface surface) {
}
void MediaPlayerBridge::Prepare() {
if (j_media_player_bridge_.is_null())
CreateJavaMediaPlayerBridge();
DCHECK(j_media_player_bridge_.is_null());
CreateJavaMediaPlayerBridge();
if (url_.SchemeIsFileSystem()) {
manager()->GetMediaResourceGetter()->GetPlatformPathFromFileSystemURL(
url_, base::Bind(&MediaPlayerBridge::SetDataSource,
......@@ -144,15 +144,16 @@ void MediaPlayerBridge::SetDataSource(const std::string& url) {
jobject j_context = base::android::GetApplicationContext();
DCHECK(j_context);
if (Java_MediaPlayerBridge_setDataSource(
if (!Java_MediaPlayerBridge_setDataSource(
env, j_media_player_bridge_.obj(), j_context, j_url_string.obj(),
j_cookies.obj(), hide_url_log_)) {
manager()->RequestMediaResources(player_id());
Java_MediaPlayerBridge_prepareAsync(
env, j_media_player_bridge_.obj());
} else {
OnMediaError(MEDIA_ERROR_FORMAT);
return;
}
manager()->RequestMediaResources(player_id());
if (!Java_MediaPlayerBridge_prepareAsync(env, j_media_player_bridge_.obj()))
OnMediaError(MEDIA_ERROR_FORMAT);
}
void MediaPlayerBridge::OnCookiesRetrieved(const std::string& cookies) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment