Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chrome/browser/net/connection_tester_unittest.cc

Issue 16501002: Give more request types a TransportSecurityState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enforce CalledOnValidThread in all non-static methods. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/net/connection_tester.h" 5 #include "chrome/browser/net/connection_tester.h"
6 6
7 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "content/public/test/test_browser_thread.h" 8 #include "content/public/test/test_browser_thread.h"
9 #include "net/cert/mock_cert_verifier.h" 9 #include "net/cert/mock_cert_verifier.h"
10 #include "net/cookies/cookie_monster.h" 10 #include "net/cookies/cookie_monster.h"
11 #include "net/dns/mock_host_resolver.h" 11 #include "net/dns/mock_host_resolver.h"
12 #include "net/ftp/ftp_network_layer.h" 12 #include "net/ftp/ftp_network_layer.h"
13 #include "net/http/http_auth_handler_factory.h" 13 #include "net/http/http_auth_handler_factory.h"
14 #include "net/http/http_network_layer.h" 14 #include "net/http/http_network_layer.h"
15 #include "net/http/http_network_session.h" 15 #include "net/http/http_network_session.h"
16 #include "net/http/http_server_properties_impl.h" 16 #include "net/http/http_server_properties_impl.h"
17 #include "net/http/transport_security_state.h"
17 #include "net/proxy/proxy_config_service_fixed.h" 18 #include "net/proxy/proxy_config_service_fixed.h"
18 #include "net/proxy/proxy_service.h" 19 #include "net/proxy/proxy_service.h"
19 #include "net/ssl/ssl_config_service_defaults.h" 20 #include "net/ssl/ssl_config_service_defaults.h"
20 #include "net/test/spawned_test_server/spawned_test_server.h" 21 #include "net/test/spawned_test_server/spawned_test_server.h"
21 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "testing/platform_test.h" 24 #include "testing/platform_test.h"
24 25
25 using content::BrowserThread; 26 using content::BrowserThread;
26 27
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // ObserverListThreadSave to shut down properly. For example, 103 // ObserverListThreadSave to shut down properly. For example,
103 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the 104 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the
104 // MessageLoop is already destroyed, then the RemoveObserver will be a 105 // MessageLoop is already destroyed, then the RemoveObserver will be a
105 // no-op, and the ObserverList will contain invalid entries. 106 // no-op, and the ObserverList will contain invalid entries.
106 base::MessageLoop message_loop_; 107 base::MessageLoop message_loop_;
107 content::TestBrowserThread io_thread_; 108 content::TestBrowserThread io_thread_;
108 net::SpawnedTestServer test_server_; 109 net::SpawnedTestServer test_server_;
109 ConnectionTesterDelegate test_delegate_; 110 ConnectionTesterDelegate test_delegate_;
110 net::MockHostResolver host_resolver_; 111 net::MockHostResolver host_resolver_;
111 scoped_ptr<net::CertVerifier> cert_verifier_; 112 scoped_ptr<net::CertVerifier> cert_verifier_;
113 scoped_ptr<net::TransportSecurityState> transport_security_state_;
112 scoped_ptr<net::ProxyService> proxy_service_; 114 scoped_ptr<net::ProxyService> proxy_service_;
113 scoped_refptr<net::SSLConfigService> ssl_config_service_; 115 scoped_refptr<net::SSLConfigService> ssl_config_service_;
114 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; 116 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_;
115 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; 117 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_;
116 net::HttpServerPropertiesImpl http_server_properties_impl_; 118 net::HttpServerPropertiesImpl http_server_properties_impl_;
117 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_; 119 scoped_ptr<net::URLRequestContext> proxy_script_fetcher_context_;
118 120
119 private: 121 private:
120 void InitializeRequestContext() { 122 void InitializeRequestContext() {
121 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_); 123 proxy_script_fetcher_context_->set_host_resolver(&host_resolver_);
122 cert_verifier_.reset(new net::MockCertVerifier); 124 cert_verifier_.reset(new net::MockCertVerifier);
125 transport_security_state_.reset(new net::TransportSecurityState);
123 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get()); 126 proxy_script_fetcher_context_->set_cert_verifier(cert_verifier_.get());
127 proxy_script_fetcher_context_->set_transport_security_state(
128 transport_security_state_.get());
124 proxy_script_fetcher_context_->set_http_auth_handler_factory( 129 proxy_script_fetcher_context_->set_http_auth_handler_factory(
125 &http_auth_handler_factory_); 130 &http_auth_handler_factory_);
126 proxy_service_.reset(net::ProxyService::CreateDirect()); 131 proxy_service_.reset(net::ProxyService::CreateDirect());
127 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get()); 132 proxy_script_fetcher_context_->set_proxy_service(proxy_service_.get());
128 ssl_config_service_ = new net::SSLConfigServiceDefaults; 133 ssl_config_service_ = new net::SSLConfigServiceDefaults;
129 net::HttpNetworkSession::Params session_params; 134 net::HttpNetworkSession::Params session_params;
130 session_params.host_resolver = &host_resolver_; 135 session_params.host_resolver = &host_resolver_;
131 session_params.cert_verifier = cert_verifier_.get(); 136 session_params.cert_verifier = cert_verifier_.get();
137 session_params.transport_security_state = transport_security_state_.get();
132 session_params.http_auth_handler_factory = &http_auth_handler_factory_; 138 session_params.http_auth_handler_factory = &http_auth_handler_factory_;
133 session_params.ssl_config_service = ssl_config_service_.get(); 139 session_params.ssl_config_service = ssl_config_service_.get();
134 session_params.proxy_service = proxy_service_.get(); 140 session_params.proxy_service = proxy_service_.get();
135 session_params.http_server_properties = &http_server_properties_impl_; 141 session_params.http_server_properties = &http_server_properties_impl_;
136 scoped_refptr<net::HttpNetworkSession> network_session( 142 scoped_refptr<net::HttpNetworkSession> network_session(
137 new net::HttpNetworkSession(session_params)); 143 new net::HttpNetworkSession(session_params));
138 http_transaction_factory_.reset( 144 http_transaction_factory_.reset(
139 new net::HttpNetworkLayer(network_session.get())); 145 new net::HttpNetworkLayer(network_session.get()));
140 proxy_script_fetcher_context_->set_http_transaction_factory( 146 proxy_script_fetcher_context_->set_http_transaction_factory(
141 http_transaction_factory_.get()); 147 http_transaction_factory_.get());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer 208 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer
203 // |backup_task| that it will try to deref during the destructor, but 209 // |backup_task| that it will try to deref during the destructor, but
204 // depending on the order that pending tasks were deleted in, it might 210 // depending on the order that pending tasks were deleted in, it might
205 // already be invalid! See http://crbug.com/43291. 211 // already be invalid! See http://crbug.com/43291.
206 base::MessageLoop::current()->PostTask(FROM_HERE, 212 base::MessageLoop::current()->PostTask(FROM_HERE,
207 base::MessageLoop::QuitClosure()); 213 base::MessageLoop::QuitClosure());
208 base::MessageLoop::current()->Run(); 214 base::MessageLoop::current()->Run();
209 } 215 }
210 216
211 } // namespace 217 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/connection_tester.cc ('k') | chrome/service/net/service_url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698