Chromium Code Reviews| 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 "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" | 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 if (net_error == net::OK) { | 338 if (net_error == net::OK) { |
| 339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success", | 339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success", |
| 340 request_loading_time); | 340 request_loading_time); |
| 341 } else if (net_error == net::ERR_ABORTED) { | 341 } else if (net_error == net::ERR_ABORTED) { |
| 342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", | 342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", |
| 343 request_loading_time); | 343 request_loading_time); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 void NotifyUIThreadOfRequestStarted( | |
|
Charlie Harrison
2017/04/18 16:51:32
Can we use WebContentsObserver::DidGetResourceResp
RyanSturm
2017/04/18 17:23:57
This seems to be called when headers are received.
Charlie Harrison
2017/04/18 17:38:35
Woops, you're right I completely misread the name
| |
| 349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | |
| 350 const content::GlobalRequestID& request_id, | |
| 351 ResourceType resource_type, | |
| 352 base::TimeTicks request_creation_time) { | |
| 353 content::WebContents* web_contents = web_contents_getter.Run(); | |
| 354 | |
| 355 if (!web_contents) | |
| 356 return; | |
| 357 | |
| 358 page_load_metrics::MetricsWebContentsObserver* metrics_observer = | |
| 359 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | |
| 360 web_contents); | |
| 361 | |
| 362 if (metrics_observer) { | |
| 363 metrics_observer->OnRequestStarted(request_id, resource_type, | |
| 364 request_creation_time); | |
| 365 } | |
| 366 } | |
| 367 | |
| 348 void NotifyUIThreadOfRequestComplete( | 368 void NotifyUIThreadOfRequestComplete( |
| 349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 369 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 350 const GURL& url, | 370 const GURL& url, |
| 351 const content::GlobalRequestID& request_id, | 371 const content::GlobalRequestID& request_id, |
| 352 ResourceType resource_type, | 372 ResourceType resource_type, |
| 353 bool was_cached, | 373 bool was_cached, |
| 354 bool used_data_reduction_proxy, | 374 bool used_data_reduction_proxy, |
| 355 int net_error, | 375 int net_error, |
| 356 int64_t total_received_bytes, | 376 int64_t total_received_bytes, |
| 357 int64_t raw_body_bytes, | 377 int64_t raw_body_bytes, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 void ChromeResourceDispatcherHostDelegate::RequestBeginning( | 456 void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 437 net::URLRequest* request, | 457 net::URLRequest* request, |
| 438 content::ResourceContext* resource_context, | 458 content::ResourceContext* resource_context, |
| 439 content::AppCacheService* appcache_service, | 459 content::AppCacheService* appcache_service, |
| 440 ResourceType resource_type, | 460 ResourceType resource_type, |
| 441 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { | 461 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { |
| 442 if (safe_browsing_.get()) | 462 if (safe_browsing_.get()) |
| 443 safe_browsing_->OnResourceRequest(request); | 463 safe_browsing_->OnResourceRequest(request); |
| 444 | 464 |
| 445 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 465 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 466 | |
| 467 // TODO(petewil): Unify the safe browsing request and the metrics observer | |
| 468 // request if possible so we only have to cross to the main thread once. | |
| 469 // http://crbug.com/712312. | |
| 470 BrowserThread::PostTask( | |
| 471 BrowserThread::UI, FROM_HERE, | |
| 472 base::Bind(&NotifyUIThreadOfRequestStarted, | |
| 473 info->GetWebContentsGetterForRequest(), | |
| 474 info->GetGlobalRequestID(), info->GetResourceType(), | |
| 475 request->creation_time())); | |
| 476 | |
| 446 ProfileIOData* io_data = ProfileIOData::FromResourceContext( | 477 ProfileIOData* io_data = ProfileIOData::FromResourceContext( |
| 447 resource_context); | 478 resource_context); |
| 448 | 479 |
| 449 #if defined(OS_ANDROID) | 480 #if defined(OS_ANDROID) |
| 450 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) | 481 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
| 451 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); | 482 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); |
| 452 #endif | 483 #endif |
| 453 | 484 |
| 454 #if defined(OS_CHROMEOS) | 485 #if defined(OS_CHROMEOS) |
| 455 // Check if we need to add merge session throttle. This throttle will postpone | 486 // Check if we need to add merge session throttle. This throttle will postpone |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 943 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 913 base::Unretained(this), url, request_loading_time)); | 944 base::Unretained(this), url, request_loading_time)); |
| 914 return; | 945 return; |
| 915 } | 946 } |
| 916 | 947 |
| 917 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 948 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 918 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 949 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 919 rappor::SampleDomainAndRegistryFromGURL( | 950 rappor::SampleDomainAndRegistryFromGURL( |
| 920 g_browser_process->rappor_service(), metric_name, url); | 951 g_browser_process->rappor_service(), metric_name, url); |
| 921 } | 952 } |
| OLD | NEW |