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

Side by Side Diff: chrome/browser/android/download/download_manager_service.cc

Issue 2320693003: [Download Home] Expose Java side to DownloadItem states (Closed)
Patch Set: Rebased Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/download/download_manager_service.h" 5 #include "chrome/browser/android/download/download_manager_service.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // Monitor all DownloadItems for changes. 234 // Monitor all DownloadItems for changes.
235 updateNotifier(this, GetDownloadManager(false), original_notifier_); 235 updateNotifier(this, GetDownloadManager(false), original_notifier_);
236 updateNotifier(this, GetDownloadManager(true), off_the_record_notifier_); 236 updateNotifier(this, GetDownloadManager(true), off_the_record_notifier_);
237 } 237 }
238 238
239 void DownloadManagerService::OnDownloadUpdated( 239 void DownloadManagerService::OnDownloadUpdated(
240 content::DownloadManager* manager, content::DownloadItem* item) { 240 content::DownloadManager* manager, content::DownloadItem* item) {
241 if (java_ref_.is_null()) 241 if (java_ref_.is_null())
242 return; 242 return;
243 243
244 // Ignore anything that isn't a completed download notification.
245 if (item->GetState() != content::DownloadItem::DownloadState::COMPLETE)
246 return;
247
248 JNIEnv* env = base::android::AttachCurrentThread(); 244 JNIEnv* env = base::android::AttachCurrentThread();
249 Java_DownloadManagerService_onDownloadItemUpdated( 245 Java_DownloadManagerService_onDownloadItemUpdated(
250 env, 246 env,
251 java_ref_.obj(), 247 java_ref_.obj(),
248 item->GetState(),
252 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(), 249 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(),
253 ConvertUTF8ToJavaString( 250 ConvertUTF8ToJavaString(
254 env, item->GetFileNameToReportUser().value()).obj(), 251 env, item->GetFileNameToReportUser().value()).obj(),
255 ConvertUTF8ToJavaString( 252 ConvertUTF8ToJavaString(
256 env, item->GetTargetFilePath().value()).obj(), 253 env, item->GetTargetFilePath().value()).obj(),
257 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(), 254 ConvertUTF8ToJavaString(env, item->GetTabUrl().spec()).obj(),
258 ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(), 255 ConvertUTF8ToJavaString(env, item->GetMimeType()).obj(),
259 item->GetStartTime().ToJavaTime(), 256 item->GetStartTime().ToJavaTime(),
260 item->GetTotalBytes(), 257 item->GetTotalBytes(),
261 item->GetBrowserContext()->IsOffTheRecord(), 258 item->GetBrowserContext()->IsOffTheRecord(),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 content::DownloadManager* manager = 389 content::DownloadManager* manager =
393 content::BrowserContext::GetDownloadManager(profile); 390 content::BrowserContext::GetDownloadManager(profile);
394 391
395 // Update notifiers to monitor any newly created DownloadManagers. 392 // Update notifiers to monitor any newly created DownloadManagers.
396 updateNotifier( 393 updateNotifier(
397 this, manager, 394 this, manager,
398 is_off_the_record ? off_the_record_notifier_ : original_notifier_); 395 is_off_the_record ? off_the_record_notifier_ : original_notifier_);
399 396
400 return manager; 397 return manager;
401 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698