| 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_content_browser_client.h" | 9 #include "android_webview/browser/aw_content_browser_client.h" |
| 10 #include "android_webview/browser/aw_request_interceptor.h" | 10 #include "android_webview/browser/aw_request_interceptor.h" |
| 11 #include "android_webview/browser/net/aw_network_delegate.h" | 11 #include "android_webview/browser/net/aw_network_delegate.h" |
| 12 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 12 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 13 #include "android_webview/browser/net/init_native_callback.h" | 13 #include "android_webview/browser/net/init_native_callback.h" |
| 14 #include "android_webview/common/aw_switches.h" | 14 #include "android_webview/common/aw_switches.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/cookie_store_factory.h" | |
| 20 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
| 20 #include "content/public/common/content_constants.h" |
| 21 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 22 #include "net/base/cache_type.h" | 22 #include "net/base/cache_type.h" |
| 23 #include "net/cookies/cookie_store.h" | 23 #include "net/cookies/cookie_store.h" |
| 24 #include "net/http/http_cache.h" | 24 #include "net/http/http_cache.h" |
| 25 #include "net/proxy/proxy_service.h" | 25 #include "net/proxy/proxy_service.h" |
| 26 #include "net/url_request/data_protocol_handler.h" | 26 #include "net/url_request/data_protocol_handler.h" |
| 27 #include "net/url_request/file_protocol_handler.h" | 27 #include "net/url_request/file_protocol_handler.h" |
| 28 #include "net/url_request/protocol_intercept_job_factory.h" | 28 #include "net/url_request/protocol_intercept_job_factory.h" |
| 29 #include "net/url_request/url_request_context_builder.h" | 29 #include "net/url_request/url_request_context_builder.h" |
| 30 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 job_factory.reset(new net::ProtocolInterceptJobFactory( | 114 job_factory.reset(new net::ProtocolInterceptJobFactory( |
| 115 job_factory.Pass(), make_scoped_ptr(*i))); | 115 job_factory.Pass(), make_scoped_ptr(*i))); |
| 116 } | 116 } |
| 117 | 117 |
| 118 return job_factory.Pass(); | 118 return job_factory.Pass(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace | 121 } // namespace |
| 122 | 122 |
| 123 AwURLRequestContextGetter::AwURLRequestContextGetter( | 123 AwURLRequestContextGetter::AwURLRequestContextGetter( |
| 124 const base::FilePath& partition_path, net::CookieStore* cookie_store) | 124 const base::FilePath& partition_path) |
| 125 : partition_path_(partition_path), | 125 : partition_path_(partition_path), |
| 126 cookie_store_(cookie_store), | |
| 127 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService( | 126 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService( |
| 128 GetNetworkTaskRunner(), | 127 GetNetworkTaskRunner(), |
| 129 NULL /* Ignored on Android */)) { | 128 NULL /* Ignored on Android */)) { |
| 130 // CreateSystemProxyConfigService for Android must be called on main thread. | 129 // CreateSystemProxyConfigService for Android must be called on main thread. |
| 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 132 } | 131 } |
| 133 | 132 |
| 134 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 133 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
| 135 } | 134 } |
| 136 | 135 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 162 net::HttpCache* main_cache = new net::HttpCache( | 161 net::HttpCache* main_cache = new net::HttpCache( |
| 163 network_session_params, | 162 network_session_params, |
| 164 new net::HttpCache::DefaultBackend( | 163 new net::HttpCache::DefaultBackend( |
| 165 net::DISK_CACHE, | 164 net::DISK_CACHE, |
| 166 cache_type, | 165 cache_type, |
| 167 partition_path_.Append(FILE_PATH_LITERAL("Cache")), | 166 partition_path_.Append(FILE_PATH_LITERAL("Cache")), |
| 168 10 * 1024 * 1024, // 10M | 167 10 * 1024 * 1024, // 10M |
| 169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 168 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| 170 main_http_factory_.reset(main_cache); | 169 main_http_factory_.reset(main_cache); |
| 171 url_request_context_->set_http_transaction_factory(main_cache); | 170 url_request_context_->set_http_transaction_factory(main_cache); |
| 172 url_request_context_->set_cookie_store(cookie_store_); | |
| 173 | 171 |
| 174 job_factory_ = CreateJobFactory(&protocol_handlers_); | 172 job_factory_ = CreateJobFactory(&protocol_handlers_); |
| 175 url_request_context_->set_job_factory(job_factory_.get()); | 173 url_request_context_->set_job_factory(job_factory_.get()); |
| 176 } | 174 } |
| 177 | 175 |
| 178 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 176 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 180 if (!url_request_context_) | 178 if (!url_request_context_) |
| 181 InitializeURLRequestContext(); | 179 InitializeURLRequestContext(); |
| 182 | 180 |
| 183 return url_request_context_.get(); | 181 return url_request_context_.get(); |
| 184 } | 182 } |
| 185 | 183 |
| 186 scoped_refptr<base::SingleThreadTaskRunner> | 184 scoped_refptr<base::SingleThreadTaskRunner> |
| 187 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 185 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 188 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 186 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 189 } | 187 } |
| 190 | 188 |
| 191 void AwURLRequestContextGetter::SetProtocolHandlers( | 189 void AwURLRequestContextGetter::SetProtocolHandlers( |
| 192 content::ProtocolHandlerMap* protocol_handlers) { | 190 content::ProtocolHandlerMap* protocol_handlers) { |
| 193 std::swap(protocol_handlers_, *protocol_handlers); | 191 std::swap(protocol_handlers_, *protocol_handlers); |
| 194 } | 192 } |
| 195 | 193 |
| 196 } // namespace android_webview | 194 } // namespace android_webview |
| OLD | NEW |