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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (data_reduction_proxy_io_data) { |
895 if (data_reduction_proxy_io_data->ShouldEnableLoFi(url_request)) | 895 previews::PreviewsIOData* previews_io_data = io_data->previews_io_data(); |
megjablon
2017/05/10 19:11:23
Should there be a null check here? Can we move thi
RyanSturm
2017/05/10 19:57:02
Done.
| |
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 if (data_reduction_proxy_io_data->ShouldEnableLitePages(url_request, |
900 previews_io_data)) | |
898 previews_state |= content::SERVER_LITE_PAGE_ON; | 901 previews_state |= content::SERVER_LITE_PAGE_ON; |
899 | 902 |
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 | 903 // 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. | 904 // the session, and the user is eligible for previews. |
903 if (data_reduction_proxy_io_data->IsEnabled() && | 905 if (data_reduction_proxy_io_data->IsEnabled() && |
904 !data_reduction_proxy_io_data->config()->lofi_off() && | 906 !data_reduction_proxy_io_data->config()->lofi_off() && |
905 previews_io_data && previews::params::IsClientLoFiEnabled() && | 907 previews_io_data && previews::params::IsClientLoFiEnabled() && |
906 previews_io_data->ShouldAllowPreviewAtECT( | 908 previews_io_data->ShouldAllowPreviewAtECT( |
907 url_request, previews::PreviewsType::LOFI, | 909 url_request, previews::PreviewsType::LOFI, |
908 previews::params:: | 910 previews::params:: |
909 EffectiveConnectionTypeThresholdForClientLoFi())) { | 911 EffectiveConnectionTypeThresholdForClientLoFi())) { |
910 previews_state |= content::CLIENT_LOFI_ON; | 912 previews_state |= content::CLIENT_LOFI_ON; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 963 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
962 base::Unretained(this), url, request_loading_time)); | 964 base::Unretained(this), url, request_loading_time)); |
963 return; | 965 return; |
964 } | 966 } |
965 | 967 |
966 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 968 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
967 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 969 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
968 rappor::SampleDomainAndRegistryFromGURL( | 970 rappor::SampleDomainAndRegistryFromGURL( |
969 g_browser_process->rappor_service(), metric_name, url); | 971 g_browser_process->rappor_service(), metric_name, url); |
970 } | 972 } |
OLD | NEW |