| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 url_request_context_.reset(builder.Build()); | 96 url_request_context_.reset(builder.Build()); |
| 97 | 97 |
| 98 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); | 98 scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); |
| 99 bool set_protocol = job_factory->SetProtocolHandler( | 99 bool set_protocol = job_factory->SetProtocolHandler( |
| 100 chrome::kFileScheme, new net::FileProtocolHandler()); | 100 chrome::kFileScheme, new net::FileProtocolHandler()); |
| 101 DCHECK(set_protocol); | 101 DCHECK(set_protocol); |
| 102 set_protocol = job_factory->SetProtocolHandler( | 102 set_protocol = job_factory->SetProtocolHandler( |
| 103 chrome::kDataScheme, new net::DataProtocolHandler()); | 103 chrome::kDataScheme, new net::DataProtocolHandler()); |
| 104 DCHECK(set_protocol); | 104 DCHECK(set_protocol); |
| 105 job_factory->AddInterceptor(new AwRequestInterceptor()); | 105 job_factory->AddInterceptor(new AwRequestInterceptor()); |
| 106 url_request_context_->set_job_factory(job_factory.get()); | |
| 107 | 106 |
| 108 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 107 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
| 109 net::HttpNetworkSession::Params network_session_params; | 108 net::HttpNetworkSession::Params network_session_params; |
| 110 PopulateNetworkSessionParams(&network_session_params); | 109 PopulateNetworkSessionParams(&network_session_params); |
| 111 net::HttpCache* main_cache = new net::HttpCache( | 110 net::HttpCache* main_cache = new net::HttpCache( |
| 112 network_session_params, | 111 network_session_params, |
| 113 new net::HttpCache::DefaultBackend( | 112 new net::HttpCache::DefaultBackend( |
| 114 net::DISK_CACHE, | 113 net::DISK_CACHE, |
| 115 browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cache")), | 114 browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cache")), |
| 116 10 * 1024 * 1024, // 10M | 115 10 * 1024 * 1024, // 10M |
| 117 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 116 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| 118 main_http_factory_.reset(main_cache); | 117 main_http_factory_.reset(main_cache); |
| 119 url_request_context_->set_http_transaction_factory(main_cache); | 118 url_request_context_->set_http_transaction_factory(main_cache); |
| 120 | 119 |
| 121 OnNetworkStackInitialized(url_request_context_.get(), | 120 job_factory_ = CreateAndroidJobFactoryAndCookieMonster( |
| 122 job_factory.get()); | 121 url_request_context_.get(), job_factory.Pass()); |
| 123 job_factory_ = job_factory.Pass(); | 122 url_request_context_->set_job_factory(job_factory_.get()); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void AwURLRequestContextGetter::PopulateNetworkSessionParams( | 125 void AwURLRequestContextGetter::PopulateNetworkSessionParams( |
| 127 net::HttpNetworkSession::Params* params) { | 126 net::HttpNetworkSession::Params* params) { |
| 128 net::URLRequestContext* context = url_request_context_.get(); | 127 net::URLRequestContext* context = url_request_context_.get(); |
| 129 params->host_resolver = context->host_resolver(); | 128 params->host_resolver = context->host_resolver(); |
| 130 params->cert_verifier = context->cert_verifier(); | 129 params->cert_verifier = context->cert_verifier(); |
| 131 params->server_bound_cert_service = context->server_bound_cert_service(); | 130 params->server_bound_cert_service = context->server_bound_cert_service(); |
| 132 params->transport_security_state = context->transport_security_state(); | 131 params->transport_security_state = context->transport_security_state(); |
| 133 params->proxy_service = context->proxy_service(); | 132 params->proxy_service = context->proxy_service(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 150 return url_request_context_.get(); | 149 return url_request_context_.get(); |
| 151 } | 150 } |
| 152 | 151 |
| 153 scoped_refptr<base::SingleThreadTaskRunner> | 152 scoped_refptr<base::SingleThreadTaskRunner> |
| 154 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 153 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 155 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 154 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace android_webview | 157 } // namespace android_webview |
| OLD | NEW |