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 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( |
| 832 int previews_state, | |
| 831 const net::URLRequest& url_request, | 833 const net::URLRequest& url_request, |
| 832 content::ResourceContext* resource_context) { | 834 content::ResourceContext* resource_context) { |
| 833 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 835 if (previews_state & content::PREVIEWS_UNSPECIFIED) { |
|
RyanSturm
2016/12/03 00:28:11
Can you add a comment that previews_state is conte
megjablon
2016/12/06 00:59:18
Added the comment to resource_dispatcher_host_impl
| |
| 834 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 836 ProfileIOData* io_data = |
| 835 io_data->data_reduction_proxy_io_data(); | 837 ProfileIOData::FromResourceContext(resource_context); |
| 838 data_reduction_proxy::DataReductionProxyIOData* | |
| 839 data_reduction_proxy_io_data = io_data->data_reduction_proxy_io_data(); | |
| 836 | 840 |
| 837 if (data_reduction_proxy_io_data) | 841 if (data_reduction_proxy_io_data) |
| 838 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); | 842 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request) |
| 839 return false; | 843 ? content::SERVER_LOFI_ON |
| 844 : content::PREVIEWS_OFF; | |
| 845 return content::PREVIEWS_OFF; | |
| 846 } | |
| 847 return previews_state; | |
| 840 } | 848 } |
| 841 | 849 |
| 842 // static | 850 // static |
| 843 void ChromeResourceDispatcherHostDelegate:: | 851 void ChromeResourceDispatcherHostDelegate:: |
| 844 SetExternalProtocolHandlerDelegateForTesting( | 852 SetExternalProtocolHandlerDelegateForTesting( |
| 845 ExternalProtocolHandler::Delegate* delegate) { | 853 ExternalProtocolHandler::Delegate* delegate) { |
| 846 g_external_protocol_handler_delegate = delegate; | 854 g_external_protocol_handler_delegate = delegate; |
| 847 } | 855 } |
| 848 | 856 |
| 849 content::NavigationData* | 857 content::NavigationData* |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 891 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 884 base::Unretained(this), url, request_loading_time)); | 892 base::Unretained(this), url, request_loading_time)); |
| 885 return; | 893 return; |
| 886 } | 894 } |
| 887 | 895 |
| 888 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 896 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 889 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 897 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 890 rappor::SampleDomainAndRegistryFromGURL( | 898 rappor::SampleDomainAndRegistryFromGURL( |
| 891 g_browser_process->rappor_service(), metric_name, url); | 899 g_browser_process->rappor_service(), metric_name, url); |
| 892 } | 900 } |
| OLD | NEW |