| 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 "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/aw_request_interceptor.h" | 8 #include "android_webview/browser/aw_request_interceptor.h" |
| 9 #include "android_webview/browser/net/aw_network_delegate.h" | 9 #include "android_webview/browser/net/aw_network_delegate.h" |
| 10 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 10 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 11 #include "android_webview/browser/net/init_native_callback.h" | 11 #include "android_webview/browser/net/init_native_callback.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "net/cookies/cookie_store.h" |
| 16 #include "net/http/http_cache.h" | 17 #include "net/http/http_cache.h" |
| 17 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
| 18 #include "net/url_request/data_protocol_handler.h" | 19 #include "net/url_request/data_protocol_handler.h" |
| 19 #include "net/url_request/file_protocol_handler.h" | 20 #include "net/url_request/file_protocol_handler.h" |
| 20 #include "net/url_request/protocol_intercept_job_factory.h" | 21 #include "net/url_request/protocol_intercept_job_factory.h" |
| 21 #include "net/url_request/url_request_context_builder.h" | 22 #include "net/url_request/url_request_context_builder.h" |
| 22 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 | 26 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 PopulateNetworkSessionParams(&network_session_params); | 66 PopulateNetworkSessionParams(&network_session_params); |
| 66 net::HttpCache* main_cache = new net::HttpCache( | 67 net::HttpCache* main_cache = new net::HttpCache( |
| 67 network_session_params, | 68 network_session_params, |
| 68 new net::HttpCache::DefaultBackend( | 69 new net::HttpCache::DefaultBackend( |
| 69 net::DISK_CACHE, | 70 net::DISK_CACHE, |
| 70 browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cache")), | 71 browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cache")), |
| 71 10 * 1024 * 1024, // 10M | 72 10 * 1024 * 1024, // 10M |
| 72 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 73 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| 73 main_http_factory_.reset(main_cache); | 74 main_http_factory_.reset(main_cache); |
| 74 url_request_context_->set_http_transaction_factory(main_cache); | 75 url_request_context_->set_http_transaction_factory(main_cache); |
| 76 |
| 77 // The CookieMonster must be passed here so it happens synchronously to |
| 78 // the main thread initialization (to avoid race condition in another |
| 79 // thread trying to access the CookieManager API). |
| 80 DidCreateCookieMonster( |
| 81 url_request_context_->cookie_store()->GetCookieMonster()); |
| 75 } | 82 } |
| 76 | 83 |
| 77 void AwURLRequestContextGetter::PopulateNetworkSessionParams( | 84 void AwURLRequestContextGetter::PopulateNetworkSessionParams( |
| 78 net::HttpNetworkSession::Params* params) { | 85 net::HttpNetworkSession::Params* params) { |
| 79 net::URLRequestContext* context = url_request_context_.get(); | 86 net::URLRequestContext* context = url_request_context_.get(); |
| 80 params->host_resolver = context->host_resolver(); | 87 params->host_resolver = context->host_resolver(); |
| 81 params->cert_verifier = context->cert_verifier(); | 88 params->cert_verifier = context->cert_verifier(); |
| 82 params->server_bound_cert_service = context->server_bound_cert_service(); | 89 params->server_bound_cert_service = context->server_bound_cert_service(); |
| 83 params->transport_security_state = context->transport_security_state(); | 90 params->transport_security_state = context->transport_security_state(); |
| 84 params->proxy_service = context->proxy_service(); | 91 params->proxy_service = context->proxy_service(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 111 set_protocol = job_factory->SetProtocolHandler( | 118 set_protocol = job_factory->SetProtocolHandler( |
| 112 chrome::kChromeUIScheme, chrome_protocol_handler_.release()); | 119 chrome::kChromeUIScheme, chrome_protocol_handler_.release()); |
| 113 DCHECK(set_protocol); | 120 DCHECK(set_protocol); |
| 114 DCHECK(chrome_devtools_protocol_handler_); | 121 DCHECK(chrome_devtools_protocol_handler_); |
| 115 set_protocol = job_factory->SetProtocolHandler( | 122 set_protocol = job_factory->SetProtocolHandler( |
| 116 chrome::kChromeDevToolsScheme, | 123 chrome::kChromeDevToolsScheme, |
| 117 chrome_devtools_protocol_handler_.release()); | 124 chrome_devtools_protocol_handler_.release()); |
| 118 DCHECK(set_protocol); | 125 DCHECK(set_protocol); |
| 119 // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed | 126 // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed |
| 120 // at the beginning of the chain. | 127 // at the beginning of the chain. |
| 121 job_factory_ = CreateAndroidJobFactoryAndCookieMonster( | 128 job_factory_ = CreateAndroidJobFactory(job_factory.Pass()); |
| 122 url_request_context_.get(), job_factory.Pass()); | |
| 123 job_factory_.reset(new net::ProtocolInterceptJobFactory( | 129 job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| 124 job_factory_.Pass(), | 130 job_factory_.Pass(), |
| 125 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| 126 new AwRequestInterceptor()))); | 132 new AwRequestInterceptor()))); |
| 127 job_factory_.reset(new net::ProtocolInterceptJobFactory( | 133 job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| 128 job_factory_.Pass(), | 134 job_factory_.Pass(), |
| 129 developer_protocol_handler_.Pass())); | 135 developer_protocol_handler_.Pass())); |
| 130 url_request_context_->set_job_factory(job_factory_.get()); | 136 url_request_context_->set_job_factory(job_factory_.get()); |
| 131 } | 137 } |
| 132 return url_request_context_.get(); | 138 return url_request_context_.get(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 149 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 155 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 150 chrome_devtools_protocol_handler) { | 156 chrome_devtools_protocol_handler) { |
| 151 blob_protocol_handler_ = blob_protocol_handler.Pass(); | 157 blob_protocol_handler_ = blob_protocol_handler.Pass(); |
| 152 file_system_protocol_handler_ = file_system_protocol_handler.Pass(); | 158 file_system_protocol_handler_ = file_system_protocol_handler.Pass(); |
| 153 developer_protocol_handler_ = developer_protocol_handler.Pass(); | 159 developer_protocol_handler_ = developer_protocol_handler.Pass(); |
| 154 chrome_protocol_handler_ = chrome_protocol_handler.Pass(); | 160 chrome_protocol_handler_ = chrome_protocol_handler.Pass(); |
| 155 chrome_devtools_protocol_handler_ = chrome_devtools_protocol_handler.Pass(); | 161 chrome_devtools_protocol_handler_ = chrome_devtools_protocol_handler.Pass(); |
| 156 } | 162 } |
| 157 | 163 |
| 158 } // namespace android_webview | 164 } // namespace android_webview |
| OLD | NEW |