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

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: rebase 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "content/public/browser/plugin_service_filter.h" 59 #include "content/public/browser/plugin_service_filter.h"
60 #include "content/public/browser/render_frame_host.h" 60 #include "content/public/browser/render_frame_host.h"
61 #include "content/public/browser/render_process_host.h" 61 #include "content/public/browser/render_process_host.h"
62 #include "content/public/browser/render_view_host.h" 62 #include "content/public/browser/render_view_host.h"
63 #include "content/public/browser/resource_context.h" 63 #include "content/public/browser/resource_context.h"
64 #include "content/public/browser/resource_dispatcher_host.h" 64 #include "content/public/browser/resource_dispatcher_host.h"
65 #include "content/public/browser/resource_request_info.h" 65 #include "content/public/browser/resource_request_info.h"
66 #include "content/public/browser/service_worker_context.h" 66 #include "content/public/browser/service_worker_context.h"
67 #include "content/public/browser/stream_info.h" 67 #include "content/public/browser/stream_info.h"
68 #include "content/public/browser/web_contents.h" 68 #include "content/public/browser/web_contents.h"
69 #include "content/public/common/previews_state.h"
69 #include "content/public/common/resource_response.h" 70 #include "content/public/common/resource_response.h"
70 #include "extensions/features/features.h" 71 #include "extensions/features/features.h"
71 #include "net/base/load_flags.h" 72 #include "net/base/load_flags.h"
72 #include "net/base/load_timing_info.h" 73 #include "net/base/load_timing_info.h"
73 #include "net/base/request_priority.h" 74 #include "net/base/request_priority.h"
74 #include "net/http/http_response_headers.h" 75 #include "net/http/http_response_headers.h"
75 #include "net/ssl/client_cert_store.h" 76 #include "net/ssl/client_cert_store.h"
76 #include "net/url_request/url_request.h" 77 #include "net/url_request/url_request.h"
77 78
78 #if !defined(DISABLE_NACL) 79 #if !defined(DISABLE_NACL)
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 ResourceRequestInfo::ForRequest(url_request); 822 ResourceRequestInfo::ForRequest(url_request);
822 BrowserThread::PostTask( 823 BrowserThread::PostTask(
823 BrowserThread::UI, FROM_HERE, 824 BrowserThread::UI, FROM_HERE,
824 base::Bind(&NotifyUIThreadOfRequestComplete, 825 base::Bind(&NotifyUIThreadOfRequestComplete,
825 info->GetWebContentsGetterForRequest(), url_request->url(), 826 info->GetWebContentsGetterForRequest(), url_request->url(),
826 info->GetResourceType(), url_request->was_cached(), net_error, 827 info->GetResourceType(), url_request->was_cached(), net_error,
827 url_request->GetTotalReceivedBytes(), 828 url_request->GetTotalReceivedBytes(),
828 base::TimeTicks::Now() - url_request->creation_time())); 829 base::TimeTicks::Now() - url_request->creation_time()));
829 } 830 }
830 831
831 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( 832 int ChromeResourceDispatcherHostDelegate::GetPreviewsState(
832 const net::URLRequest& url_request, 833 const net::URLRequest& url_request,
833 content::ResourceContext* resource_context) { 834 content::ResourceContext* resource_context) {
834 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 835 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
835 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 836 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
836 io_data->data_reduction_proxy_io_data(); 837 io_data->data_reduction_proxy_io_data();
837 838
838 if (data_reduction_proxy_io_data) 839 if (data_reduction_proxy_io_data) {
839 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request); 840 return data_reduction_proxy_io_data->ShouldEnableLoFiMode(url_request)
840 return false; 841 ? content::SERVER_LOFI_ON
842 : content::PREVIEWS_OFF;
843 }
844 return content::PREVIEWS_OFF;
841 } 845 }
842 846
843 // static 847 // static
844 void ChromeResourceDispatcherHostDelegate:: 848 void ChromeResourceDispatcherHostDelegate::
845 SetExternalProtocolHandlerDelegateForTesting( 849 SetExternalProtocolHandlerDelegateForTesting(
846 ExternalProtocolHandler::Delegate* delegate) { 850 ExternalProtocolHandler::Delegate* delegate) {
847 g_external_protocol_handler_delegate = delegate; 851 g_external_protocol_handler_delegate = delegate;
848 } 852 }
849 853
850 content::NavigationData* 854 content::NavigationData*
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 888 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
885 base::Unretained(this), url, request_loading_time)); 889 base::Unretained(this), url, request_loading_time));
886 return; 890 return;
887 } 891 }
888 892
889 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 893 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
890 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 894 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
891 rappor::SampleDomainAndRegistryFromGURL( 895 rappor::SampleDomainAndRegistryFromGURL(
892 g_browser_process->rappor_service(), metric_name, url); 896 g_browser_process->rappor_service(), metric_name, url);
893 } 897 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698