Index: content/browser/android/download_controller_android_impl.cc |
diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc |
index 5aedd81706fcde3c9fc38763fe276215e169bf4f..d45bdf299dbe44b7d5689bd1727193e3e13b9c68 100644 |
--- a/content/browser/android/download_controller_android_impl.cc |
+++ b/content/browser/android/download_controller_android_impl.cc |
@@ -236,16 +236,18 @@ void DownloadControllerAndroidImpl::StartAndroidDownload( |
} |
void DownloadControllerAndroidImpl::OnPostDownloadStarted( |
- WebContents* web_contents, |
DownloadItem* download_item) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (!download_item->GetWebContents()) |
+ return; |
+ |
JNIEnv* env = AttachCurrentThread(); |
// Register for updates to the DownloadItem. |
download_item->AddObserver(this); |
ScopedJavaLocalRef<jobject> view = |
- GetContentViewCoreFromWebContents(web_contents); |
+ GetContentViewCoreFromWebContents(download_item->GetWebContents()); |
// The view went away. Can't proceed. |
if (view.is_null()) |
return; |
@@ -257,9 +259,13 @@ void DownloadControllerAndroidImpl::OnPostDownloadStarted( |
void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- if (item->GetState() != DownloadItem::COMPLETE) |
+ if (!item->IsComplete()) |
return; |
+ // Multiple OnDownloadUpdated() notifications may be issued while the download |
+ // is in the COMPLETE state. Only handle one. |
+ item->RemoveObserver(this); |
+ |
// Call onHttpPostDownloadCompleted |
JNIEnv* env = AttachCurrentThread(); |
ScopedJavaLocalRef<jstring> jurl = |
@@ -284,9 +290,6 @@ void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) { |
item->GetReceivedBytes(), true); |
} |
-void DownloadControllerAndroidImpl::OnDownloadOpened(DownloadItem* item) { |
-} |
- |
ScopedJavaLocalRef<jobject> DownloadControllerAndroidImpl::GetContentView( |
int render_process_id, int render_view_id) { |
RenderViewHost* render_view_host = |