| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ResumeDownloadInternal(download_id, ConvertJavaStringToUTF8(env, fileName), | 60 ResumeDownloadInternal(download_id, ConvertJavaStringToUTF8(env, fileName), |
| 61 true); | 61 true); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void DownloadManagerService::CancelDownload(JNIEnv* env, | 64 void DownloadManagerService::CancelDownload(JNIEnv* env, |
| 65 jobject obj, | 65 jobject obj, |
| 66 uint32_t download_id) { | 66 uint32_t download_id) { |
| 67 CancelDownloadInternal(download_id, true); | 67 CancelDownloadInternal(download_id, true); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DownloadManagerService::PauseDownload(JNIEnv* env, |
| 71 jobject obj, |
| 72 uint32_t download_id) { |
| 73 content::DownloadItem* item = manager_->GetDownload(download_id); |
| 74 if (item) |
| 75 item->Pause(); |
| 76 } |
| 77 |
| 70 void DownloadManagerService::ManagerGoingDown( | 78 void DownloadManagerService::ManagerGoingDown( |
| 71 content::DownloadManager* manager) { | 79 content::DownloadManager* manager) { |
| 72 manager_ = nullptr; | 80 manager_ = nullptr; |
| 73 } | 81 } |
| 74 | 82 |
| 75 void DownloadManagerService::ResumeDownloadItem(content::DownloadItem* item, | 83 void DownloadManagerService::ResumeDownloadItem(content::DownloadItem* item, |
| 76 const std::string& fileName) { | 84 const std::string& fileName) { |
| 77 if (!item->CanResume()) { | 85 if (!item->CanResume()) { |
| 78 OnResumptionFailed(item->GetId(), fileName); | 86 OnResumptionFailed(item->GetId(), fileName); |
| 79 return; | 87 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const std::string& fileName) { | 143 const std::string& fileName) { |
| 136 if (!java_ref_.is_null()) { | 144 if (!java_ref_.is_null()) { |
| 137 JNIEnv* env = base::android::AttachCurrentThread(); | 145 JNIEnv* env = base::android::AttachCurrentThread(); |
| 138 Java_DownloadManagerService_onResumptionFailed( | 146 Java_DownloadManagerService_onResumptionFailed( |
| 139 env, java_ref_.obj(), download_id, | 147 env, java_ref_.obj(), download_id, |
| 140 ConvertUTF8ToJavaString(env, fileName).obj()); | 148 ConvertUTF8ToJavaString(env, fileName).obj()); |
| 141 } | 149 } |
| 142 if (!resume_callback_for_testing_.is_null()) | 150 if (!resume_callback_for_testing_.is_null()) |
| 143 resume_callback_for_testing_.Run(false); | 151 resume_callback_for_testing_.Run(false); |
| 144 } | 152 } |
| OLD | NEW |