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

Side by Side Diff: trunk/src/chrome/browser/net/spdyproxy/proxy_advisor.cc

Issue 307013003: Revert 273810 "Added alternative configuration for the data redu..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/net/spdyproxy/proxy_advisor.h" 5 #include "chrome/browser/net/spdyproxy/proxy_advisor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
16 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
17 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
18 #include "net/base/request_priority.h" 17 #include "net/base/request_priority.h"
19 #include "net/http/http_status_code.h" 18 #include "net/http/http_status_code.h"
20 #include "net/proxy/proxy_info.h" 19 #include "net/proxy/proxy_info.h"
21 #include "net/proxy/proxy_service.h" 20 #include "net/proxy/proxy_service.h"
22 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
23 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
24 23
25 // TODO(marq): Remove this class because it is not being used.
26
27 // Ensure data reduction features are available. 24 // Ensure data reduction features are available.
28 #if !defined(OS_ANDROID) && !defined(OS_IOS) 25 #if !defined(OS_ANDROID) && !defined(OS_IOS)
29 #error proxy_advisor should only be included in Android or iOS builds. 26 #error proxy_advisor should only be included in Android or iOS builds.
30 #endif 27 #endif
31 28
32 using content::BrowserThread; 29 using content::BrowserThread;
33 using data_reduction_proxy::DataReductionProxySettings; 30 using data_reduction_proxy::DataReductionProxySettings;
34 31
35 namespace { 32 namespace {
36 const char kOmniboxMotivation[] = "omnibox"; 33 const char kOmniboxMotivation[] = "omnibox";
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 chrome_browser_net::UrlInfo::ResolutionMotivation motivation, 112 chrome_browser_net::UrlInfo::ResolutionMotivation motivation,
116 bool is_preconnect) { 113 bool is_preconnect) {
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
118 115
119 if (!WouldProxyURL(url)) 116 if (!WouldProxyURL(url))
120 return; 117 return;
121 118
122 std::string motivation_name(MotivationName(motivation, is_preconnect)); 119 std::string motivation_name(MotivationName(motivation, is_preconnect));
123 std::string header_value = motivation_name + " " + url.spec(); 120 std::string header_value = motivation_name + " " + url.spec();
124 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); 121 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
125 data_reduction_proxy::DataReductionProxyParams params(
126 data_reduction_proxy::DataReductionProxyParams::kAllowed |
127 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed |
128 data_reduction_proxy::DataReductionProxyParams::kPromoAllowed);
129 std::string endpoint = 122 std::string endpoint =
130 params.origin().spec() + "preconnect"; 123 DataReductionProxySettings::GetDataReductionProxyOrigin() + "preconnect";
131 scoped_ptr<net::URLRequest> request = context->CreateRequest( 124 scoped_ptr<net::URLRequest> request = context->CreateRequest(
132 GURL(endpoint), net::DEFAULT_PRIORITY, this, NULL); 125 GURL(endpoint), net::DEFAULT_PRIORITY, this, NULL);
133 request->set_method("HEAD"); 126 request->set_method("HEAD");
134 request->SetExtraRequestHeaderByName( 127 request->SetExtraRequestHeaderByName(
135 "Proxy-Host-Advisory", header_value, false); 128 "Proxy-Host-Advisory", header_value, false);
136 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 129 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
137 net::LOAD_DO_NOT_SAVE_COOKIES | 130 net::LOAD_DO_NOT_SAVE_COOKIES |
138 net::LOAD_BYPASS_PROXY | 131 net::LOAD_BYPASS_PROXY |
139 net::LOAD_DISABLE_CACHE); 132 net::LOAD_DISABLE_CACHE);
140 net::URLRequest* raw_request = request.get(); 133 net::URLRequest* raw_request = request.get();
(...skipping 19 matching lines...) Expand all
160 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request); 153 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request);
161 inflight_requests_.erase(request); 154 inflight_requests_.erase(request);
162 // |scoped_request_for_deletion| will delete |request| 155 // |scoped_request_for_deletion| will delete |request|
163 } 156 }
164 157
165 void ProxyAdvisor::UpdateProxyState() { 158 void ProxyAdvisor::UpdateProxyState() {
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
167 // Delete all inflight requests. Each request's destructor will call Cancel(). 160 // Delete all inflight requests. Each request's destructor will call Cancel().
168 STLDeleteElements(&inflight_requests_); 161 STLDeleteElements(&inflight_requests_);
169 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698