Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2059)

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2642793005: Create a Lite Page bit for previews and fallback to Lo-Fi (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (data_reduction_proxy_io_data) { 866 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED;
bengr 2017/02/15 00:03:47 Why do you need separate values for UNSPECIFIED an
megjablon 2017/02/16 04:29:09 For requesting the original page with previews off
867 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request) 867
868 ? content::SERVER_LOFI_ON 868 if (data_reduction_proxy_io_data &&
bengr 2017/02/15 00:03:47 Style nit: if (drp_io_data) { if (drp_io_data->
megjablon 2017/02/16 04:29:09 Done.
869 : content::PREVIEWS_OFF; 869 data_reduction_proxy_io_data->ShouldEnableLoFi(url_request)) {
870 previews_state |= content::SERVER_LOFI_ON;
870 } 871 }
871 return content::PREVIEWS_OFF; 872
873 if (data_reduction_proxy_io_data &&
874 data_reduction_proxy_io_data->ShouldEnableLitePages(url_request)) {
875 previews_state |= content::SERVER_LITE_PAGE_ON;
876 }
877
878 if (previews_state == content::PREVIEWS_UNSPECIFIED)
879 return content::PREVIEWS_OFF;
880 return previews_state;
872 } 881 }
873 882
874 // static 883 // static
875 void ChromeResourceDispatcherHostDelegate:: 884 void ChromeResourceDispatcherHostDelegate::
876 SetExternalProtocolHandlerDelegateForTesting( 885 SetExternalProtocolHandlerDelegateForTesting(
877 ExternalProtocolHandler::Delegate* delegate) { 886 ExternalProtocolHandler::Delegate* delegate) {
878 g_external_protocol_handler_delegate = delegate; 887 g_external_protocol_handler_delegate = delegate;
879 } 888 }
880 889
881 content::NavigationData* 890 content::NavigationData*
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 924 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
916 base::Unretained(this), url, request_loading_time)); 925 base::Unretained(this), url, request_loading_time));
917 return; 926 return;
918 } 927 }
919 928
920 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 929 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
921 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 930 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
922 rappor::SampleDomainAndRegistryFromGURL( 931 rappor::SampleDomainAndRegistryFromGURL(
923 g_browser_process->rappor_service(), metric_name, url); 932 g_browser_process->rappor_service(), metric_name, url);
924 } 933 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698