| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "content/public/browser/plugin_service_filter.h" | 58 #include "content/public/browser/plugin_service_filter.h" |
| 59 #include "content/public/browser/render_frame_host.h" | 59 #include "content/public/browser/render_frame_host.h" |
| 60 #include "content/public/browser/render_process_host.h" | 60 #include "content/public/browser/render_process_host.h" |
| 61 #include "content/public/browser/render_view_host.h" | 61 #include "content/public/browser/render_view_host.h" |
| 62 #include "content/public/browser/resource_context.h" | 62 #include "content/public/browser/resource_context.h" |
| 63 #include "content/public/browser/resource_dispatcher_host.h" | 63 #include "content/public/browser/resource_dispatcher_host.h" |
| 64 #include "content/public/browser/resource_request_info.h" | 64 #include "content/public/browser/resource_request_info.h" |
| 65 #include "content/public/browser/service_worker_context.h" | 65 #include "content/public/browser/service_worker_context.h" |
| 66 #include "content/public/browser/stream_info.h" | 66 #include "content/public/browser/stream_info.h" |
| 67 #include "content/public/browser/web_contents.h" | 67 #include "content/public/browser/web_contents.h" |
| 68 #include "content/public/common/previews_state.h" |
| 68 #include "content/public/common/resource_response.h" | 69 #include "content/public/common/resource_response.h" |
| 69 #include "extensions/features/features.h" | 70 #include "extensions/features/features.h" |
| 70 #include "net/base/load_flags.h" | 71 #include "net/base/load_flags.h" |
| 71 #include "net/base/load_timing_info.h" | 72 #include "net/base/load_timing_info.h" |
| 72 #include "net/base/request_priority.h" | 73 #include "net/base/request_priority.h" |
| 73 #include "net/http/http_response_headers.h" | 74 #include "net/http/http_response_headers.h" |
| 74 #include "net/ssl/client_cert_store.h" | 75 #include "net/ssl/client_cert_store.h" |
| 75 #include "net/url_request/url_request.h" | 76 #include "net/url_request/url_request.h" |
| 76 | 77 |
| 77 #if !defined(DISABLE_NACL) | 78 #if !defined(DISABLE_NACL) |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 ResourceRequestInfo::ForRequest(url_request); | 821 ResourceRequestInfo::ForRequest(url_request); |
| 821 BrowserThread::PostTask( | 822 BrowserThread::PostTask( |
| 822 BrowserThread::UI, FROM_HERE, | 823 BrowserThread::UI, FROM_HERE, |
| 823 base::Bind(&NotifyUIThreadOfRequestComplete, | 824 base::Bind(&NotifyUIThreadOfRequestComplete, |
| 824 info->GetWebContentsGetterForRequest(), url_request->url(), | 825 info->GetWebContentsGetterForRequest(), url_request->url(), |
| 825 info->GetResourceType(), url_request->was_cached(), net_error, | 826 info->GetResourceType(), url_request->was_cached(), net_error, |
| 826 url_request->GetTotalReceivedBytes(), | 827 url_request->GetTotalReceivedBytes(), |
| 827 base::TimeTicks::Now() - url_request->creation_time())); | 828 base::TimeTicks::Now() - url_request->creation_time())); |
| 828 } | 829 } |
| 829 | 830 |
| 830 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( | 831 int ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
| 831 const net::URLRequest& url_request, | 832 const net::URLRequest& url_request, |
| 832 content::ResourceContext* resource_context) { | 833 content::ResourceContext* resource_context) { |
| 833 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 834 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 834 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 835 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
| 835 io_data->data_reduction_proxy_io_data(); | 836 io_data->data_reduction_proxy_io_data(); |
| 836 | 837 |
| 837 if (data_reduction_proxy_io_data) | 838 if (data_reduction_proxy_io_data) { |
| 838 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 839 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request) |
| 839 return false; | 840 ? content::SERVER_LOFI_ON |
| 841 : content::PREVIEWS_OFF; |
| 842 } |
| 843 return content::PREVIEWS_OFF; |
| 840 } | 844 } |
| 841 | 845 |
| 842 // static | 846 // static |
| 843 void ChromeResourceDispatcherHostDelegate:: | 847 void ChromeResourceDispatcherHostDelegate:: |
| 844 SetExternalProtocolHandlerDelegateForTesting( | 848 SetExternalProtocolHandlerDelegateForTesting( |
| 845 ExternalProtocolHandler::Delegate* delegate) { | 849 ExternalProtocolHandler::Delegate* delegate) { |
| 846 g_external_protocol_handler_delegate = delegate; | 850 g_external_protocol_handler_delegate = delegate; |
| 847 } | 851 } |
| 848 | 852 |
| 849 content::NavigationData* | 853 content::NavigationData* |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 887 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 884 base::Unretained(this), url, request_loading_time)); | 888 base::Unretained(this), url, request_loading_time)); |
| 885 return; | 889 return; |
| 886 } | 890 } |
| 887 | 891 |
| 888 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 892 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 889 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 893 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 890 rappor::SampleDomainAndRegistryFromGURL( | 894 rappor::SampleDomainAndRegistryFromGURL( |
| 891 g_browser_process->rappor_service(), metric_name, url); | 895 g_browser_process->rappor_service(), metric_name, url); |
| 892 } | 896 } |
| OLD | NEW |