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

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

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: use PreviewsState everywhere Created 4 years 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 ResourceRequestInfo::ForRequest(url_request); 821 ResourceRequestInfo::ForRequest(url_request);
822 BrowserThread::PostTask( 822 BrowserThread::PostTask(
823 BrowserThread::UI, FROM_HERE, 823 BrowserThread::UI, FROM_HERE,
824 base::Bind(&NotifyUIThreadOfRequestComplete, 824 base::Bind(&NotifyUIThreadOfRequestComplete,
825 info->GetWebContentsGetterForRequest(), url_request->url(), 825 info->GetWebContentsGetterForRequest(), url_request->url(),
826 info->GetResourceType(), url_request->was_cached(), net_error, 826 info->GetResourceType(), url_request->was_cached(), net_error,
827 url_request->GetTotalReceivedBytes(), 827 url_request->GetTotalReceivedBytes(),
828 base::TimeTicks::Now() - url_request->creation_time())); 828 base::TimeTicks::Now() - url_request->creation_time()));
829 } 829 }
830 830
831 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( 831 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState(
832 const net::URLRequest& url_request, 832 const net::URLRequest& url_request,
833 content::ResourceContext* resource_context) { 833 content::ResourceContext* resource_context) {
834 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 834 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
835 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 835 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
836 io_data->data_reduction_proxy_io_data(); 836 io_data->data_reduction_proxy_io_data();
837 837
838 if (data_reduction_proxy_io_data) 838 if (data_reduction_proxy_io_data) {
839 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); 839 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request)
840 return false; 840 ? content::SERVER_LOFI_ON
841 : content::PREVIEWS_OFF;
842 }
843 return content::PREVIEWS_OFF;
841 } 844 }
842 845
843 // static 846 // static
844 void ChromeResourceDispatcherHostDelegate:: 847 void ChromeResourceDispatcherHostDelegate::
845 SetExternalProtocolHandlerDelegateForTesting( 848 SetExternalProtocolHandlerDelegateForTesting(
846 ExternalProtocolHandler::Delegate* delegate) { 849 ExternalProtocolHandler::Delegate* delegate) {
847 g_external_protocol_handler_delegate = delegate; 850 g_external_protocol_handler_delegate = delegate;
848 } 851 }
849 852
850 content::NavigationData* 853 content::NavigationData*
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 887 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
885 base::Unretained(this), url, request_loading_time)); 888 base::Unretained(this), url, request_loading_time));
886 return; 889 return;
887 } 890 }
888 891
889 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 892 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
890 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 893 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
891 rappor::SampleDomainAndRegistryFromGURL( 894 rappor::SampleDomainAndRegistryFromGURL(
892 g_browser_process->rappor_service(), metric_name, url); 895 g_browser_process->rappor_service(), metric_name, url);
893 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698