Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } | 231 } |
| 232 pending_actions_.clear(); | 232 pending_actions_.clear(); |
| 233 | 233 |
| 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()) | |
| 242 return; | |
| 243 | |
| 241 // Ignore anything that isn't a completed download notification. | 244 // Ignore anything that isn't a completed download notification. |
| 242 if (!item->IsDone() || java_ref_.is_null()) | 245 if (!item->IsDone() |
| 246 || item->GetState() != content::DownloadItem::DownloadState::COMPLETE) { | |
|
qinmin
2016/09/06 23:08:55
the 2nd condition implies the first one, you can r
gone
2016/09/06 23:24:05
Done.
| |
| 243 return; | 247 return; |
| 248 } | |
| 244 | 249 |
| 245 JNIEnv* env = base::android::AttachCurrentThread(); | 250 JNIEnv* env = base::android::AttachCurrentThread(); |
| 246 Java_DownloadManagerService_onDownloadItemUpdated( | 251 Java_DownloadManagerService_onDownloadItemUpdated( |
| 247 env, | 252 env, |
| 248 java_ref_.obj(), | 253 java_ref_.obj(), |
| 249 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(), | 254 ConvertUTF8ToJavaString(env, item->GetGuid()).obj(), |
| 250 ConvertUTF8ToJavaString( | 255 ConvertUTF8ToJavaString( |
| 251 env, item->GetFileNameToReportUser().value()).obj(), | 256 env, item->GetFileNameToReportUser().value()).obj(), |
| 252 ConvertUTF8ToJavaString( | 257 ConvertUTF8ToJavaString( |
| 253 env, item->GetTargetFilePath().value()).obj(), | 258 env, item->GetTargetFilePath().value()).obj(), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 content::DownloadManager* manager = | 394 content::DownloadManager* manager = |
| 390 content::BrowserContext::GetDownloadManager(profile); | 395 content::BrowserContext::GetDownloadManager(profile); |
| 391 | 396 |
| 392 // Update notifiers to monitor any newly created DownloadManagers. | 397 // Update notifiers to monitor any newly created DownloadManagers. |
| 393 updateNotifier( | 398 updateNotifier( |
| 394 this, manager, | 399 this, manager, |
| 395 is_off_the_record ? off_the_record_notifier_ : original_notifier_); | 400 is_off_the_record ? off_the_record_notifier_ : original_notifier_); |
| 396 | 401 |
| 397 return manager; | 402 return manager; |
| 398 } | 403 } |
| OLD | NEW |