| 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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 | 884 |
| 885 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( | 885 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
| 886 const net::URLRequest& url_request, | 886 const net::URLRequest& url_request, |
| 887 content::ResourceContext* resource_context) { | 887 content::ResourceContext* resource_context) { |
| 888 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 888 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 889 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 889 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
| 890 io_data->data_reduction_proxy_io_data(); | 890 io_data->data_reduction_proxy_io_data(); |
| 891 | 891 |
| 892 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; | 892 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; |
| 893 | 893 |
| 894 if (data_reduction_proxy_io_data) { | 894 previews::PreviewsIOData* previews_io_data = io_data->previews_io_data(); |
| 895 if (data_reduction_proxy_io_data->ShouldEnableLoFi(url_request)) | 895 if (data_reduction_proxy_io_data && previews_io_data) { |
| 896 if (data_reduction_proxy_io_data->ShouldEnableLoFi(url_request, |
| 897 previews_io_data)) { |
| 896 previews_state |= content::SERVER_LOFI_ON; | 898 previews_state |= content::SERVER_LOFI_ON; |
| 897 if (data_reduction_proxy_io_data->ShouldEnableLitePages(url_request)) | 899 } |
| 900 if (data_reduction_proxy_io_data->ShouldEnableLitePages(url_request, |
| 901 previews_io_data)) { |
| 898 previews_state |= content::SERVER_LITE_PAGE_ON; | 902 previews_state |= content::SERVER_LITE_PAGE_ON; |
| 903 } |
| 899 | 904 |
| 900 previews::PreviewsIOData* previews_io_data = io_data->previews_io_data(); | |
| 901 // Check that data saver is enabled, the user isn't opted out of LoFi for | 905 // Check that data saver is enabled, the user isn't opted out of LoFi for |
| 902 // the session, and the user is eligible for previews. | 906 // the session, and the user is eligible for previews. |
| 903 if (data_reduction_proxy_io_data->IsEnabled() && | 907 if (data_reduction_proxy_io_data->IsEnabled() && |
| 904 !data_reduction_proxy_io_data->config()->lofi_off() && | 908 !data_reduction_proxy_io_data->config()->lofi_off() && |
| 905 previews_io_data && previews::params::IsClientLoFiEnabled() && | 909 previews::params::IsClientLoFiEnabled() && |
| 906 previews_io_data->ShouldAllowPreviewAtECT( | 910 previews_io_data->ShouldAllowPreviewAtECT( |
| 907 url_request, previews::PreviewsType::LOFI, | 911 url_request, previews::PreviewsType::LOFI, |
| 908 previews::params:: | 912 previews::params:: |
| 909 EffectiveConnectionTypeThresholdForClientLoFi())) { | 913 EffectiveConnectionTypeThresholdForClientLoFi())) { |
| 910 previews_state |= content::CLIENT_LOFI_ON; | 914 previews_state |= content::CLIENT_LOFI_ON; |
| 911 } | 915 } |
| 912 } | 916 } |
| 913 | 917 |
| 914 if (previews_state == content::PREVIEWS_UNSPECIFIED) | 918 if (previews_state == content::PREVIEWS_UNSPECIFIED) |
| 915 return content::PREVIEWS_OFF; | 919 return content::PREVIEWS_OFF; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 965 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 962 base::Unretained(this), url, request_loading_time)); | 966 base::Unretained(this), url, request_loading_time)); |
| 963 return; | 967 return; |
| 964 } | 968 } |
| 965 | 969 |
| 966 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 970 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 967 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 971 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 968 rappor::SampleDomainAndRegistryFromGURL( | 972 rappor::SampleDomainAndRegistryFromGURL( |
| 969 g_browser_process->rappor_service(), metric_name, url); | 973 g_browser_process->rappor_service(), metric_name, url); |
| 970 } | 974 } |
| OLD | NEW |