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/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "chrome/browser/download/download_process_handle.h" | |
18 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
19 | 18 |
20 #if defined(TOOLKIT_VIEWS) | 19 #if defined(TOOLKIT_VIEWS) |
21 #include "views/view.h" | 20 #include "views/view.h" |
22 #endif | 21 #endif |
23 | 22 |
24 class BaseDownloadItemModel; | 23 class BaseDownloadItemModel; |
25 class CrxInstaller; | 24 class CrxInstaller; |
26 class DictionaryValue; | 25 class DictionaryValue; |
27 class DownloadItem; | 26 class DownloadItem; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // Download the URL. Must be called on the IO thread. | 261 // Download the URL. Must be called on the IO thread. |
263 void DownloadUrl(const GURL& url, | 262 void DownloadUrl(const GURL& url, |
264 const GURL& referrer, | 263 const GURL& referrer, |
265 const std::string& referrer_charset, | 264 const std::string& referrer_charset, |
266 const DownloadSaveInfo& save_info, | 265 const DownloadSaveInfo& save_info, |
267 ResourceDispatcherHost* rdh, | 266 ResourceDispatcherHost* rdh, |
268 int render_process_host_id, | 267 int render_process_host_id, |
269 int render_view_id, | 268 int render_view_id, |
270 const content::ResourceContext* context); | 269 const content::ResourceContext* context); |
271 | 270 |
272 // Tells the resource dispatcher host to cancel a download request. | |
273 // Must be called on the IO thread. | |
274 // |process_handle| is passed by value because it is ultimately passed to | |
275 // other threads, and this way we don't have to worry about object lifetimes. | |
276 void CancelDownloadRequest(ResourceDispatcherHost* rdh, | |
277 DownloadProcessHandle process_handle); | |
278 | |
279 // Sends a notification on downloads being initiated | 271 // Sends a notification on downloads being initiated |
280 // Must be called on the UI thread. | 272 // Must be called on the UI thread. |
281 void NotifyDownloadInitiated(int render_process_id, int render_view_id); | 273 void NotifyDownloadInitiated(int render_process_id, int render_view_id); |
282 | 274 |
283 // Same as GetUniquePathNumber, except that it also checks the existence | 275 // Same as GetUniquePathNumber, except that it also checks the existence |
284 // of its .crdownload intermediate path. | 276 // of its .crdownload intermediate path. |
285 // If |path| does not exist, 0 is returned. If it fails to find such | 277 // If |path| does not exist, 0 is returned. If it fails to find such |
286 // a number, -1 is returned. | 278 // a number, -1 is returned. |
287 int GetUniquePathNumberWithCrDownload(const FilePath& path); | 279 int GetUniquePathNumberWithCrDownload(const FilePath& path); |
288 | 280 |
289 // Erases all downloaded files with the specified path and name prefix. | 281 // Erases all downloaded files with the specified path and name prefix. |
290 // Used by download UI tests to clean up the download directory. | 282 // Used by download UI tests to clean up the download directory. |
291 void EraseUniqueDownloadFiles(const FilePath& path_prefix); | 283 void EraseUniqueDownloadFiles(const FilePath& path_prefix); |
292 | 284 |
293 // Returns a .crdownload intermediate path for the |suggested_path|. | 285 // Returns a .crdownload intermediate path for the |suggested_path|. |
294 FilePath GetCrDownloadPath(const FilePath& suggested_path); | 286 FilePath GetCrDownloadPath(const FilePath& suggested_path); |
295 | 287 |
296 } // namespace download_util | 288 } // namespace download_util |
297 | 289 |
298 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ | 290 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ |
OLD | NEW |