Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2503813002: Fix and refactor downloaded file handling in the loading stack (Closed)
Patch Set: move to dtor Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/browser/loader/downloaded_temp_file_impl.h"
15 #include "content/browser/loader/netlog_observer.h" 16 #include "content/browser/loader/netlog_observer.h"
16 #include "content/browser/loader/resource_dispatcher_host_impl.h" 17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
17 #include "content/browser/loader/resource_request_info_impl.h" 18 #include "content/browser/loader/resource_request_info_impl.h"
18 #include "content/common/resource_request_completion_status.h" 19 #include "content/common/resource_request_completion_status.h"
19 #include "content/public/browser/global_request_id.h" 20 #include "content/public/browser/global_request_id.h"
20 #include "content/public/browser/resource_controller.h" 21 #include "content/public/browser/resource_controller.h"
21 #include "content/public/browser/resource_dispatcher_host_delegate.h" 22 #include "content/public/browser/resource_dispatcher_host_delegate.h"
22 #include "content/public/common/resource_response.h" 23 #include "content/public/common/resource_response.h"
23 #include "mojo/public/c/system/data_pipe.h" 24 #include "mojo/public/c/system/data_pipe.h"
24 #include "mojo/public/cpp/bindings/message.h" 25 #include "mojo/public/cpp/bindings/message.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (rdh_->delegate()) { 157 if (rdh_->delegate()) {
157 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(), 158 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(),
158 response); 159 response);
159 } 160 }
160 161
161 NetLogObserver::PopulateResponseInfo(request(), response); 162 NetLogObserver::PopulateResponseInfo(request(), response);
162 163
163 response->head.request_start = request()->creation_time(); 164 response->head.request_start = request()->creation_time();
164 response->head.response_start = base::TimeTicks::Now(); 165 response->head.response_start = base::TimeTicks::Now();
165 sent_received_response_message_ = true; 166 sent_received_response_message_ = true;
166 url_loader_client_->OnReceiveResponse(response->head); 167
168 mojom::DownloadedTempFilePtr downloaded_file_ptr;
169 if (!response->head.download_file_path.empty()) {
170 downloaded_file_ptr = DownloadedTempFileImpl::Create(info->GetChildID(),
171 info->GetRequestID());
172 rdh_->RegisterDownloadedTempFile(info->GetChildID(), info->GetRequestID(),
173 response->head.download_file_path);
174 }
175
176 url_loader_client_->OnReceiveResponse(response->head,
177 std::move(downloaded_file_ptr));
167 return true; 178 return true;
168 } 179 }
169 180
170 bool MojoAsyncResourceHandler::OnWillStart(const GURL& url, bool* defer) { 181 bool MojoAsyncResourceHandler::OnWillStart(const GURL& url, bool* defer) {
171 return true; 182 return true;
172 } 183 }
173 184
174 bool MojoAsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, 185 bool MojoAsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
175 int* buf_size, 186 int* buf_size,
176 int min_size) { 187 int min_size) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 const ResourceRequestInfoImpl* info = GetRequestInfo(); 443 const ResourceRequestInfoImpl* info = GetRequestInfo();
433 ResourceDispatcherHostImpl::Get()->CancelRequestFromRenderer( 444 ResourceDispatcherHostImpl::Get()->CancelRequestFromRenderer(
434 GlobalRequestID(info->GetChildID(), info->GetRequestID())); 445 GlobalRequestID(info->GetChildID(), info->GetRequestID()));
435 } 446 }
436 447
437 void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) { 448 void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) {
438 mojo::ReportBadMessage(error); 449 mojo::ReportBadMessage(error);
439 } 450 }
440 451
441 } // namespace content 452 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/downloaded_temp_file_impl.cc ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698