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

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: moved definition up Created 3 years, 8 months 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 "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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 } 346 }
347 347
348 void NotifyUIThreadOfRequestComplete( 348 void NotifyUIThreadOfRequestComplete(
349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
350 const GURL& url, 350 const GURL& url,
351 const content::GlobalRequestID& request_id, 351 const content::GlobalRequestID& request_id,
352 ResourceType resource_type, 352 ResourceType resource_type,
353 bool was_cached, 353 bool was_cached,
354 bool used_data_reduction_proxy, 354 bool used_data_reduction_proxy,
355 bool was_lofi_reponse,
bengr 2017/04/20 17:36:18 What is a lofi response? Does this bit get set on
RyanSturm 2017/04/20 20:25:44 Obsolete. Changed to DRPData.
355 int net_error, 356 int net_error,
356 int64_t total_received_bytes, 357 int64_t total_received_bytes,
357 int64_t raw_body_bytes, 358 int64_t raw_body_bytes,
358 int64_t original_content_length, 359 int64_t original_content_length,
359 base::TimeTicks request_creation_time, 360 base::TimeTicks request_creation_time,
360 base::TimeDelta request_loading_time) { 361 base::TimeDelta request_loading_time) {
361 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 362 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
362 content::WebContents* web_contents = web_contents_getter.Run(); 363 content::WebContents* web_contents = web_contents_getter.Run();
363 if (!web_contents) 364 if (!web_contents)
364 return; 365 return;
(...skipping 10 matching lines...) Expand all
375 if (background_loader) 376 if (background_loader)
376 background_loader->OnNetworkBytesChanged(total_received_bytes); 377 background_loader->OnNetworkBytesChanged(total_received_bytes);
377 #endif // OS_ANDROID 378 #endif // OS_ANDROID
378 } 379 }
379 page_load_metrics::MetricsWebContentsObserver* metrics_observer = 380 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
380 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 381 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
381 web_contents); 382 web_contents);
382 if (metrics_observer) { 383 if (metrics_observer) {
383 metrics_observer->OnRequestComplete( 384 metrics_observer->OnRequestComplete(
384 request_id, resource_type, was_cached, used_data_reduction_proxy, 385 request_id, resource_type, was_cached, used_data_reduction_proxy,
385 raw_body_bytes, original_content_length, request_creation_time); 386 was_lofi_reponse, raw_body_bytes, original_content_length,
387 request_creation_time);
386 } 388 }
387 } 389 }
388 390
389 } // namespace 391 } // namespace
390 392
391 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() 393 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate()
392 : download_request_limiter_(g_browser_process->download_request_limiter()), 394 : download_request_limiter_(g_browser_process->download_request_limiter()),
393 safe_browsing_(g_browser_process->safe_browsing_service()) 395 safe_browsing_(g_browser_process->safe_browsing_service())
394 #if BUILDFLAG(ENABLE_EXTENSIONS) 396 #if BUILDFLAG(ENABLE_EXTENSIONS)
395 , user_script_listener_(new extensions::UserScriptListener()) 397 , user_script_listener_(new extensions::UserScriptListener())
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 return; 839 return;
838 // TODO(maksims): remove this and use net_error argument in RequestComplete 840 // TODO(maksims): remove this and use net_error argument in RequestComplete
839 // once ResourceDispatcherHostDelegate is modified. 841 // once ResourceDispatcherHostDelegate is modified.
840 int net_error = url_request->status().error(); 842 int net_error = url_request->status().error();
841 const ResourceRequestInfo* info = 843 const ResourceRequestInfo* info =
842 ResourceRequestInfo::ForRequest(url_request); 844 ResourceRequestInfo::ForRequest(url_request);
843 845
844 data_reduction_proxy::DataReductionProxyData* data = 846 data_reduction_proxy::DataReductionProxyData* data =
845 data_reduction_proxy::DataReductionProxyData::GetData(*url_request); 847 data_reduction_proxy::DataReductionProxyData::GetData(*url_request);
846 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy(); 848 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy();
849 bool was_lofi_reponse = data && data->lofi_received();
847 int64_t original_content_length = 850 int64_t original_content_length =
848 used_data_reduction_proxy 851 used_data_reduction_proxy
849 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) 852 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request)
850 : url_request->GetRawBodyBytes(); 853 : url_request->GetRawBodyBytes();
851 854
852 BrowserThread::PostTask( 855 BrowserThread::PostTask(
853 BrowserThread::UI, FROM_HERE, 856 BrowserThread::UI, FROM_HERE,
854 base::Bind(&NotifyUIThreadOfRequestComplete, 857 base::Bind(&NotifyUIThreadOfRequestComplete,
855 info->GetWebContentsGetterForRequest(), url_request->url(), 858 info->GetWebContentsGetterForRequest(), url_request->url(),
856 info->GetGlobalRequestID(), info->GetResourceType(), 859 info->GetGlobalRequestID(), info->GetResourceType(),
857 url_request->was_cached(), used_data_reduction_proxy, 860 url_request->was_cached(), used_data_reduction_proxy,
858 net_error, url_request->GetTotalReceivedBytes(), 861 was_lofi_reponse, net_error,
862 url_request->GetTotalReceivedBytes(),
859 url_request->GetRawBodyBytes(), original_content_length, 863 url_request->GetRawBodyBytes(), original_content_length,
860 url_request->creation_time(), 864 url_request->creation_time(),
861 base::TimeTicks::Now() - url_request->creation_time())); 865 base::TimeTicks::Now() - url_request->creation_time()));
862 } 866 }
863 867
864 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( 868 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState(
865 const net::URLRequest& url_request, 869 const net::URLRequest& url_request,
866 content::ResourceContext* resource_context) { 870 content::ResourceContext* resource_context) {
867 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 871 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
868 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 872 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 937 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
934 base::Unretained(this), url, request_loading_time)); 938 base::Unretained(this), url, request_loading_time));
935 return; 939 return;
936 } 940 }
937 941
938 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 942 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
939 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 943 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
940 rappor::SampleDomainAndRegistryFromGURL( 944 rappor::SampleDomainAndRegistryFromGURL(
941 g_browser_process->rappor_service(), metric_name, url); 945 g_browser_process->rappor_service(), metric_name, url);
942 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698