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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 786 |
787 if (io_data->policy_header_helper()) | 787 if (io_data->policy_header_helper()) |
788 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); | 788 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); |
789 } | 789 } |
790 | 790 |
791 // Notification that a request has completed. | 791 // Notification that a request has completed. |
792 void ChromeResourceDispatcherHostDelegate::RequestComplete( | 792 void ChromeResourceDispatcherHostDelegate::RequestComplete( |
793 net::URLRequest* url_request) { | 793 net::URLRequest* url_request) { |
794 if (!url_request) | 794 if (!url_request) |
795 return; | 795 return; |
| 796 // TODO(maksims): remove this and use net_error argument in RequestComplete |
| 797 // once ResourceDispatcherHostDelegate is modified. |
| 798 int net_error = url_request->status().error(); |
796 const ResourceRequestInfo* info = | 799 const ResourceRequestInfo* info = |
797 ResourceRequestInfo::ForRequest(url_request); | 800 ResourceRequestInfo::ForRequest(url_request); |
798 BrowserThread::PostTask( | 801 BrowserThread::PostTask( |
799 BrowserThread::UI, FROM_HERE, | 802 BrowserThread::UI, FROM_HERE, |
800 base::Bind(&NotifyUIThreadOfRequestComplete, | 803 base::Bind(&NotifyUIThreadOfRequestComplete, |
801 info->GetWebContentsGetterForRequest(), url_request->url(), | 804 info->GetWebContentsGetterForRequest(), url_request->url(), |
802 info->GetResourceType(), url_request->was_cached(), | 805 info->GetResourceType(), url_request->was_cached(), net_error, |
803 url_request->status().error(), | |
804 url_request->GetTotalReceivedBytes(), | 806 url_request->GetTotalReceivedBytes(), |
805 base::TimeTicks::Now() - url_request->creation_time())); | 807 base::TimeTicks::Now() - url_request->creation_time())); |
806 } | 808 } |
807 | 809 |
808 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( | 810 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( |
809 const net::URLRequest& url_request, | 811 const net::URLRequest& url_request, |
810 content::ResourceContext* resource_context) { | 812 content::ResourceContext* resource_context) { |
811 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 813 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
812 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 814 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
813 io_data->data_reduction_proxy_io_data(); | 815 io_data->data_reduction_proxy_io_data(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 863 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
862 base::Unretained(this), url, request_loading_time)); | 864 base::Unretained(this), url, request_loading_time)); |
863 return; | 865 return; |
864 } | 866 } |
865 | 867 |
866 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 868 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
867 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 869 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
868 rappor::SampleDomainAndRegistryFromGURL( | 870 rappor::SampleDomainAndRegistryFromGURL( |
869 g_browser_process->rappor_service(), metric_name, url); | 871 g_browser_process->rappor_service(), metric_name, url); |
870 } | 872 } |
OLD | NEW |