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

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

Issue 2143303002: [Downloads] Expose basic download history to UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaning up the interface Created 4 years, 5 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 #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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const JavaParamRef<jstring>& jdownload_guid, 45 const JavaParamRef<jstring>& jdownload_guid,
46 bool is_off_the_record, 46 bool is_off_the_record,
47 bool is_notification_dismissed); 47 bool is_notification_dismissed);
48 48
49 // Called to pause a download item that has GUID equal to |jdownload_guid|. 49 // Called to pause a download item that has GUID equal to |jdownload_guid|.
50 // If the DownloadItem is not yet created, do nothing as it is already paused. 50 // If the DownloadItem is not yet created, do nothing as it is already paused.
51 void PauseDownload(JNIEnv* env, 51 void PauseDownload(JNIEnv* env,
52 jobject obj, 52 jobject obj,
53 const JavaParamRef<jstring>& jdownload_guid); 53 const JavaParamRef<jstring>& jdownload_guid);
54 54
55 // Called to request that the DownloadManagerService return data about all
56 // downloads in the user's history.
57 void GetAllDownloads(JNIEnv* env, const JavaParamRef<jobject>& obj);
58
55 // DownloadHistory::Observer methods. 59 // DownloadHistory::Observer methods.
56 void OnHistoryQueryComplete() override; 60 void OnHistoryQueryComplete() override;
57 61
58 protected: 62 protected:
59 // Called to get the content::DownloadManager instance. 63 // Called to get the content::DownloadManager instance.
60 virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record); 64 virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record);
61 65
62 private: 66 private:
63 // For testing. 67 // For testing.
64 friend class DownloadManagerServiceTest; 68 friend class DownloadManagerServiceTest;
65 69
66 // Helper function to start the download resumption. 70 // Helper function to start the download resumption.
67 void ResumeDownloadInternal(const std::string& download_guid); 71 void ResumeDownloadInternal(const std::string& download_guid);
68 72
69 // Helper function to cancel a download. 73 // Helper function to cancel a download.
70 void CancelDownloadInternal(const std::string& download_guid, 74 void CancelDownloadInternal(const std::string& download_guid,
71 bool is_off_the_record); 75 bool is_off_the_record);
72 76
73 // Helper function to pause a download. 77 // Helper function to pause a download.
74 void PauseDownloadInternal(const std::string& download_guid); 78 void PauseDownloadInternal(const std::string& download_guid);
75 79
80 // Helper function to send info about all downloads to the Java-side.
81 void GetAllDownloadsInternal();
82
76 // Called to notify the java side that download resumption failed. 83 // Called to notify the java side that download resumption failed.
77 void OnResumptionFailed(const std::string& download_guid); 84 void OnResumptionFailed(const std::string& download_guid);
78 85
79 void OnResumptionFailedInternal(const std::string& download_guid); 86 void OnResumptionFailedInternal(const std::string& download_guid);
80 87
81 typedef base::Callback<void(bool)> ResumeCallback; 88 typedef base::Callback<void(bool)> ResumeCallback;
82 void set_resume_callback_for_testing(const ResumeCallback& resume_cb) { 89 void set_resume_callback_for_testing(const ResumeCallback& resume_cb) {
83 resume_callback_for_testing_ = resume_cb; 90 resume_callback_for_testing_ = resume_cb;
84 } 91 }
85 92
86 // Reference to the Java object. 93 // Reference to the Java object.
87 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 94 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
88 95
89 bool is_history_query_complete_; 96 bool is_history_query_complete_;
90 97
91 enum DownloadAction { RESUME, PAUSE, CANCEL, UNKNOWN }; 98 enum DownloadAction { RESUME, PAUSE, CANCEL, INITIALIZE_UI, UNKNOWN };
92 99
93 using PendingDownloadActions = std::map<std::string, DownloadAction>; 100 using PendingDownloadActions = std::map<std::string, DownloadAction>;
94 PendingDownloadActions pending_actions_; 101 PendingDownloadActions pending_actions_;
95 102
96 void EnqueueDownloadAction(const std::string& download_guid, 103 void EnqueueDownloadAction(const std::string& download_guid,
97 DownloadAction action); 104 DownloadAction action);
98 105
99 ResumeCallback resume_callback_for_testing_; 106 ResumeCallback resume_callback_for_testing_;
100 107
101 DISALLOW_COPY_AND_ASSIGN(DownloadManagerService); 108 DISALLOW_COPY_AND_ASSIGN(DownloadManagerService);
102 }; 109 };
103 110
104 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_ 111 #endif // CHROME_BROWSER_ANDROID_DOWNLOAD_DOWNLOAD_MANAGER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698