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

Unified Diff: chrome/browser/android/download/download_manager_service.cc

Issue 2511303002: [Downloads] Add support for tracking incomplete downloads (Closed)
Patch Set: Remove unnecessary function Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/android/download/download_manager_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/download/download_manager_service.cc
diff --git a/chrome/browser/android/download/download_manager_service.cc b/chrome/browser/android/download/download_manager_service.cc
index 07ee8e90ca3b6b0dd71ae0f841017de37129fb90..3e513c1cd83375f2e9e8706455f32a4a4b0614cb 100644
--- a/chrome/browser/android/download/download_manager_service.cc
+++ b/chrome/browser/android/download/download_manager_service.cc
@@ -28,13 +28,10 @@ using base::android::ScopedJavaLocalRef;
namespace {
bool ShouldShowDownloadItem(content::DownloadItem* item) {
- return !item->IsTemporary() &&
- !item->GetFileNameToReportUser().empty() &&
- !item->GetTargetFilePath().empty() &&
- item->GetState() != content::DownloadItem::CANCELLED;
+ return !item->IsTemporary();
}
-void updateNotifier(DownloadManagerService* service,
+void UpdateNotifier(DownloadManagerService* service,
content::DownloadManager* manager,
std::unique_ptr<AllDownloadItemNotifier>& notifier) {
if (manager) {
@@ -276,8 +273,17 @@ void DownloadManagerService::OnHistoryQueryComplete() {
GetAllDownloadsInternal(true);
// Monitor all DownloadItems for changes.
- updateNotifier(this, GetDownloadManager(false), original_notifier_);
- updateNotifier(this, GetDownloadManager(true), off_the_record_notifier_);
+ UpdateNotifier(this, GetDownloadManager(false), original_notifier_);
+ UpdateNotifier(this, GetDownloadManager(true), off_the_record_notifier_);
+}
+
+void DownloadManagerService::OnDownloadCreated(
+ content::DownloadManager* manager, content::DownloadItem* item) {
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> j_item = CreateJavaDownloadItem(env, item);
+ Java_DownloadManagerService_onDownloadItemCreated(
+ env, java_ref_.obj(), j_item);
}
void DownloadManagerService::OnDownloadUpdated(
@@ -285,6 +291,9 @@ void DownloadManagerService::OnDownloadUpdated(
if (java_ref_.is_null())
return;
+ if (item->IsTemporary())
+ return;
+
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_item = CreateJavaDownloadItem(env, item);
Java_DownloadManagerService_onDownloadItemUpdated(
@@ -420,7 +429,7 @@ content::DownloadManager* DownloadManagerService::GetDownloadManager(
content::BrowserContext::GetDownloadManager(profile);
// Update notifiers to monitor any newly created DownloadManagers.
- updateNotifier(
+ UpdateNotifier(
this, manager,
is_off_the_record ? off_the_record_notifier_ : original_notifier_);
« no previous file with comments | « chrome/browser/android/download/download_manager_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698