| 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 #include "content/browser/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 tab_info_(new DownloadTabInfo()), | 88 tab_info_(new DownloadTabInfo()), |
| 89 core_(request, this) { | 89 core_(request, this) { |
| 90 // Do UI thread initialization for tab_info_ asap after | 90 // Do UI thread initialization for tab_info_ asap after |
| 91 // DownloadResourceHandler creation since the tab could be navigated | 91 // DownloadResourceHandler creation since the tab could be navigated |
| 92 // before StartOnUIThread gets called. This is safe because deletion | 92 // before StartOnUIThread gets called. This is safe because deletion |
| 93 // will occur via PostTask() as well, which will serialized behind this | 93 // will occur via PostTask() as well, which will serialized behind this |
| 94 // PostTask() | 94 // PostTask() |
| 95 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); | 95 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); |
| 96 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
| 97 BrowserThread::UI, FROM_HERE, | 97 BrowserThread::UI, FROM_HERE, |
| 98 base::Bind(&InitializeDownloadTabInfoOnUIThread, | 98 base::Bind( |
| 99 DownloadRequestHandle(AsWeakPtr(), request_info->GetChildID(), | 99 &InitializeDownloadTabInfoOnUIThread, |
| 100 request_info->GetRouteID(), | 100 DownloadRequestHandle(AsWeakPtr(), |
| 101 request_info->GetRequestID(), | 101 request_info->GetWebContentsGetterForRequest()), |
| 102 request_info->frame_tree_node_id()), | 102 tab_info_.get())); |
| 103 tab_info_.get())); | |
| 104 } | 103 } |
| 105 | 104 |
| 106 DownloadResourceHandler::~DownloadResourceHandler() { | 105 DownloadResourceHandler::~DownloadResourceHandler() { |
| 107 if (tab_info_) { | 106 if (tab_info_) { |
| 108 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
| 109 BrowserThread::UI, FROM_HERE, | 108 BrowserThread::UI, FROM_HERE, |
| 110 base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); | 109 base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); |
| 111 } | 110 } |
| 112 } | 111 } |
| 113 | 112 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 BrowserThread::UI, FROM_HERE, | 180 BrowserThread::UI, FROM_HERE, |
| 182 base::Bind(callback, nullptr, create_info->result)); | 181 base::Bind(callback, nullptr, create_info->result)); |
| 183 return; | 182 return; |
| 184 } | 183 } |
| 185 | 184 |
| 186 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); | 185 const ResourceRequestInfoImpl* request_info = GetRequestInfo(); |
| 187 create_info->has_user_gesture = request_info->HasUserGesture(); | 186 create_info->has_user_gesture = request_info->HasUserGesture(); |
| 188 create_info->transition_type = request_info->GetPageTransition(); | 187 create_info->transition_type = request_info->GetPageTransition(); |
| 189 | 188 |
| 190 create_info->request_handle.reset(new DownloadRequestHandle( | 189 create_info->request_handle.reset(new DownloadRequestHandle( |
| 191 AsWeakPtr(), request_info->GetChildID(), request_info->GetRouteID(), | 190 AsWeakPtr(), request_info->GetWebContentsGetterForRequest())); |
| 192 request_info->GetRequestID(), request_info->frame_tree_node_id())); | |
| 193 | 191 |
| 194 BrowserThread::PostTask( | 192 BrowserThread::PostTask( |
| 195 BrowserThread::UI, FROM_HERE, | 193 BrowserThread::UI, FROM_HERE, |
| 196 base::Bind(&StartOnUIThread, base::Passed(&create_info), | 194 base::Bind(&StartOnUIThread, base::Passed(&create_info), |
| 197 base::Passed(&tab_info_), base::Passed(&stream_reader), | 195 base::Passed(&tab_info_), base::Passed(&stream_reader), |
| 198 callback)); | 196 callback)); |
| 199 } | 197 } |
| 200 | 198 |
| 201 void DownloadResourceHandler::OnReadyToRead() { | 199 void DownloadResourceHandler::OnReadyToRead() { |
| 202 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 200 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 225 " }", | 223 " }", |
| 226 request() ? | 224 request() ? |
| 227 request()->url().spec().c_str() : | 225 request()->url().spec().c_str() : |
| 228 "<NULL request>", | 226 "<NULL request>", |
| 229 info->GetChildID(), | 227 info->GetChildID(), |
| 230 info->GetRequestID(), | 228 info->GetRequestID(), |
| 231 info->GetRouteID()); | 229 info->GetRouteID()); |
| 232 } | 230 } |
| 233 | 231 |
| 234 } // namespace content | 232 } // namespace content |
| OLD | NEW |