OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utilities. | 5 // Download utilities. |
6 | 6 |
7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 7 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 8 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "chrome/browser/download/download_process_handle.h" | |
17 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
18 | 17 |
19 #if defined(TOOLKIT_VIEWS) | 18 #if defined(TOOLKIT_VIEWS) |
20 #include "views/view.h" | 19 #include "views/view.h" |
21 #endif | 20 #endif |
22 | 21 |
23 class BaseDownloadItemModel; | 22 class BaseDownloadItemModel; |
24 class DictionaryValue; | 23 class DictionaryValue; |
25 class DownloadItem; | 24 class DownloadItem; |
26 class DownloadManager; | 25 class DownloadManager; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // Download the URL. Must be called on the IO thread. | 240 // Download the URL. Must be called on the IO thread. |
242 void DownloadUrl(const GURL& url, | 241 void DownloadUrl(const GURL& url, |
243 const GURL& referrer, | 242 const GURL& referrer, |
244 const std::string& referrer_charset, | 243 const std::string& referrer_charset, |
245 const DownloadSaveInfo& save_info, | 244 const DownloadSaveInfo& save_info, |
246 ResourceDispatcherHost* rdh, | 245 ResourceDispatcherHost* rdh, |
247 int render_process_host_id, | 246 int render_process_host_id, |
248 int render_view_id, | 247 int render_view_id, |
249 const content::ResourceContext* context); | 248 const content::ResourceContext* context); |
250 | 249 |
251 // Tells the resource dispatcher host to cancel a download request. | |
252 // Must be called on the IO thread. | |
253 // |process_handle| is passed by value because it is ultimately passed to | |
254 // other threads, and this way we don't have to worry about object lifetimes. | |
255 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | |
256 DownloadProcessHandle process_handle); | |
257 | |
258 // Sends a notification on downloads being initiated | 250 // Sends a notification on downloads being initiated |
259 // Must be called on the UI thread. | 251 // Must be called on the UI thread. |
260 void NotifyDownloadInitiated(int render_process_id, int render_view_id); | 252 void NotifyDownloadInitiated(int render_process_id, int render_view_id); |
261 | 253 |
262 // Same as GetUniquePathNumber, except that it also checks the existence | 254 // Same as GetUniquePathNumber, except that it also checks the existence |
263 // of its .crdownload intermediate path. | 255 // of its .crdownload intermediate path. |
264 // If |path| does not exist, 0 is returned. If it fails to find such | 256 // If |path| does not exist, 0 is returned. If it fails to find such |
265 // a number, -1 is returned. | 257 // a number, -1 is returned. |
266 int GetUniquePathNumberWithCrDownload(const FilePath& path); | 258 int GetUniquePathNumberWithCrDownload(const FilePath& path); |
267 | 259 |
268 // Erases all downloaded files with the specified path and name prefix. | 260 // Erases all downloaded files with the specified path and name prefix. |
269 // Used by download UI tests to clean up the download directory. | 261 // Used by download UI tests to clean up the download directory. |
270 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 262 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
271 | 263 |
272 // Returns a .crdownload intermediate path for the |suggested_path|. | 264 // Returns a .crdownload intermediate path for the |suggested_path|. |
273 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 265 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
274 | 266 |
275 } // namespace download_util | 267 } // namespace download_util |
276 | 268 |
277 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 269 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |