OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 class DownloadManager; | |
12 class ResourceDispatcherHost; | |
13 class TabContents; | |
14 | |
15 // A handle used by the download system for operations on the URLRequest | |
16 // or objects conditional on it (e.g. TabContents). | |
17 // This class needs to be copyable, so we can pass it across threads and not | |
18 // worry about lifetime or const-ness. | |
19 class DownloadRequestHandle { | |
20 public: | |
21 // Create a null DownloadRequestHandle: getters will return null, and | |
22 // all actions are no-ops. | |
23 // TODO(rdsmith): Ideally, actions would be forbidden rather than | |
24 // no-ops, to confirm that no non-testing code actually uses | |
25 // a null DownloadRequestHandle. But for now, we need the no-op | |
26 // behavior for unit tests. Long-term, this should be fixed by | |
27 // allowing mocking of ResourceDispatcherHost in unit tests. | |
28 DownloadRequestHandle(); | |
29 | |
30 // Note that |rdh| is required to be non-null. | |
31 DownloadRequestHandle(ResourceDispatcherHost* rdh, | |
32 int child_id, | |
33 int render_view_id, | |
34 int request_id); | |
35 | |
36 // These functions must be called on the UI thread. | |
37 TabContents* GetTabContents() const; | |
38 DownloadManager* GetDownloadManager() const; | |
39 | |
40 // Pause or resume the matching URL request. | |
41 void PauseRequest() const; | |
42 void ResumeRequest() const; | |
43 | |
44 // Cancel the request | |
45 void CancelRequest() const; | |
46 | |
47 std::string DebugString() const; | |
48 | |
49 private: | |
50 // The resource dispatcher host. | |
51 ResourceDispatcherHost* rdh_; | |
52 | |
53 // The ID of the child process that started the download. | |
54 int child_id_; | |
55 | |
56 // The ID of the render view that started the download. | |
57 int render_view_id_; | |
58 | |
59 // The ID associated with the request used for the download. | |
60 int request_id_; | |
61 }; | |
62 | |
63 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | |
OLD | NEW |