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 #include "content/browser/download/download_request_handle.h" | 5 #include "content/browser/download/download_request_handle.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
8 #include "content/browser/browser_context.h" | 9 #include "content/browser/browser_context.h" |
9 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
10 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
11 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 12 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
13 | 14 |
14 // IO Thread indirections to resource dispatcher host. | 15 // IO Thread indirections to resource dispatcher host. |
15 // Provided as targets for PostTask from within this object | 16 // Provided as targets for PostTask from within this object |
16 // only. | 17 // only. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return NULL; | 73 return NULL; |
73 return context->GetDownloadManager(); | 74 return context->GetDownloadManager(); |
74 } | 75 } |
75 | 76 |
76 void DownloadRequestHandle::PauseRequest() const { | 77 void DownloadRequestHandle::PauseRequest() const { |
77 // The post is safe because ResourceDispatcherHost is guaranteed | 78 // The post is safe because ResourceDispatcherHost is guaranteed |
78 // to outlive the IO thread. | 79 // to outlive the IO thread. |
79 if (rdh_) { | 80 if (rdh_) { |
80 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
81 BrowserThread::IO, FROM_HERE, | 82 BrowserThread::IO, FROM_HERE, |
82 NewRunnableFunction(&ResourceDispatcherHostPauseRequest, | 83 base::Bind(&ResourceDispatcherHostPauseRequest, |
83 rdh_, child_id_, request_id_, true)); | 84 rdh_, child_id_, request_id_, true)); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 void DownloadRequestHandle::ResumeRequest() const { | 88 void DownloadRequestHandle::ResumeRequest() const { |
88 // The post is safe because ResourceDispatcherHost is guaranteed | 89 // The post is safe because ResourceDispatcherHost is guaranteed |
89 // to outlive the IO thread. | 90 // to outlive the IO thread. |
90 if (rdh_) { | 91 if (rdh_) { |
91 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
92 BrowserThread::IO, FROM_HERE, | 93 BrowserThread::IO, FROM_HERE, |
93 NewRunnableFunction(&ResourceDispatcherHostPauseRequest, | 94 base::Bind(&ResourceDispatcherHostPauseRequest, |
94 rdh_, child_id_, request_id_, false)); | 95 rdh_, child_id_, request_id_, false)); |
95 } | 96 } |
96 } | 97 } |
97 | 98 |
98 void DownloadRequestHandle::CancelRequest() const { | 99 void DownloadRequestHandle::CancelRequest() const { |
99 // The post is safe because ResourceDispatcherHost is guaranteed | 100 // The post is safe because ResourceDispatcherHost is guaranteed |
100 // to outlive the IO thread. | 101 // to outlive the IO thread. |
101 if (rdh_) { | 102 if (rdh_) { |
102 BrowserThread::PostTask( | 103 BrowserThread::PostTask( |
103 BrowserThread::IO, FROM_HERE, | 104 BrowserThread::IO, FROM_HERE, |
104 NewRunnableFunction(&ResourceDispatcherHostCancelRequest, | 105 base::Bind(&ResourceDispatcherHostCancelRequest, |
105 rdh_, child_id_, request_id_)); | 106 rdh_, child_id_, request_id_)); |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 std::string DownloadRequestHandle::DebugString() const { | 110 std::string DownloadRequestHandle::DebugString() const { |
110 return base::StringPrintf("{" | 111 return base::StringPrintf("{" |
111 " child_id = %d" | 112 " child_id = %d" |
112 " render_view_id = %d" | 113 " render_view_id = %d" |
113 " request_id = %d" | 114 " request_id = %d" |
114 "}", | 115 "}", |
115 child_id_, | 116 child_id_, |
116 render_view_id_, | 117 render_view_id_, |
117 request_id_); | 118 request_id_); |
118 } | 119 } |
OLD | NEW |