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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | |
10 | |
9 class DownloadManager; | 11 class DownloadManager; |
10 class ResourceDispatcherHost; | 12 class ResourceDispatcherHost; |
11 class TabContents; | 13 class TabContents; |
12 | 14 |
13 // A handle used by the download system for operations on external | 15 // A handle used by the download system for operations on external |
14 // objects associated with the download (e.g. URLRequest, TabContents, | 16 // objects associated with the download (e.g. URLRequest, TabContents, |
15 // DownloadManager). | 17 // DownloadManager). |
16 // This class needs to be copyable, so we can pass it across threads and not | 18 // This class needs to be copyable, so we can pass it across threads and not |
17 // worry about lifetime or const-ness. | 19 // worry about lifetime or const-ness. |
18 class DownloadProcessHandle { | 20 class DownloadProcessHandle { |
19 public: | 21 public: |
20 DownloadProcessHandle(); | 22 DownloadProcessHandle(); |
21 DownloadProcessHandle(int child_id, int render_view_id, int request_id); | 23 DownloadProcessHandle(ResourceDispatcherHost* rdh, |
24 int child_id, | |
25 int render_view_id, | |
26 int request_id); | |
22 | 27 |
23 // These functions must be called on the UI thread. | 28 // These functions must be called on the UI thread. |
24 TabContents* GetTabContents(); | 29 TabContents* GetTabContents(); |
25 DownloadManager* GetDownloadManager(); | 30 DownloadManager* GetDownloadManager(); |
26 | 31 |
27 int child_id() const { return child_id_; } | 32 // Pause or resume (|pause| == false) the matching URL request. |
28 int render_view_id() const { return render_view_id_; } | 33 // If the DownloadProcessHandle was constructed with a null |
Paweł Hajdan Jr.
2011/06/04 08:58:51
I'm worried about this possibly silent no-op. Is |
Randy Smith (Not in Mondays)
2011/06/07 22:41:11
Hmmm. The silent no-op is copied from the downloa
| |
29 int request_id() const { return request_id_; } | 34 // ResourceDispatcherHost, this is a no-op. |
35 void PauseRequest(bool pause); | |
36 | |
37 // Cancel the request | |
38 void CancelRequest(); | |
39 | |
40 std::string DebugString() const; | |
30 | 41 |
31 private: | 42 private: |
43 // IO Thread indirections to resource dispatcher host. | |
44 // Provided as targets for PostTask from within this object | |
45 // only. Safe to use as ResourceDispatcherHost outlives the | |
46 // IO thread. | |
47 static void RDHPauseRequest(ResourceDispatcherHost* rdh, | |
48 int process_unique_id, | |
49 int request_id, | |
50 bool pause); | |
51 static void RDHCancelRequest(ResourceDispatcherHost* rdh, | |
52 int process_unique_id, | |
53 int request_id); | |
54 | |
55 // The resource dispatcher host. | |
56 ResourceDispatcherHost* rdh_; | |
hendrickson_a
2011/06/04 16:01:45
Nit: It seems unintuitive from the name of the cla
Randy Smith (Not in Mondays)
2011/06/07 22:41:11
Yep. I think of that as being part of the encpasu
| |
57 | |
32 // The ID of the child process that started the download. | 58 // The ID of the child process that started the download. |
33 int child_id_; | 59 int child_id_; |
34 | 60 |
35 // The ID of the render view that started the download. | 61 // The ID of the render view that started the download. |
36 int render_view_id_; | 62 int render_view_id_; |
37 | 63 |
38 // The ID associated with the request used for the download. | 64 // The ID associated with the request used for the download. |
39 int request_id_; | 65 int request_id_; |
40 }; | 66 }; |
41 | 67 |
42 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ | 68 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PROCESS_HANDLE_H_ |
OLD | NEW |