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