| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 *base::CommandLine::ForCurrentProcess(); | 57 *base::CommandLine::ForCurrentProcess(); |
| 58 if (command_line.HasSwitch(switches::kHostResolverRules)) { | 58 if (command_line.HasSwitch(switches::kHostResolverRules)) { |
| 59 // If hostname remappings were specified on the command-line, layer these | 59 // If hostname remappings were specified on the command-line, layer these |
| 60 // rules on top of the real host resolver. This allows forwarding all | 60 // rules on top of the real host resolver. This allows forwarding all |
| 61 // requests through a designated test server. | 61 // requests through a designated test server. |
| 62 scoped_ptr<net::MappedHostResolver> host_resolver( | 62 scoped_ptr<net::MappedHostResolver> host_resolver( |
| 63 new net::MappedHostResolver( | 63 new net::MappedHostResolver( |
| 64 net::HostResolver::CreateDefaultResolver(NULL))); | 64 net::HostResolver::CreateDefaultResolver(NULL))); |
| 65 host_resolver->SetRulesFromString( | 65 host_resolver->SetRulesFromString( |
| 66 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); | 66 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
| 67 builder->set_host_resolver(host_resolver.release()); | 67 builder->set_host_resolver(host_resolver.Pass()); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void ApplyCmdlineOverridesToNetworkSessionParams( | 71 void ApplyCmdlineOverridesToNetworkSessionParams( |
| 72 net::HttpNetworkSession::Params* params) { | 72 net::HttpNetworkSession::Params* params) { |
| 73 int value; | 73 int value; |
| 74 const base::CommandLine& command_line = | 74 const base::CommandLine& command_line = |
| 75 *base::CommandLine::ForCurrentProcess(); | 75 *base::CommandLine::ForCurrentProcess(); |
| 76 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 76 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
| 77 base::StringToInt(command_line.GetSwitchValueASCII( | 77 base::StringToInt(command_line.GetSwitchValueASCII( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 199 DCHECK(!url_request_context_); | 199 DCHECK(!url_request_context_); |
| 200 | 200 |
| 201 net::URLRequestContextBuilder builder; | 201 net::URLRequestContextBuilder builder; |
| 202 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); | 202 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); |
| 203 | 203 |
| 204 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 204 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 205 DCHECK(browser_context); | 205 DCHECK(browser_context); |
| 206 | 206 |
| 207 builder.set_network_delegate( | 207 builder.set_network_delegate( |
| 208 browser_context->GetDataReductionProxyIOData()->CreateNetworkDelegate( | 208 browser_context->GetDataReductionProxyIOData() |
| 209 aw_network_delegate.Pass(), | 209 ->CreateNetworkDelegate( |
| 210 false /* No UMA is produced to track bypasses. */ ).release()); | 210 aw_network_delegate.Pass(), |
| 211 false /* No UMA is produced to track bypasses. */) |
| 212 .Pass()); |
| 211 #if !defined(DISABLE_FTP_SUPPORT) | 213 #if !defined(DISABLE_FTP_SUPPORT) |
| 212 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 214 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 213 #endif | 215 #endif |
| 214 DCHECK(proxy_config_service_.get()); | 216 DCHECK(proxy_config_service_.get()); |
| 215 // Android provides a local HTTP proxy that handles all the proxying. | 217 // Android provides a local HTTP proxy that handles all the proxying. |
| 216 // Create the proxy without a resolver since we rely on this local HTTP proxy. | 218 // Create the proxy without a resolver since we rely on this local HTTP proxy. |
| 217 // TODO(sgurun) is this behavior guaranteed through SDK? | 219 // TODO(sgurun) is this behavior guaranteed through SDK? |
| 218 builder.set_proxy_service( | 220 builder.set_proxy_service( |
| 219 net::ProxyService::CreateWithoutProxyResolver( | 221 make_scoped_ptr(net::ProxyService::CreateWithoutProxyResolver( |
| 220 proxy_config_service_.release(), | 222 proxy_config_service_.release(), net_log_.get()))); |
| 221 net_log_.get())); | |
| 222 builder.set_net_log(net_log_.get()); | 223 builder.set_net_log(net_log_.get()); |
| 223 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 224 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); |
| 224 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 225 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
| 225 | 226 |
| 226 url_request_context_.reset(builder.Build()); | 227 url_request_context_ = builder.Build().Pass(); |
| 227 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 228 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
| 228 net::HttpNetworkSession::Params network_session_params; | 229 net::HttpNetworkSession::Params network_session_params; |
| 229 | 230 |
| 230 PopulateNetworkSessionParams(url_request_context_.get(), | 231 PopulateNetworkSessionParams(url_request_context_.get(), |
| 231 &network_session_params); | 232 &network_session_params); |
| 232 | 233 |
| 233 net::HttpCache* main_cache = new net::HttpCache( | 234 net::HttpCache* main_cache = new net::HttpCache( |
| 234 network_session_params, | 235 network_session_params, |
| 235 new net::HttpCache::DefaultBackend( | 236 new net::HttpCache::DefaultBackend( |
| 236 net::DISK_CACHE, | 237 net::DISK_CACHE, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return net_log_.get(); | 278 return net_log_.get(); |
| 278 } | 279 } |
| 279 | 280 |
| 280 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 281 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
| 281 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 282 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
| 282 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 283 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
| 283 request_options()->SetKeyOnIO(key); | 284 request_options()->SetKeyOnIO(key); |
| 284 } | 285 } |
| 285 | 286 |
| 286 } // namespace android_webview | 287 } // namespace android_webview |
| OLD | NEW |