| 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 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ | 6 #define CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 DownloadController::DownloadCancelReason reason); | 34 DownloadController::DownloadCancelReason reason); |
| 35 | 35 |
| 36 DownloadManagerService(JNIEnv* env, | 36 DownloadManagerService(JNIEnv* env, |
| 37 jobject jobj); | 37 jobject jobj); |
| 38 ~DownloadManagerService() override; | 38 ~DownloadManagerService() override; |
| 39 | 39 |
| 40 // Called to resume downloading the item that has GUID equal to | 40 // Called to resume downloading the item that has GUID equal to |
| 41 // |jdownload_guid|.. | 41 // |jdownload_guid|.. |
| 42 void ResumeDownload(JNIEnv* env, | 42 void ResumeDownload(JNIEnv* env, |
| 43 jobject obj, | 43 jobject obj, |
| 44 const JavaParamRef<jstring>& jdownload_guid); | 44 const JavaParamRef<jstring>& jdownload_guid, |
| 45 bool is_off_the_record); |
| 45 | 46 |
| 46 // Called to cancel a download item that has GUID equal to |jdownload_guid|. | 47 // Called to cancel a download item that has GUID equal to |jdownload_guid|. |
| 47 // If the DownloadItem is not yet created, retry after a while. | 48 // If the DownloadItem is not yet created, retry after a while. |
| 48 void CancelDownload(JNIEnv* env, | 49 void CancelDownload(JNIEnv* env, |
| 49 jobject obj, | 50 jobject obj, |
| 50 const JavaParamRef<jstring>& jdownload_guid, | 51 const JavaParamRef<jstring>& jdownload_guid, |
| 51 bool is_off_the_record, | 52 bool is_off_the_record, |
| 52 bool is_notification_dismissed); | 53 bool is_notification_dismissed); |
| 53 | 54 |
| 54 // Called to pause a download item that has GUID equal to |jdownload_guid|. | 55 // Called to pause a download item that has GUID equal to |jdownload_guid|. |
| 55 // If the DownloadItem is not yet created, do nothing as it is already paused. | 56 // If the DownloadItem is not yet created, do nothing as it is already paused. |
| 56 void PauseDownload(JNIEnv* env, | 57 void PauseDownload(JNIEnv* env, |
| 57 jobject obj, | 58 jobject obj, |
| 58 const JavaParamRef<jstring>& jdownload_guid); | 59 const JavaParamRef<jstring>& jdownload_guid, |
| 60 bool is_off_the_record); |
| 59 | 61 |
| 60 // Called to request that the DownloadManagerService return data about all | 62 // Called to request that the DownloadManagerService return data about all |
| 61 // downloads in the user's history. | 63 // downloads in the user's history. |
| 62 void GetAllDownloads(JNIEnv* env, const JavaParamRef<jobject>& obj); | 64 void GetAllDownloads(JNIEnv* env, const JavaParamRef<jobject>& obj); |
| 63 | 65 |
| 64 // DownloadHistory::Observer methods. | 66 // DownloadHistory::Observer methods. |
| 65 void OnHistoryQueryComplete() override; | 67 void OnHistoryQueryComplete() override; |
| 66 | 68 |
| 67 protected: | 69 protected: |
| 68 // Called to get the content::DownloadManager instance. | 70 // Called to get the content::DownloadManager instance. |
| 69 virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record); | 71 virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record); |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 // For testing. | 74 // For testing. |
| 73 friend class DownloadManagerServiceTest; | 75 friend class DownloadManagerServiceTest; |
| 74 | 76 |
| 75 // Helper function to start the download resumption. | 77 // Helper function to start the download resumption. |
| 76 void ResumeDownloadInternal(const std::string& download_guid); | 78 void ResumeDownloadInternal(const std::string& download_guid, |
| 79 bool is_off_the_record); |
| 77 | 80 |
| 78 // Helper function to cancel a download. | 81 // Helper function to cancel a download. |
| 79 void CancelDownloadInternal(const std::string& download_guid, | 82 void CancelDownloadInternal(const std::string& download_guid, |
| 80 bool is_off_the_record); | 83 bool is_off_the_record); |
| 81 | 84 |
| 82 // Helper function to pause a download. | 85 // Helper function to pause a download. |
| 83 void PauseDownloadInternal(const std::string& download_guid); | 86 void PauseDownloadInternal(const std::string& download_guid, |
| 87 bool is_off_the_record); |
| 84 | 88 |
| 85 // Helper function to send info about all downloads to the Java-side. | 89 // Helper function to send info about all downloads to the Java-side. |
| 86 void GetAllDownloadsInternal(); | 90 void GetAllDownloadsInternal(); |
| 87 | 91 |
| 88 // Called to notify the java side that download resumption failed. | 92 // Called to notify the java side that download resumption failed. |
| 89 void OnResumptionFailed(const std::string& download_guid); | 93 void OnResumptionFailed(const std::string& download_guid); |
| 90 | 94 |
| 91 void OnResumptionFailedInternal(const std::string& download_guid); | 95 void OnResumptionFailedInternal(const std::string& download_guid); |
| 92 | 96 |
| 93 typedef base::Callback<void(bool)> ResumeCallback; | 97 typedef base::Callback<void(bool)> ResumeCallback; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 107 | 111 |
| 108 void EnqueueDownloadAction(const std::string& download_guid, | 112 void EnqueueDownloadAction(const std::string& download_guid, |
| 109 DownloadAction action); | 113 DownloadAction action); |
| 110 | 114 |
| 111 ResumeCallback resume_callback_for_testing_; | 115 ResumeCallback resume_callback_for_testing_; |
| 112 | 116 |
| 113 DISALLOW_COPY_AND_ASSIGN(DownloadManagerService); | 117 DISALLOW_COPY_AND_ASSIGN(DownloadManagerService); |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ | 120 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ |
| OLD | NEW |