| 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 "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/message_loop/message_loop.h" | |
| 19 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 20 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 21 #include "base/test/scoped_feature_list.h" | 20 #include "base/test/scoped_feature_list.h" |
| 22 #include "base/test/scoped_task_scheduler.h" | |
| 23 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 25 #include "base/values.h" | 23 #include "base/values.h" |
| 26 #include "crypto/rsa_private_key.h" | 24 #include "crypto/rsa_private_key.h" |
| 27 #include "net/base/address_list.h" | 25 #include "net/base/address_list.h" |
| 28 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
| 29 #include "net/base/ip_address.h" | 27 #include "net/base/ip_address.h" |
| 30 #include "net/base/ip_endpoint.h" | 28 #include "net/base/ip_endpoint.h" |
| 31 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 32 #include "net/base/test_completion_callback.h" | 30 #include "net/base/test_completion_callback.h" |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 // False Start is not enabled, so the handshake will not complete because | 1210 // False Start is not enabled, so the handshake will not complete because |
| 1213 // the server second leg is blocked. | 1211 // the server second leg is blocked. |
| 1214 base::RunLoop().RunUntilIdle(); | 1212 base::RunLoop().RunUntilIdle(); |
| 1215 EXPECT_FALSE(callback.have_result()); | 1213 EXPECT_FALSE(callback.have_result()); |
| 1216 } | 1214 } |
| 1217 } | 1215 } |
| 1218 }; | 1216 }; |
| 1219 | 1217 |
| 1220 class SSLClientSocketChannelIDTest : public SSLClientSocketTest { | 1218 class SSLClientSocketChannelIDTest : public SSLClientSocketTest { |
| 1221 protected: | 1219 protected: |
| 1222 SSLClientSocketChannelIDTest() | 1220 SSLClientSocketChannelIDTest() = default; |
| 1223 : scoped_task_scheduler_(base::MessageLoop::current()) {} | |
| 1224 | 1221 |
| 1225 void EnableChannelID() { | 1222 void EnableChannelID() { |
| 1226 channel_id_service_.reset( | 1223 channel_id_service_.reset( |
| 1227 new ChannelIDService(new DefaultChannelIDStore(NULL))); | 1224 new ChannelIDService(new DefaultChannelIDStore(NULL))); |
| 1228 context_.channel_id_service = channel_id_service_.get(); | 1225 context_.channel_id_service = channel_id_service_.get(); |
| 1229 } | 1226 } |
| 1230 | 1227 |
| 1231 void EnableFailingChannelID() { | 1228 void EnableFailingChannelID() { |
| 1232 channel_id_service_.reset( | 1229 channel_id_service_.reset( |
| 1233 new ChannelIDService(new FailingChannelIDStore())); | 1230 new ChannelIDService(new FailingChannelIDStore())); |
| 1234 context_.channel_id_service = channel_id_service_.get(); | 1231 context_.channel_id_service = channel_id_service_.get(); |
| 1235 } | 1232 } |
| 1236 | 1233 |
| 1237 void EnableAsyncFailingChannelID() { | 1234 void EnableAsyncFailingChannelID() { |
| 1238 channel_id_service_.reset( | 1235 channel_id_service_.reset( |
| 1239 new ChannelIDService(new AsyncFailingChannelIDStore())); | 1236 new ChannelIDService(new AsyncFailingChannelIDStore())); |
| 1240 context_.channel_id_service = channel_id_service_.get(); | 1237 context_.channel_id_service = channel_id_service_.get(); |
| 1241 } | 1238 } |
| 1242 | 1239 |
| 1243 private: | 1240 private: |
| 1244 base::test::ScopedTaskScheduler scoped_task_scheduler_; | |
| 1245 std::unique_ptr<ChannelIDService> channel_id_service_; | 1241 std::unique_ptr<ChannelIDService> channel_id_service_; |
| 1246 }; | 1242 }; |
| 1247 | 1243 |
| 1248 // Returns a serialized unencrypted TLS 1.2 alert record for the given alert | 1244 // Returns a serialized unencrypted TLS 1.2 alert record for the given alert |
| 1249 // value. | 1245 // value. |
| 1250 std::string FormatTLS12Alert(uint8_t alert) { | 1246 std::string FormatTLS12Alert(uint8_t alert) { |
| 1251 std::string ret; | 1247 std::string ret; |
| 1252 // ContentType.alert | 1248 // ContentType.alert |
| 1253 ret.push_back(21); | 1249 ret.push_back(21); |
| 1254 // Record-layer version. Assume TLS 1.2. | 1250 // Record-layer version. Assume TLS 1.2. |
| (...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4053 // The read buffer should be released. | 4049 // The read buffer should be released. |
| 4054 StreamSocket::SocketMemoryStats stats; | 4050 StreamSocket::SocketMemoryStats stats; |
| 4055 client->DumpMemoryStats(&stats); | 4051 client->DumpMemoryStats(&stats); |
| 4056 EXPECT_EQ(0u, stats.buffer_size); | 4052 EXPECT_EQ(0u, stats.buffer_size); |
| 4057 EXPECT_EQ(1u, stats.cert_count); | 4053 EXPECT_EQ(1u, stats.cert_count); |
| 4058 EXPECT_LT(0u, stats.cert_size); | 4054 EXPECT_LT(0u, stats.cert_size); |
| 4059 EXPECT_EQ(stats.cert_size, stats.total_size); | 4055 EXPECT_EQ(stats.cert_size, stats.total_size); |
| 4060 } | 4056 } |
| 4061 | 4057 |
| 4062 } // namespace net | 4058 } // namespace net |
| OLD | NEW |