| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 196   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 196   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| 197   DCHECK(!url_request_context_); | 197   DCHECK(!url_request_context_); | 
| 198 | 198 | 
| 199   net::URLRequestContextBuilder builder; | 199   net::URLRequestContextBuilder builder; | 
| 200   scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); | 200   scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); | 
| 201 | 201 | 
| 202   AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 202   AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 
| 203   DCHECK(browser_context); | 203   DCHECK(browser_context); | 
| 204 | 204 | 
| 205   builder.set_network_delegate( | 205   builder.set_network_delegate( | 
| 206       browser_context->GetDataReductionProxyIOData()->CreateNetworkDelegate( | 206       browser_context->GetDataReductionProxyIOData() | 
| 207           aw_network_delegate.Pass(), | 207           ->CreateNetworkDelegate( | 
| 208           false /* No UMA is produced to track bypasses. */ ).release()); | 208               aw_network_delegate.Pass(), | 
|  | 209               false /* No UMA is produced to track bypasses. */) | 
|  | 210           .Pass()); | 
| 209 #if !defined(DISABLE_FTP_SUPPORT) | 211 #if !defined(DISABLE_FTP_SUPPORT) | 
| 210   builder.set_ftp_enabled(false);  // Android WebView does not support ftp yet. | 212   builder.set_ftp_enabled(false);  // Android WebView does not support ftp yet. | 
| 211 #endif | 213 #endif | 
| 212   DCHECK(proxy_config_service_.get()); | 214   DCHECK(proxy_config_service_.get()); | 
| 213   // Android provides a local HTTP proxy that handles all the proxying. | 215   // Android provides a local HTTP proxy that handles all the proxying. | 
| 214   // Create the proxy without a resolver since we rely on this local HTTP proxy. | 216   // Create the proxy without a resolver since we rely on this local HTTP proxy. | 
| 215   // TODO(sgurun) is this behavior guaranteed through SDK? | 217   // TODO(sgurun) is this behavior guaranteed through SDK? | 
| 216   builder.set_proxy_service( | 218   builder.set_proxy_service( | 
| 217       net::ProxyService::CreateWithoutProxyResolver( | 219       make_scoped_ptr(net::ProxyService::CreateWithoutProxyResolver( | 
| 218           proxy_config_service_.release(), | 220           proxy_config_service_.release(), net_log_.get()))); | 
| 219           net_log_.get())); |  | 
| 220   builder.set_net_log(net_log_.get()); | 221   builder.set_net_log(net_log_.get()); | 
| 221   builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 222   builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 
| 222   ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 223   ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 
| 223 | 224 | 
| 224   url_request_context_.reset(builder.Build()); | 225   url_request_context_ = builder.Build().Pass(); | 
| 225   // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 226   // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 
| 226   net::HttpNetworkSession::Params network_session_params; | 227   net::HttpNetworkSession::Params network_session_params; | 
| 227 | 228 | 
| 228   PopulateNetworkSessionParams(url_request_context_.get(), | 229   PopulateNetworkSessionParams(url_request_context_.get(), | 
| 229                                &network_session_params); | 230                                &network_session_params); | 
| 230 | 231 | 
| 231   net::HttpCache* main_cache = new net::HttpCache( | 232   net::HttpCache* main_cache = new net::HttpCache( | 
| 232       network_session_params, | 233       network_session_params, | 
| 233       new net::HttpCache::DefaultBackend( | 234       new net::HttpCache::DefaultBackend( | 
| 234           net::DISK_CACHE, | 235           net::DISK_CACHE, | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 275   return net_log_.get(); | 276   return net_log_.get(); | 
| 276 } | 277 } | 
| 277 | 278 | 
| 278 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 279 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 
| 279   DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 280   DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 
| 280   AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 281   AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 
| 281       request_options()->SetKeyOnIO(key); | 282       request_options()->SetKeyOnIO(key); | 
| 282 } | 283 } | 
| 283 | 284 | 
| 284 }  // namespace android_webview | 285 }  // namespace android_webview | 
| OLD | NEW | 
|---|