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" |
19 #include "content/public/common/content_client.h" | 20 #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) | 124 const base::FilePath& partition_path, net::CookieStore* cookie_store) |
125 : partition_path_(partition_path), | 125 : partition_path_(partition_path), |
| 126 cookie_store_(cookie_store), |
126 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService( | 127 proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService( |
127 GetNetworkTaskRunner(), | 128 GetNetworkTaskRunner(), |
128 NULL /* Ignored on Android */)) { | 129 NULL /* Ignored on Android */)) { |
129 // CreateSystemProxyConfigService for Android must be called on main thread. | 130 // CreateSystemProxyConfigService for Android must be called on main thread. |
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
131 } | 132 } |
132 | 133 |
133 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 134 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
134 } | 135 } |
135 | 136 |
(...skipping 25 matching lines...) Expand all Loading... |
161 net::HttpCache* main_cache = new net::HttpCache( | 162 net::HttpCache* main_cache = new net::HttpCache( |
162 network_session_params, | 163 network_session_params, |
163 new net::HttpCache::DefaultBackend( | 164 new net::HttpCache::DefaultBackend( |
164 net::DISK_CACHE, | 165 net::DISK_CACHE, |
165 cache_type, | 166 cache_type, |
166 partition_path_.Append(FILE_PATH_LITERAL("Cache")), | 167 partition_path_.Append(FILE_PATH_LITERAL("Cache")), |
167 10 * 1024 * 1024, // 10M | 168 10 * 1024 * 1024, // 10M |
168 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
169 main_http_factory_.reset(main_cache); | 170 main_http_factory_.reset(main_cache); |
170 url_request_context_->set_http_transaction_factory(main_cache); | 171 url_request_context_->set_http_transaction_factory(main_cache); |
| 172 url_request_context_->set_cookie_store(cookie_store_); |
171 | 173 |
172 job_factory_ = CreateJobFactory(&protocol_handlers_); | 174 job_factory_ = CreateJobFactory(&protocol_handlers_); |
173 url_request_context_->set_job_factory(job_factory_.get()); | 175 url_request_context_->set_job_factory(job_factory_.get()); |
174 } | 176 } |
175 | 177 |
176 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 178 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
178 if (!url_request_context_) | 180 if (!url_request_context_) |
179 InitializeURLRequestContext(); | 181 InitializeURLRequestContext(); |
180 | 182 |
181 return url_request_context_.get(); | 183 return url_request_context_.get(); |
182 } | 184 } |
183 | 185 |
184 scoped_refptr<base::SingleThreadTaskRunner> | 186 scoped_refptr<base::SingleThreadTaskRunner> |
185 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 187 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
186 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 188 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
187 } | 189 } |
188 | 190 |
189 void AwURLRequestContextGetter::SetProtocolHandlers( | 191 void AwURLRequestContextGetter::SetProtocolHandlers( |
190 content::ProtocolHandlerMap* protocol_handlers) { | 192 content::ProtocolHandlerMap* protocol_handlers) { |
191 std::swap(protocol_handlers_, *protocol_handlers); | 193 std::swap(protocol_handlers_, *protocol_handlers); |
192 } | 194 } |
193 | 195 |
194 } // namespace android_webview | 196 } // namespace android_webview |
OLD | NEW |