OLD | NEW |
---|---|
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" | |
14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" | 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
17 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
19 #include "net/proxy/proxy_info.h" | 20 #include "net/proxy/proxy_info.h" |
20 #include "net/proxy/proxy_service.h" | 21 #include "net/proxy/proxy_service.h" |
21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
23 | 24 |
25 // TODO(marq): Remove this class because it is not being used. | |
mmenke
2014/05/21 16:00:20
Which class?
bengr
2014/05/28 01:25:32
This ProxyAdvisor class.
| |
26 | |
24 // Ensure data reduction features are available. | 27 // Ensure data reduction features are available. |
25 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 28 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
26 #error proxy_advisor should only be included in Android or iOS builds. | 29 #error proxy_advisor should only be included in Android or iOS builds. |
27 #endif | 30 #endif |
28 | 31 |
29 using content::BrowserThread; | 32 using content::BrowserThread; |
30 using data_reduction_proxy::DataReductionProxySettings; | 33 using data_reduction_proxy::DataReductionProxySettings; |
31 | 34 |
32 namespace { | 35 namespace { |
33 const char kOmniboxMotivation[] = "omnibox"; | 36 const char kOmniboxMotivation[] = "omnibox"; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 chrome_browser_net::UrlInfo::ResolutionMotivation motivation, | 115 chrome_browser_net::UrlInfo::ResolutionMotivation motivation, |
113 bool is_preconnect) { | 116 bool is_preconnect) { |
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
115 | 118 |
116 if (!WouldProxyURL(url)) | 119 if (!WouldProxyURL(url)) |
117 return; | 120 return; |
118 | 121 |
119 std::string motivation_name(MotivationName(motivation, is_preconnect)); | 122 std::string motivation_name(MotivationName(motivation, is_preconnect)); |
120 std::string header_value = motivation_name + " " + url.spec(); | 123 std::string header_value = motivation_name + " " + url.spec(); |
121 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 124 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
125 data_reduction_proxy::DataReductionProxyParams params( | |
126 true, true, false, true); | |
mmenke
2014/05/21 16:00:20
Suggest either enums instead of bools, or adding c
sgurun-gerrit only
2014/05/21 16:21:29
I like the idea of using enums. It will be a lot m
bengr
2014/05/28 01:25:32
Done.
| |
122 std::string endpoint = | 127 std::string endpoint = |
123 DataReductionProxySettings::GetDataReductionProxyOrigin() + "preconnect"; | 128 params.origin().spec() + "preconnect"; |
124 scoped_ptr<net::URLRequest> request = context->CreateRequest( | 129 scoped_ptr<net::URLRequest> request = context->CreateRequest( |
125 GURL(endpoint), net::DEFAULT_PRIORITY, this, NULL); | 130 GURL(endpoint), net::DEFAULT_PRIORITY, this, NULL); |
126 request->set_method("HEAD"); | 131 request->set_method("HEAD"); |
127 request->SetExtraRequestHeaderByName( | 132 request->SetExtraRequestHeaderByName( |
128 "Proxy-Host-Advisory", header_value, false); | 133 "Proxy-Host-Advisory", header_value, false); |
129 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 134 request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
130 net::LOAD_DO_NOT_SAVE_COOKIES | | 135 net::LOAD_DO_NOT_SAVE_COOKIES | |
131 net::LOAD_BYPASS_PROXY | | 136 net::LOAD_BYPASS_PROXY | |
132 net::LOAD_DISABLE_CACHE); | 137 net::LOAD_DISABLE_CACHE); |
133 net::URLRequest* raw_request = request.get(); | 138 net::URLRequest* raw_request = request.get(); |
(...skipping 19 matching lines...) Expand all Loading... | |
153 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request); | 158 scoped_ptr<net::URLRequest> scoped_request_for_deletion(request); |
154 inflight_requests_.erase(request); | 159 inflight_requests_.erase(request); |
155 // |scoped_request_for_deletion| will delete |request| | 160 // |scoped_request_for_deletion| will delete |request| |
156 } | 161 } |
157 | 162 |
158 void ProxyAdvisor::UpdateProxyState() { | 163 void ProxyAdvisor::UpdateProxyState() { |
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
160 // Delete all inflight requests. Each request's destructor will call Cancel(). | 165 // Delete all inflight requests. Each request's destructor will call Cancel(). |
161 STLDeleteElements(&inflight_requests_); | 166 STLDeleteElements(&inflight_requests_); |
162 } | 167 } |
OLD | NEW |