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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 base::TimeTicks::Now() - url_request->creation_time())); | 856 base::TimeTicks::Now() - url_request->creation_time())); |
857 } | 857 } |
858 | 858 |
859 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( | 859 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
860 const net::URLRequest& url_request, | 860 const net::URLRequest& url_request, |
861 content::ResourceContext* resource_context) { | 861 content::ResourceContext* resource_context) { |
862 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 862 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
863 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 863 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
864 io_data->data_reduction_proxy_io_data(); | 864 io_data->data_reduction_proxy_io_data(); |
865 | 865 |
| 866 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; |
| 867 |
866 if (data_reduction_proxy_io_data) { | 868 if (data_reduction_proxy_io_data) { |
867 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request) | 869 if (data_reduction_proxy_io_data->ShouldEnableLoFi(url_request)) |
868 ? content::SERVER_LOFI_ON | 870 previews_state |= content::SERVER_LOFI_ON; |
869 : content::PREVIEWS_OFF; | 871 if (data_reduction_proxy_io_data->ShouldEnableLitePages(url_request)) |
| 872 previews_state |= content::SERVER_LITE_PAGE_ON; |
870 } | 873 } |
871 return content::PREVIEWS_OFF; | 874 |
| 875 if (previews_state == content::PREVIEWS_UNSPECIFIED) |
| 876 return content::PREVIEWS_OFF; |
| 877 return previews_state; |
872 } | 878 } |
873 | 879 |
874 // static | 880 // static |
875 void ChromeResourceDispatcherHostDelegate:: | 881 void ChromeResourceDispatcherHostDelegate:: |
876 SetExternalProtocolHandlerDelegateForTesting( | 882 SetExternalProtocolHandlerDelegateForTesting( |
877 ExternalProtocolHandler::Delegate* delegate) { | 883 ExternalProtocolHandler::Delegate* delegate) { |
878 g_external_protocol_handler_delegate = delegate; | 884 g_external_protocol_handler_delegate = delegate; |
879 } | 885 } |
880 | 886 |
881 content::NavigationData* | 887 content::NavigationData* |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 921 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
916 base::Unretained(this), url, request_loading_time)); | 922 base::Unretained(this), url, request_loading_time)); |
917 return; | 923 return; |
918 } | 924 } |
919 | 925 |
920 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 926 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
921 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 927 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
922 rappor::SampleDomainAndRegistryFromGURL( | 928 rappor::SampleDomainAndRegistryFromGURL( |
923 g_browser_process->rappor_service(), metric_name, url); | 929 g_browser_process->rappor_service(), metric_name, url); |
924 } | 930 } |
OLD | NEW |