OLD | NEW |
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 "android_webview/browser/net/aw_url_request_context_getter.h" | 5 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_content_browser_client.h" | 10 #include "android_webview/browser/aw_content_browser_client.h" |
11 #include "android_webview/browser/aw_request_interceptor.h" | 11 #include "android_webview/browser/aw_request_interceptor.h" |
12 #include "android_webview/browser/net/aw_network_delegate.h" | 12 #include "android_webview/browser/net/aw_network_delegate.h" |
13 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
14 #include "android_webview/browser/net/init_native_callback.h" | 14 #include "android_webview/browser/net/init_native_callback.h" |
15 #include "android_webview/common/aw_content_client.h" | 15 #include "android_webview/common/aw_content_client.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/threading/worker_pool.h" | 19 #include "base/threading/worker_pool.h" |
20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | 20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
21 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se
rvice.h" | 21 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se
rvice.h" |
22 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 22 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
25 #include "content/public/browser/cookie_store_factory.h" | 25 #include "content/public/browser/cookie_store_factory.h" |
26 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
29 #include "net/base/cache_type.h" | 29 #include "net/base/cache_type.h" |
| 30 #include "net/base/net_log.h" |
30 #include "net/cookies/cookie_store.h" | 31 #include "net/cookies/cookie_store.h" |
31 #include "net/dns/mapped_host_resolver.h" | 32 #include "net/dns/mapped_host_resolver.h" |
32 #include "net/http/http_cache.h" | 33 #include "net/http/http_cache.h" |
33 #include "net/http/http_stream_factory.h" | 34 #include "net/http/http_stream_factory.h" |
34 #include "net/proxy/proxy_service.h" | 35 #include "net/proxy/proxy_service.h" |
35 #include "net/socket/next_proto.h" | 36 #include "net/socket/next_proto.h" |
36 #include "net/ssl/default_channel_id_store.h" | 37 #include "net/ssl/default_channel_id_store.h" |
37 #include "net/url_request/data_protocol_handler.h" | 38 #include "net/url_request/data_protocol_handler.h" |
38 #include "net/url_request/file_protocol_handler.h" | 39 #include "net/url_request/file_protocol_handler.h" |
39 #include "net/url_request/url_request_context_builder.h" | 40 #include "net/url_request/url_request_context_builder.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return job_factory.Pass(); | 169 return job_factory.Pass(); |
169 } | 170 } |
170 | 171 |
171 } // namespace | 172 } // namespace |
172 | 173 |
173 AwURLRequestContextGetter::AwURLRequestContextGetter( | 174 AwURLRequestContextGetter::AwURLRequestContextGetter( |
174 const base::FilePath& partition_path, net::CookieStore* cookie_store, | 175 const base::FilePath& partition_path, net::CookieStore* cookie_store, |
175 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService> | 176 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService> |
176 config_service) | 177 config_service) |
177 : partition_path_(partition_path), | 178 : partition_path_(partition_path), |
178 cookie_store_(cookie_store) { | 179 cookie_store_(cookie_store), |
| 180 net_log_(new net::NetLog()) { |
179 data_reduction_proxy_config_service_ = config_service.Pass(); | 181 data_reduction_proxy_config_service_ = config_service.Pass(); |
180 // CreateSystemProxyConfigService for Android must be called on main thread. | 182 // CreateSystemProxyConfigService for Android must be called on main thread. |
181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
182 } | 184 } |
183 | 185 |
184 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 186 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
185 } | 187 } |
186 | 188 |
187 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 189 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
189 DCHECK(!url_request_context_); | 191 DCHECK(!url_request_context_); |
190 | 192 |
191 net::URLRequestContextBuilder builder; | 193 net::URLRequestContextBuilder builder; |
192 builder.set_user_agent(GetUserAgent()); | 194 builder.set_user_agent(GetUserAgent()); |
193 AwNetworkDelegate* aw_network_delegate = new AwNetworkDelegate(); | 195 AwNetworkDelegate* aw_network_delegate = new AwNetworkDelegate(); |
194 builder.set_network_delegate(aw_network_delegate); | 196 builder.set_network_delegate(aw_network_delegate); |
195 #if !defined(DISABLE_FTP_SUPPORT) | 197 #if !defined(DISABLE_FTP_SUPPORT) |
196 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 198 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
197 #endif | 199 #endif |
198 if (data_reduction_proxy_config_service_.get()) { | 200 if (data_reduction_proxy_config_service_.get()) { |
199 builder.set_proxy_config_service( | 201 builder.set_proxy_config_service( |
200 data_reduction_proxy_config_service_.release()); | 202 data_reduction_proxy_config_service_.release()); |
201 } else { | 203 } else { |
202 builder.set_proxy_config_service( | 204 builder.set_proxy_config_service( |
203 net::ProxyService::CreateSystemProxyConfigService( | 205 net::ProxyService::CreateSystemProxyConfigService( |
204 GetNetworkTaskRunner(), NULL /* Ignored on Android */ )); | 206 GetNetworkTaskRunner(), NULL /* Ignored on Android */ )); |
205 } | 207 } |
206 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( | 208 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( |
207 AwContentBrowserClient::GetAcceptLangsImpl())); | 209 AwContentBrowserClient::GetAcceptLangsImpl())); |
| 210 builder.set_net_log(net_log_.get()); |
208 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 211 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
209 | 212 |
210 url_request_context_.reset(builder.Build()); | 213 url_request_context_.reset(builder.Build()); |
211 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 214 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
212 net::HttpNetworkSession::Params network_session_params; | 215 net::HttpNetworkSession::Params network_session_params; |
213 | 216 |
214 PopulateNetworkSessionParams(url_request_context_.get(), | 217 PopulateNetworkSessionParams(url_request_context_.get(), |
215 &network_session_params); | 218 &network_session_params); |
216 | 219 |
217 net::HttpCache* main_cache = new net::HttpCache( | 220 net::HttpCache* main_cache = new net::HttpCache( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 content::URLRequestInterceptorScopedVector request_interceptors) { | 272 content::URLRequestInterceptorScopedVector request_interceptors) { |
270 std::swap(protocol_handlers_, *protocol_handlers); | 273 std::swap(protocol_handlers_, *protocol_handlers); |
271 request_interceptors_.swap(request_interceptors); | 274 request_interceptors_.swap(request_interceptors); |
272 } | 275 } |
273 | 276 |
274 data_reduction_proxy::DataReductionProxyAuthRequestHandler* | 277 data_reduction_proxy::DataReductionProxyAuthRequestHandler* |
275 AwURLRequestContextGetter::GetDataReductionProxyAuthRequestHandler() const { | 278 AwURLRequestContextGetter::GetDataReductionProxyAuthRequestHandler() const { |
276 return data_reduction_proxy_auth_request_handler_.get(); | 279 return data_reduction_proxy_auth_request_handler_.get(); |
277 } | 280 } |
278 | 281 |
| 282 net::NetLog* AwURLRequestContextGetter::GetNetLog() { |
| 283 return net_log_.get(); |
| 284 } |
| 285 |
279 } // namespace android_webview | 286 } // namespace android_webview |
OLD | NEW |