Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: content/browser/android/download_controller_android_impl.cc

Issue 11640007: Make the UI an observer of downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android clang build Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 =
« no previous file with comments | « content/browser/android/download_controller_android_impl.h ('k') | content/browser/download/download_item_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698