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

Side by Side Diff: chrome/browser/download/download_file_manager.h

Issue 2805091: Download code cleanup: (Closed)
Patch Set: rebased Created 10 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
« no previous file with comments | « base/tuple.h ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // The DownloadFileManager owns a set of DownloadFile objects, each of which 5 // The DownloadFileManager owns a set of DownloadFile objects, each of which
6 // represent one in progress download and performs the disk IO for that 6 // represent one in progress download and performs the disk IO for that
7 // download. The DownloadFileManager itself is a singleton object owned by the 7 // download. The DownloadFileManager itself is a singleton object owned by the
8 // ResourceDispatcherHost. 8 // ResourceDispatcherHost.
9 // 9 //
10 // The DownloadFileManager uses the file_thread for performing file write 10 // The DownloadFileManager uses the file_thread for performing file write
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Called on the IO thread 71 // Called on the IO thread
72 int GetNextId(); 72 int GetNextId();
73 73
74 // Handlers for notifications sent from the IO thread and run on the 74 // Handlers for notifications sent from the IO thread and run on the
75 // download thread. 75 // download thread.
76 void StartDownload(DownloadCreateInfo* info); 76 void StartDownload(DownloadCreateInfo* info);
77 void UpdateDownload(int id, DownloadBuffer* buffer); 77 void UpdateDownload(int id, DownloadBuffer* buffer);
78 void CancelDownload(int id); 78 void CancelDownload(int id);
79 void DownloadFinished(int id, DownloadBuffer* buffer); 79 void DownloadFinished(int id, DownloadBuffer* buffer);
80 80
81 // Download the URL. Called on the UI thread and forwarded to the
82 // ResourceDispatcherHost on the IO thread.
83 void DownloadUrl(const GURL& url,
84 const GURL& referrer,
85 const std::string& referrer_charset,
86 const DownloadSaveInfo& save_info,
87 int render_process_host_id,
88 int render_view_id,
89 URLRequestContextGetter* request_context_getter);
90
91 // Called on the UI thread to remove a download item or manager. 81 // Called on the UI thread to remove a download item or manager.
92 void RemoveDownloadManager(DownloadManager* manager); 82 void RemoveDownloadManager(DownloadManager* manager);
93 void RemoveDownload(int id, DownloadManager* manager); 83 void RemoveDownload(int id, DownloadManager* manager);
94 84
95 #if !defined(OS_MACOSX) 85 #if !defined(OS_MACOSX)
96 // The open and show methods run on the file thread, which does not work on 86 // The open and show methods run on the file thread, which does not work on
97 // Mac OS X (which uses the UI thread for opens). 87 // Mac OS X (which uses the UI thread for opens).
98 88
99 // Handler for shell operations sent from the UI to the download thread. 89 // Handler for shell operations sent from the UI to the download thread.
100 void OnShowDownloadInShell(const FilePath& full_path); 90 void OnShowDownloadInShell(const FilePath& full_path);
(...skipping 15 matching lines...) Expand all
116 ~DownloadFileManager(); 106 ~DownloadFileManager();
117 107
118 // Timer helpers for updating the UI about the current progress of a download. 108 // Timer helpers for updating the UI about the current progress of a download.
119 void StartUpdateTimer(); 109 void StartUpdateTimer();
120 void StopUpdateTimer(); 110 void StopUpdateTimer();
121 void UpdateInProgressDownloads(); 111 void UpdateInProgressDownloads();
122 112
123 // Clean up helper that runs on the download thread. 113 // Clean up helper that runs on the download thread.
124 void OnShutdown(); 114 void OnShutdown();
125 115
126 // Run on the IO thread to initiate the download of a URL.
127 void OnDownloadUrl(const GURL& url,
128 const GURL& referrer,
129 const std::string& referrer_charset,
130 const DownloadSaveInfo& save_info,
131 int render_process_host_id,
132 int render_view_id,
133 URLRequestContextGetter* request_context_getter);
134
135 // Handlers for notifications sent from the download thread and run on 116 // Handlers for notifications sent from the download thread and run on
136 // the UI thread. 117 // the UI thread.
137 void OnStartDownload(DownloadCreateInfo* info); 118 void OnStartDownload(DownloadCreateInfo* info);
138 void OnDownloadFinished(int id, int64 bytes_so_far); 119 void OnDownloadFinished(int id, int64 bytes_so_far);
139 120
140 // Called only on UI thread to get the DownloadManager for a tab's profile. 121 // Called only on UI thread to get the DownloadManager for a tab's profile.
141 static DownloadManager* DownloadManagerFromRenderIds(int render_process_id, 122 static DownloadManager* DownloadManagerFromRenderIds(int render_process_id,
142 int review_view_id); 123 int review_view_id);
143 DownloadManager* LookupManager(int download_id); 124 DownloadManager* GetDownloadManager(int download_id);
144 125
145 // Called only on the download thread. 126 // Called only on the download thread.
146 DownloadFile* LookupDownload(int id); 127 DownloadFile* GetDownloadFile(int id);
147 128
148 // Called on the UI thread to remove a download from the UI progress table. 129 // Called on the UI thread to remove a download from the UI progress table.
149 void RemoveDownloadFromUIProgress(int id); 130 void RemoveDownloadFromUIProgress(int id);
150 131
151 // Unique ID for each DownloadFile. 132 // Unique ID for each DownloadFile.
152 int next_id_; 133 int next_id_;
153 134
154 // A map of all in progress downloads. 135 // A map of all in progress downloads.
155 typedef base::hash_map<int, DownloadFile*> DownloadFileMap; 136 typedef base::hash_map<int, DownloadFile*> DownloadFileMap;
156 DownloadFileMap downloads_; 137 DownloadFileMap downloads_;
(...skipping 17 matching lines...) Expand all
174 // Used for progress updates on the UI thread, mapping download->id() to bytes 155 // Used for progress updates on the UI thread, mapping download->id() to bytes
175 // received so far. Written to by the file thread and read by the UI thread. 156 // received so far. Written to by the file thread and read by the UI thread.
176 typedef base::hash_map<int, int64> ProgressMap; 157 typedef base::hash_map<int, int64> ProgressMap;
177 ProgressMap ui_progress_; 158 ProgressMap ui_progress_;
178 Lock progress_lock_; 159 Lock progress_lock_;
179 160
180 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); 161 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager);
181 }; 162 };
182 163
183 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ 164 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_
OLDNEW
« no previous file with comments | « base/tuple.h ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698