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

Side by Side Diff: net/socket/client_socket_factory.cc

Issue 135373002: Added SSLHostInfo. Storing of server host info to our standard disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 years, 11 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 "net/socket/client_socket_factory.h" 5 #include "net/socket/client_socket_factory.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "net/cert/cert_database.h" 11 #include "net/cert/cert_database.h"
12 #include "net/socket/client_socket_handle.h" 12 #include "net/socket/client_socket_handle.h"
13 #if defined(USE_OPENSSL) 13 #if defined(USE_OPENSSL)
14 #include "net/socket/ssl_client_socket_openssl.h" 14 #include "net/socket/ssl_client_socket_openssl.h"
15 #elif defined(USE_NSS) || defined(OS_MACOSX) || defined(OS_WIN) 15 #elif defined(USE_NSS) || defined(OS_MACOSX) || defined(OS_WIN)
16 #include "net/socket/ssl_client_socket_nss.h" 16 #include "net/socket/ssl_client_socket_nss.h"
17 #endif 17 #endif
18 #include "net/socket/ssl_host_info.h"
18 #include "net/socket/tcp_client_socket.h" 19 #include "net/socket/tcp_client_socket.h"
19 #include "net/udp/udp_client_socket.h" 20 #include "net/udp/udp_client_socket.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 class X509Certificate; 24 class X509Certificate;
24 25
25 namespace { 26 namespace {
26 27
27 // ChromeOS and Linux may require interaction with smart cards or TPMs, which 28 // ChromeOS and Linux may require interaction with smart cards or TPMs, which
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 NetLog* net_log, 82 NetLog* net_log,
82 const NetLog::Source& source) OVERRIDE { 83 const NetLog::Source& source) OVERRIDE {
83 return scoped_ptr<StreamSocket>( 84 return scoped_ptr<StreamSocket>(
84 new TCPClientSocket(addresses, net_log, source)); 85 new TCPClientSocket(addresses, net_log, source));
85 } 86 }
86 87
87 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( 88 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket(
88 scoped_ptr<ClientSocketHandle> transport_socket, 89 scoped_ptr<ClientSocketHandle> transport_socket,
89 const HostPortPair& host_and_port, 90 const HostPortPair& host_and_port,
90 const SSLConfig& ssl_config, 91 const SSLConfig& ssl_config,
92 SSLHostInfo* ssl_host_info,
91 const SSLClientSocketContext& context) OVERRIDE { 93 const SSLClientSocketContext& context) OVERRIDE {
94 scoped_ptr<SSLHostInfo> shi(ssl_host_info);
95
92 // nss_thread_task_runner_ may be NULL if g_use_dedicated_nss_thread is 96 // nss_thread_task_runner_ may be NULL if g_use_dedicated_nss_thread is
93 // false or if the dedicated NSS thread failed to start. If so, cause NSS 97 // false or if the dedicated NSS thread failed to start. If so, cause NSS
94 // functions to execute on the current task runner. 98 // functions to execute on the current task runner.
95 // 99 //
96 // Note: The current task runner is obtained on each call due to unit 100 // Note: The current task runner is obtained on each call due to unit
97 // tests, which may create and tear down the current thread's TaskRunner 101 // tests, which may create and tear down the current thread's TaskRunner
98 // between each test. Because the DefaultClientSocketFactory is leaky, it 102 // between each test. Because the DefaultClientSocketFactory is leaky, it
99 // may span multiple tests, and thus the current task runner may change 103 // may span multiple tests, and thus the current task runner may change
100 // from call to call. 104 // from call to call.
101 scoped_refptr<base::SequencedTaskRunner> nss_task_runner( 105 scoped_refptr<base::SequencedTaskRunner> nss_task_runner(
102 nss_thread_task_runner_); 106 nss_thread_task_runner_);
103 if (!nss_task_runner.get()) 107 if (!nss_task_runner.get())
104 nss_task_runner = base::ThreadTaskRunnerHandle::Get(); 108 nss_task_runner = base::ThreadTaskRunnerHandle::Get();
105 109
106 #if defined(USE_OPENSSL) 110 #if defined(USE_OPENSSL)
107 return scoped_ptr<SSLClientSocket>( 111 return scoped_ptr<SSLClientSocket>(
108 new SSLClientSocketOpenSSL(transport_socket.Pass(), host_and_port, 112 new SSLClientSocketOpenSSL(transport_socket.Pass(), host_and_port,
109 ssl_config, context)); 113 ssl_config, context));
110 #elif defined(USE_NSS) || defined(OS_MACOSX) || defined(OS_WIN) 114 #elif defined(USE_NSS) || defined(OS_MACOSX) || defined(OS_WIN)
111 return scoped_ptr<SSLClientSocket>( 115 return scoped_ptr<SSLClientSocket>(
112 new SSLClientSocketNSS(nss_task_runner.get(), 116 new SSLClientSocketNSS(nss_task_runner.get(),
113 transport_socket.Pass(), 117 transport_socket.Pass(),
114 host_and_port, 118 host_and_port,
115 ssl_config, 119 ssl_config,
120 shi.release(),
116 context)); 121 context));
117 #else 122 #else
118 NOTIMPLEMENTED(); 123 NOTIMPLEMENTED();
119 return scoped_ptr<SSLClientSocket>(); 124 return scoped_ptr<SSLClientSocket>();
120 #endif 125 #endif
121 } 126 }
122 127
123 virtual void ClearSSLSessionCache() OVERRIDE { 128 virtual void ClearSSLSessionCache() OVERRIDE {
124 SSLClientSocket::ClearSessionCache(); 129 SSLClientSocket::ClearSessionCache();
125 } 130 }
126 131
127 private: 132 private:
128 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 133 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
129 scoped_refptr<base::SequencedTaskRunner> nss_thread_task_runner_; 134 scoped_refptr<base::SequencedTaskRunner> nss_thread_task_runner_;
130 }; 135 };
131 136
132 static base::LazyInstance<DefaultClientSocketFactory>::Leaky 137 static base::LazyInstance<DefaultClientSocketFactory>::Leaky
133 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER; 138 g_default_client_socket_factory = LAZY_INSTANCE_INITIALIZER;
134 139
135 } // namespace 140 } // namespace
136 141
137 // static 142 // static
138 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { 143 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() {
139 return g_default_client_socket_factory.Pointer(); 144 return g_default_client_socket_factory.Pointer();
140 } 145 }
141 146
142 } // namespace net 147 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698