| 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_switches.h" | 15 #include "android_webview/common/aw_switches.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/cookie_store_factory.h" | 20 #include "content/public/browser/cookie_store_factory.h" |
| 20 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
| 21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
| 22 #include "net/base/cache_type.h" | 23 #include "net/base/cache_type.h" |
| 23 #include "net/cookies/cookie_store.h" | 24 #include "net/cookies/cookie_store.h" |
| 24 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 25 #include "net/proxy/proxy_service.h" | 26 #include "net/proxy/proxy_service.h" |
| 26 #include "net/url_request/data_protocol_handler.h" | 27 #include "net/url_request/data_protocol_handler.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 // The CookieMonster must be passed here so it happens synchronously to | 65 // The CookieMonster must be passed here so it happens synchronously to |
| 65 // the main thread initialization (to avoid race condition in another | 66 // the main thread initialization (to avoid race condition in another |
| 66 // thread trying to access the CookieManager API). | 67 // thread trying to access the CookieManager API). |
| 67 DidCreateCookieMonster(cookie_store_->GetCookieMonster()); | 68 DidCreateCookieMonster(cookie_store_->GetCookieMonster()); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void AwURLRequestContextGetter::InitAsync() { | 71 void AwURLRequestContextGetter::InitAsync() { |
| 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 72 | 73 |
| 73 net::URLRequestContextBuilder builder; | 74 net::URLRequestContextBuilder builder( |
| 75 content::BrowserThread::GetBlockingPool()-> |
| 76 GetTaskRunnerWithShutdownBehavior( |
| 77 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 74 builder.set_user_agent(content::GetUserAgent(GURL())); | 78 builder.set_user_agent(content::GetUserAgent(GURL())); |
| 75 builder.set_network_delegate(new AwNetworkDelegate()); | 79 builder.set_network_delegate(new AwNetworkDelegate()); |
| 76 #if !defined(DISABLE_FTP_SUPPORT) | 80 #if !defined(DISABLE_FTP_SUPPORT) |
| 77 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 81 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 78 #endif | 82 #endif |
| 79 builder.set_proxy_config_service(proxy_config_service_.release()); | 83 builder.set_proxy_config_service(proxy_config_service_.release()); |
| 80 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( | 84 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( |
| 81 AwContentBrowserClient::GetAcceptLangsImpl())); | 85 AwContentBrowserClient::GetAcceptLangsImpl())); |
| 82 | 86 |
| 83 url_request_context_.reset(builder.Build()); | 87 url_request_context_.reset(builder.Build()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 params->network_delegate = context->network_delegate(); | 120 params->network_delegate = context->network_delegate(); |
| 117 params->http_server_properties = context->http_server_properties(); | 121 params->http_server_properties = context->http_server_properties(); |
| 118 params->net_log = context->net_log(); | 122 params->net_log = context->net_log(); |
| 119 } | 123 } |
| 120 | 124 |
| 121 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 125 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 123 if (!job_factory_) { | 127 if (!job_factory_) { |
| 124 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); | 128 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); |
| 125 bool set_protocol = job_factory->SetProtocolHandler( | 129 bool set_protocol = job_factory->SetProtocolHandler( |
| 126 chrome::kFileScheme, new net::FileProtocolHandler()); | 130 chrome::kFileScheme, |
| 131 new net::FileProtocolHandler( |
| 132 content::BrowserThread::GetBlockingPool()-> |
| 133 GetTaskRunnerWithShutdownBehavior( |
| 134 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
| 127 DCHECK(set_protocol); | 135 DCHECK(set_protocol); |
| 128 set_protocol = job_factory->SetProtocolHandler( | 136 set_protocol = job_factory->SetProtocolHandler( |
| 129 chrome::kDataScheme, new net::DataProtocolHandler()); | 137 chrome::kDataScheme, new net::DataProtocolHandler()); |
| 130 DCHECK(set_protocol); | 138 DCHECK(set_protocol); |
| 131 set_protocol = job_factory->SetProtocolHandler( | 139 set_protocol = job_factory->SetProtocolHandler( |
| 132 chrome::kBlobScheme, protocol_handlers_[chrome::kBlobScheme].release()); | 140 chrome::kBlobScheme, protocol_handlers_[chrome::kBlobScheme].release()); |
| 133 DCHECK(set_protocol); | 141 DCHECK(set_protocol); |
| 134 set_protocol = job_factory->SetProtocolHandler( | 142 set_protocol = job_factory->SetProtocolHandler( |
| 135 chrome::kFileSystemScheme, | 143 chrome::kFileSystemScheme, |
| 136 protocol_handlers_[chrome::kFileSystemScheme].release()); | 144 protocol_handlers_[chrome::kFileSystemScheme].release()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 197 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 190 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 198 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 191 } | 199 } |
| 192 | 200 |
| 193 void AwURLRequestContextGetter::SetProtocolHandlers( | 201 void AwURLRequestContextGetter::SetProtocolHandlers( |
| 194 content::ProtocolHandlerMap* protocol_handlers) { | 202 content::ProtocolHandlerMap* protocol_handlers) { |
| 195 std::swap(protocol_handlers_, *protocol_handlers); | 203 std::swap(protocol_handlers_, *protocol_handlers); |
| 196 } | 204 } |
| 197 | 205 |
| 198 } // namespace android_webview | 206 } // namespace android_webview |
| OLD | NEW |