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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | |
13 #include "content/browser/download/download_resource_handler.h" | |
12 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 class DownloadManager; | 17 class DownloadManager; |
16 class WebContents; | 18 class WebContents; |
17 } | 19 } |
18 | 20 |
19 // A handle used by the download system for operations on the URLRequest | 21 // A handle used by the download system for operations on the URLRequest |
20 // or objects conditional on it (e.g. WebContentsImpl). | 22 // or objects conditional on it (e.g. WebContentsImpl). |
21 // This class needs to be copyable, so we can pass it across threads and not | 23 // This class needs to be copyable, so we can pass it across threads and not |
(...skipping 16 matching lines...) Expand all Loading... | |
38 virtual void CancelRequest() const = 0; | 40 virtual void CancelRequest() const = 0; |
39 | 41 |
40 // Describe the object. | 42 // Describe the object. |
41 virtual std::string DebugString() const = 0; | 43 virtual std::string DebugString() const = 0; |
42 }; | 44 }; |
43 | 45 |
44 | 46 |
45 class CONTENT_EXPORT DownloadRequestHandle | 47 class CONTENT_EXPORT DownloadRequestHandle |
46 : public DownloadRequestHandleInterface { | 48 : public DownloadRequestHandleInterface { |
47 public: | 49 public: |
50 virtual ~DownloadRequestHandle(); | |
51 | |
48 // Create a null DownloadRequestHandle: getters will return null, and | 52 // Create a null DownloadRequestHandle: getters will return null, and |
49 // all actions are no-ops. | 53 // all actions are no-ops. |
50 // TODO(rdsmith): Ideally, actions would be forbidden rather than | 54 // TODO(rdsmith): Ideally, actions would be forbidden rather than |
51 // no-ops, to confirm that no non-testing code actually uses | 55 // no-ops, to confirm that no non-testing code actually uses |
52 // a null DownloadRequestHandle. But for now, we need the no-op | 56 // a null DownloadRequestHandle. But for now, we need the no-op |
53 // behavior for unit tests. Long-term, this should be fixed by | 57 // behavior for unit tests. Long-term, this should be fixed by |
54 // allowing mocking of ResourceDispatcherHost in unit tests. | 58 // allowing mocking of ResourceDispatcherHost in unit tests. |
55 DownloadRequestHandle(); | 59 DownloadRequestHandle(); |
56 | 60 |
57 // Note that |rdh| is required to be non-null. | 61 // Note that |rdh| is required to be non-null. |
58 DownloadRequestHandle(int child_id, | 62 DownloadRequestHandle(DownloadResourceHandler* handler, |
63 int child_id, | |
59 int render_view_id, | 64 int render_view_id, |
60 int request_id); | 65 int request_id); |
61 | 66 |
62 // Implement DownloadRequestHandleInterface interface. | 67 // Implement DownloadRequestHandleInterface interface. |
63 virtual content::WebContents* GetWebContents() const OVERRIDE; | 68 virtual content::WebContents* GetWebContents() const OVERRIDE; |
64 virtual content::DownloadManager* GetDownloadManager() const OVERRIDE; | 69 virtual content::DownloadManager* GetDownloadManager() const OVERRIDE; |
65 virtual void PauseRequest() const OVERRIDE; | 70 virtual void PauseRequest() const OVERRIDE; |
66 virtual void ResumeRequest() const OVERRIDE; | 71 virtual void ResumeRequest() const OVERRIDE; |
67 virtual void CancelRequest() const OVERRIDE; | 72 virtual void CancelRequest() const OVERRIDE; |
68 virtual std::string DebugString() const OVERRIDE; | 73 virtual std::string DebugString() const OVERRIDE; |
69 | 74 |
70 private: | 75 private: |
76 scoped_refptr<DownloadResourceHandler> handler_; | |
Randy Smith (Not in Mondays)
2012/05/17 15:53:48
Shouldn't this be a weak pointer? I could easily
darin (slow to review)
2012/05/17 21:17:57
It seems OK to extend the lifetime of the Handler.
| |
77 | |
71 // The ID of the child process that started the download. | 78 // The ID of the child process that started the download. |
72 int child_id_; | 79 int child_id_; |
73 | 80 |
74 // The ID of the render view that started the download. | 81 // The ID of the render view that started the download. |
75 int render_view_id_; | 82 int render_view_id_; |
76 | 83 |
77 // The ID associated with the request used for the download. | 84 // The ID associated with the request used for the download. |
78 int request_id_; | 85 int request_id_; |
79 }; | 86 }; |
80 | 87 |
81 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ | 88 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_ |
OLD | NEW |