OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/browser/download/download_resource_handler.h" | 12 #include "content/browser/download/download_resource_handler.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/resource_request_info.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 class DownloadManager; | 17 class DownloadManager; |
17 class WebContents; | 18 class WebContents; |
18 | 19 |
19 // A handle used by the download system for operations on the URLRequest | 20 // A handle used by the download system for operations on the URLRequest |
20 // or objects conditional on it (e.g. WebContentsImpl). | 21 // or objects conditional on it (e.g. WebContentsImpl). |
21 // This class needs to be copyable, so we can pass it across threads and not | 22 // This class needs to be copyable, so we can pass it across threads and not |
22 // worry about lifetime or const-ness. | 23 // worry about lifetime or const-ness. |
23 // | 24 // |
(...skipping 25 matching lines...) Expand all Loading... |
49 | 50 |
50 // Create a null DownloadRequestHandle: getters will return null, and | 51 // Create a null DownloadRequestHandle: getters will return null, and |
51 // all actions are no-ops. | 52 // all actions are no-ops. |
52 // TODO(rdsmith): Ideally, actions would be forbidden rather than | 53 // TODO(rdsmith): Ideally, actions would be forbidden rather than |
53 // no-ops, to confirm that no non-testing code actually uses | 54 // no-ops, to confirm that no non-testing code actually uses |
54 // a null DownloadRequestHandle. But for now, we need the no-op | 55 // a null DownloadRequestHandle. But for now, we need the no-op |
55 // behavior for unit tests. Long-term, this should be fixed by | 56 // behavior for unit tests. Long-term, this should be fixed by |
56 // allowing mocking of ResourceDispatcherHost in unit tests. | 57 // allowing mocking of ResourceDispatcherHost in unit tests. |
57 DownloadRequestHandle(); | 58 DownloadRequestHandle(); |
58 | 59 |
59 // Note that |rdh| is required to be non-null. | |
60 DownloadRequestHandle(const base::WeakPtr<DownloadResourceHandler>& handler, | 60 DownloadRequestHandle(const base::WeakPtr<DownloadResourceHandler>& handler, |
61 int child_id, | 61 const content::ResourceRequestInfo::WebContentsGetter& |
62 int render_view_id, | 62 web_contents_getter); |
63 int request_id, | |
64 int frame_tree_node_id); | |
65 | 63 |
66 // Implement DownloadRequestHandleInterface interface. | 64 // Implement DownloadRequestHandleInterface interface. |
67 WebContents* GetWebContents() const override; | 65 WebContents* GetWebContents() const override; |
68 DownloadManager* GetDownloadManager() const override; | 66 DownloadManager* GetDownloadManager() const override; |
69 void PauseRequest() const override; | 67 void PauseRequest() const override; |
70 void ResumeRequest() const override; | 68 void ResumeRequest() const override; |
71 void CancelRequest() const override; | 69 void CancelRequest() const override; |
72 std::string DebugString() const override; | 70 std::string DebugString() const override; |
73 | 71 |
74 private: | 72 private: |
75 base::WeakPtr<DownloadResourceHandler> handler_; | 73 base::WeakPtr<DownloadResourceHandler> handler_; |
76 | 74 content::ResourceRequestInfo::WebContentsGetter web_contents_getter_; |
77 // The ID of the child process that started the download. | |
78 int child_id_; | |
79 | |
80 // The ID of the render view that started the download. | |
81 int render_view_id_; | |
82 | |
83 // The ID associated with the request used for the download. | |
84 int request_id_; | |
85 | |
86 // PlzNavigate | |
87 // The ID of the FrameTreeNode that started the download. | |
88 int frame_tree_node_id_; | |
89 }; | 75 }; |
90 | 76 |
91 } // namespace content | 77 } // namespace content |
92 | 78 |
93 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | 79 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ |
OLD | NEW |