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

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

Issue 2503813002: Fix and refactor downloaded file handling in the loading stack (Closed)
Patch Set: +RunUntilIdle Created 4 years, 1 month 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 (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/loader/async_resource_handler.h" 5 #include "content/browser/loader/async_resource_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/debug/alias.h" 12 #include "base/debug/alias.h"
13 #include "base/feature_list.h" 13 #include "base/feature_list.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
17 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "content/browser/loader/downloaded_temp_file_impl.h"
20 #include "content/browser/loader/netlog_observer.h" 21 #include "content/browser/loader/netlog_observer.h"
21 #include "content/browser/loader/resource_buffer.h" 22 #include "content/browser/loader/resource_buffer.h"
22 #include "content/browser/loader/resource_dispatcher_host_impl.h" 23 #include "content/browser/loader/resource_dispatcher_host_impl.h"
23 #include "content/browser/loader/resource_message_filter.h" 24 #include "content/browser/loader/resource_message_filter.h"
24 #include "content/browser/loader/resource_request_info_impl.h" 25 #include "content/browser/loader/resource_request_info_impl.h"
25 #include "content/common/resource_messages.h" 26 #include "content/common/resource_messages.h"
26 #include "content/common/resource_request_completion_status.h" 27 #include "content/common/resource_request_completion_status.h"
27 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
28 #include "content/public/browser/resource_controller.h" 29 #include "content/public/browser/resource_controller.h"
29 #include "content/public/browser/resource_dispatcher_host_delegate.h" 30 #include "content/public/browser/resource_dispatcher_host_delegate.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(), 348 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(),
348 response); 349 response);
349 } 350 }
350 351
351 NetLogObserver::PopulateResponseInfo(request(), response); 352 NetLogObserver::PopulateResponseInfo(request(), response);
352 response->head.encoded_data_length = request()->raw_header_size(); 353 response->head.encoded_data_length = request()->raw_header_size();
353 354
354 // If the parent handler downloaded the resource to a file, grant the child 355 // If the parent handler downloaded the resource to a file, grant the child
355 // read permissions on it. 356 // read permissions on it.
356 if (!response->head.download_file_path.empty()) { 357 if (!response->head.download_file_path.empty()) {
357 rdh_->RegisterDownloadedTempFile( 358 auto downloaded_file = base::MakeUnique<DownloadedTempFileImpl>(
358 info->GetChildID(), info->GetRequestID(), 359 rdh_, info->GetChildID(), info->GetRequestID(),
359 response->head.download_file_path); 360 response->head.download_file_path);
361 rdh_->RegisterDownloadedTempFile(std::move(downloaded_file));
360 } 362 }
361 363
362 response->head.request_start = request()->creation_time(); 364 response->head.request_start = request()->creation_time();
363 response->head.response_start = TimeTicks::Now(); 365 response->head.response_start = TimeTicks::Now();
364 info->filter()->Send(new ResourceMsg_ReceivedResponse(GetRequestID(), 366 info->filter()->Send(new ResourceMsg_ReceivedResponse(GetRequestID(),
365 response->head)); 367 response->head));
366 sent_received_response_msg_ = true; 368 sent_received_response_msg_ = true;
367 369
368 if (request()->response_info().metadata.get()) { 370 if (request()->response_info().metadata.get()) {
369 std::vector<char> copy(request()->response_info().metadata->data(), 371 std::vector<char> copy(request()->response_info().metadata->data(),
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } else { 589 } else {
588 UMA_HISTOGRAM_CUSTOM_COUNTS( 590 UMA_HISTOGRAM_CUSTOM_COUNTS(
589 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB", 591 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB",
590 elapsed_time, 1, 100000, 100); 592 elapsed_time, 1, 100000, 100);
591 } 593 }
592 594
593 inlining_helper_->RecordHistogram(elapsed_time); 595 inlining_helper_->RecordHistogram(elapsed_time);
594 } 596 }
595 597
596 } // namespace content 598 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698