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

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: -Release 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_dispatcher_host_delegate.h" 29 #include "content/public/browser/resource_dispatcher_host_delegate.h"
29 #include "content/public/common/content_features.h" 30 #include "content/public/common/content_features.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(), 347 rdh_->delegate()->OnResponseStarted(request(), info->GetContext(),
347 response); 348 response);
348 } 349 }
349 350
350 NetLogObserver::PopulateResponseInfo(request(), response); 351 NetLogObserver::PopulateResponseInfo(request(), response);
351 response->head.encoded_data_length = request()->raw_header_size(); 352 response->head.encoded_data_length = request()->raw_header_size();
352 353
353 // If the parent handler downloaded the resource to a file, grant the child 354 // If the parent handler downloaded the resource to a file, grant the child
354 // read permissions on it. 355 // read permissions on it.
355 if (!response->head.download_file_path.empty()) { 356 if (!response->head.download_file_path.empty()) {
356 rdh_->RegisterDownloadedTempFile( 357 auto downloaded_file = base::MakeUnique<DownloadedTempFileImpl>(
357 info->GetChildID(), info->GetRequestID(), 358 rdh_, info->GetChildID(), info->GetRequestID(),
358 response->head.download_file_path); 359 response->head.download_file_path);
360 rdh_->RegisterDownloadedTempFile(std::move(downloaded_file));
359 } 361 }
360 362
361 response->head.request_start = request()->creation_time(); 363 response->head.request_start = request()->creation_time();
362 response->head.response_start = TimeTicks::Now(); 364 response->head.response_start = TimeTicks::Now();
363 info->filter()->Send(new ResourceMsg_ReceivedResponse(GetRequestID(), 365 info->filter()->Send(new ResourceMsg_ReceivedResponse(GetRequestID(),
364 response->head)); 366 response->head));
365 sent_received_response_msg_ = true; 367 sent_received_response_msg_ = true;
366 368
367 if (request()->response_info().metadata.get()) { 369 if (request()->response_info().metadata.get()) {
368 std::vector<char> copy(request()->response_info().metadata->data(), 370 std::vector<char> copy(request()->response_info().metadata->data(),
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } else { 588 } else {
587 UMA_HISTOGRAM_CUSTOM_COUNTS( 589 UMA_HISTOGRAM_CUSTOM_COUNTS(
588 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB", 590 "Net.ResourceLoader.ResponseStartToEnd.Over_512kB",
589 elapsed_time, 1, 100000, 100); 591 elapsed_time, 1, 100000, 100);
590 } 592 }
591 593
592 inlining_helper_->RecordHistogram(elapsed_time); 594 inlining_helper_->RecordHistogram(elapsed_time);
593 } 595 }
594 596
595 } // namespace content 597 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698