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 "content/shell/shell_url_request_context_getter.h" | 5 #include "content/shell/shell_url_request_context_getter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/shell/shell_network_delegate.h" |
10 #include "net/base/cert_verifier.h" | 11 #include "net/base/cert_verifier.h" |
11 #include "net/base/default_server_bound_cert_store.h" | 12 #include "net/base/default_server_bound_cert_store.h" |
12 #include "net/base/host_resolver.h" | 13 #include "net/base/host_resolver.h" |
13 #include "net/base/server_bound_cert_service.h" | 14 #include "net/base/server_bound_cert_service.h" |
14 #include "net/base/ssl_config_service_defaults.h" | 15 #include "net/base/ssl_config_service_defaults.h" |
15 #include "net/cookies/cookie_monster.h" | 16 #include "net/cookies/cookie_monster.h" |
16 #include "net/http/http_auth_handler_factory.h" | 17 #include "net/http/http_auth_handler_factory.h" |
17 #include "net/http/http_cache.h" | 18 #include "net/http/http_cache.h" |
18 #include "net/http/http_server_properties_impl.h" | 19 #include "net/http/http_server_properties_impl.h" |
19 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
(...skipping 22 matching lines...) Expand all Loading... |
42 } | 43 } |
43 | 44 |
44 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { | 45 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { |
45 } | 46 } |
46 | 47 |
47 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { | 48 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
49 | 50 |
50 if (!url_request_context_) { | 51 if (!url_request_context_) { |
51 url_request_context_ = new net::URLRequestContext(); | 52 url_request_context_ = new net::URLRequestContext(); |
| 53 network_delegate_.reset(new ShellNetworkDelegate); |
| 54 url_request_context_->set_network_delegate(network_delegate_.get()); |
52 storage_.reset(new net::URLRequestContextStorage(url_request_context_)); | 55 storage_.reset(new net::URLRequestContextStorage(url_request_context_)); |
53 | |
54 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); | 56 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
55 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( | 57 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( |
56 new net::DefaultServerBoundCertStore(NULL))); | 58 new net::DefaultServerBoundCertStore(NULL))); |
57 url_request_context_->set_accept_language("en-us,en"); | 59 url_request_context_->set_accept_language("en-us,en"); |
58 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8"); | 60 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8"); |
59 | 61 |
60 storage_->set_host_resolver( | 62 storage_->set_host_resolver( |
61 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, | 63 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, |
62 net::HostResolver::kDefaultRetryAttempts, | 64 net::HostResolver::kDefaultRetryAttempts, |
63 NULL)); | 65 NULL)); |
(...skipping 21 matching lines...) Expand all Loading... |
85 | 87 |
86 net::HttpCache* main_cache = new net::HttpCache( | 88 net::HttpCache* main_cache = new net::HttpCache( |
87 url_request_context_->host_resolver(), | 89 url_request_context_->host_resolver(), |
88 url_request_context_->cert_verifier(), | 90 url_request_context_->cert_verifier(), |
89 url_request_context_->server_bound_cert_service(), | 91 url_request_context_->server_bound_cert_service(), |
90 NULL, // tranport_security_state | 92 NULL, // tranport_security_state |
91 url_request_context_->proxy_service(), | 93 url_request_context_->proxy_service(), |
92 "", // ssl_session_cache_shard | 94 "", // ssl_session_cache_shard |
93 url_request_context_->ssl_config_service(), | 95 url_request_context_->ssl_config_service(), |
94 url_request_context_->http_auth_handler_factory(), | 96 url_request_context_->http_auth_handler_factory(), |
95 NULL, // network_delegate | 97 url_request_context_->network_delegate(), |
96 url_request_context_->http_server_properties(), | 98 url_request_context_->http_server_properties(), |
97 NULL, | 99 NULL, |
98 main_backend); | 100 main_backend); |
99 storage_->set_http_transaction_factory(main_cache); | 101 storage_->set_http_transaction_factory(main_cache); |
100 | 102 |
101 storage_->set_job_factory(new net::URLRequestJobFactory); | 103 storage_->set_job_factory(new net::URLRequestJobFactory); |
102 } | 104 } |
103 | 105 |
104 return url_request_context_; | 106 return url_request_context_; |
105 } | 107 } |
106 | 108 |
107 scoped_refptr<base::MessageLoopProxy> | 109 scoped_refptr<base::MessageLoopProxy> |
108 ShellURLRequestContextGetter::GetIOMessageLoopProxy() const { | 110 ShellURLRequestContextGetter::GetIOMessageLoopProxy() const { |
109 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 111 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
110 } | 112 } |
111 | 113 |
112 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 114 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
113 return url_request_context_->host_resolver(); | 115 return url_request_context_->host_resolver(); |
114 } | 116 } |
115 | 117 |
116 } // namespace content | 118 } // namespace content |
OLD | NEW |