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 "jingle/glue/chrome_async_socket.h" | 5 #include "jingle/glue/chrome_async_socket.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <deque> | 8 #include <deque> |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/message_loop/message_pump_default.h" | 16 #include "base/message_loop/message_pump_default.h" |
17 #include "jingle/glue/resolving_client_socket_factory.h" | 17 #include "jingle/glue/resolving_client_socket_factory.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 address_list_, NULL, net::NetLog::Source()); | 130 address_list_, NULL, net::NetLog::Source()); |
131 } | 131 } |
132 | 132 |
133 scoped_ptr<net::SSLClientSocket> CreateSSLClientSocket( | 133 scoped_ptr<net::SSLClientSocket> CreateSSLClientSocket( |
134 scoped_ptr<net::ClientSocketHandle> transport_socket, | 134 scoped_ptr<net::ClientSocketHandle> transport_socket, |
135 const net::HostPortPair& host_and_port) override { | 135 const net::HostPortPair& host_and_port) override { |
136 net::SSLClientSocketContext context; | 136 net::SSLClientSocketContext context; |
137 context.cert_verifier = cert_verifier_.get(); | 137 context.cert_verifier = cert_verifier_.get(); |
138 context.transport_security_state = transport_security_state_.get(); | 138 context.transport_security_state = transport_security_state_.get(); |
139 return mock_client_socket_factory_->CreateSSLClientSocket( | 139 return mock_client_socket_factory_->CreateSSLClientSocket( |
140 transport_socket.Pass(), host_and_port, ssl_config_, context); | 140 std::move(transport_socket), host_and_port, ssl_config_, context); |
141 } | 141 } |
142 | 142 |
143 private: | 143 private: |
144 scoped_ptr<net::ClientSocketFactory> mock_client_socket_factory_; | 144 scoped_ptr<net::ClientSocketFactory> mock_client_socket_factory_; |
145 net::AddressList address_list_; | 145 net::AddressList address_list_; |
146 net::SSLConfig ssl_config_; | 146 net::SSLConfig ssl_config_; |
147 scoped_ptr<net::CertVerifier> cert_verifier_; | 147 scoped_ptr<net::CertVerifier> cert_verifier_; |
148 scoped_ptr<net::TransportSecurityState> transport_security_state_; | 148 scoped_ptr<net::TransportSecurityState> transport_security_state_; |
149 }; | 149 }; |
150 | 150 |
151 class ChromeAsyncSocketTest | 151 class ChromeAsyncSocketTest |
152 : public testing::Test, | 152 : public testing::Test, |
153 public sigslot::has_slots<> { | 153 public sigslot::has_slots<> { |
154 protected: | 154 protected: |
155 ChromeAsyncSocketTest() | 155 ChromeAsyncSocketTest() |
156 : ssl_socket_data_provider_(net::ASYNC, net::OK), | 156 : ssl_socket_data_provider_(net::ASYNC, net::OK), |
157 addr_("localhost", 35) { | 157 addr_("localhost", 35) { |
158 // GTest death tests execute in a fork()ed but not exec()ed process. | 158 // GTest death tests execute in a fork()ed but not exec()ed process. |
159 // On OS X a CoreFoundation-backed message loop will exit with a | 159 // On OS X a CoreFoundation-backed message loop will exit with a |
160 // __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONA
LITY___YOU_MUST_EXEC__ | 160 // __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONA
LITY___YOU_MUST_EXEC__ |
161 // when called. | 161 // when called. |
162 // Explicitly create a MessagePumpDefault which can run in this enivronment. | 162 // Explicitly create a MessagePumpDefault which can run in this enivronment. |
163 scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault()); | 163 scoped_ptr<base::MessagePump> pump(new base::MessagePumpDefault()); |
164 message_loop_.reset(new base::MessageLoop(pump.Pass())); | 164 message_loop_.reset(new base::MessageLoop(std::move(pump))); |
165 } | 165 } |
166 | 166 |
167 ~ChromeAsyncSocketTest() override {} | 167 ~ChromeAsyncSocketTest() override {} |
168 | 168 |
169 void SetUp() override { | 169 void SetUp() override { |
170 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( | 170 scoped_ptr<net::MockClientSocketFactory> mock_client_socket_factory( |
171 new net::MockClientSocketFactory()); | 171 new net::MockClientSocketFactory()); |
172 mock_client_socket_factory->AddSocketDataProvider( | 172 mock_client_socket_factory->AddSocketDataProvider( |
173 &async_socket_data_provider_); | 173 &async_socket_data_provider_); |
174 mock_client_socket_factory->AddSSLSocketDataProvider( | 174 mock_client_socket_factory->AddSSLSocketDataProvider( |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 message_loop_->RunUntilIdle(); | 1093 message_loop_->RunUntilIdle(); |
1094 | 1094 |
1095 ExpectNoSignal(); | 1095 ExpectNoSignal(); |
1096 | 1096 |
1097 DoSSLCloseOpenedNoError(); | 1097 DoSSLCloseOpenedNoError(); |
1098 } | 1098 } |
1099 | 1099 |
1100 } // namespace | 1100 } // namespace |
1101 | 1101 |
1102 } // namespace jingle_glue | 1102 } // namespace jingle_glue |
OLD | NEW |