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

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

Issue 1892323002: Change scoped_ptr to std::unique_ptr in //net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/websocket_transport_client_socket_pool.h" 5 #include "net/socket/websocket_transport_client_socket_pool.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 bool ReleaseOneConnection(ClientSocketPoolTest::KeepAlive keep_alive) { 93 bool ReleaseOneConnection(ClientSocketPoolTest::KeepAlive keep_alive) {
94 return test_base_.ReleaseOneConnection(keep_alive); 94 return test_base_.ReleaseOneConnection(keep_alive);
95 } 95 }
96 96
97 void ReleaseAllConnections(ClientSocketPoolTest::KeepAlive keep_alive) { 97 void ReleaseAllConnections(ClientSocketPoolTest::KeepAlive keep_alive) {
98 test_base_.ReleaseAllConnections(keep_alive); 98 test_base_.ReleaseAllConnections(keep_alive);
99 } 99 }
100 100
101 TestSocketRequest* request(int i) { return test_base_.request(i); } 101 TestSocketRequest* request(int i) { return test_base_.request(i); }
102 102
103 std::vector<scoped_ptr<TestSocketRequest>>* requests() { 103 std::vector<std::unique_ptr<TestSocketRequest>>* requests() {
104 return test_base_.requests(); 104 return test_base_.requests();
105 } 105 }
106 size_t completion_count() const { return test_base_.completion_count(); } 106 size_t completion_count() const { return test_base_.completion_count(); }
107 107
108 TestNetLog net_log_; 108 TestNetLog net_log_;
109 scoped_refptr<TransportSocketParams> params_; 109 scoped_refptr<TransportSocketParams> params_;
110 scoped_ptr<MockHostResolver> host_resolver_; 110 std::unique_ptr<MockHostResolver> host_resolver_;
111 MockTransportClientSocketFactory client_socket_factory_; 111 MockTransportClientSocketFactory client_socket_factory_;
112 WebSocketTransportClientSocketPool pool_; 112 WebSocketTransportClientSocketPool pool_;
113 ClientSocketPoolTest test_base_; 113 ClientSocketPoolTest test_base_;
114 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_; 114 ScopedWebSocketEndpointZeroUnlockDelay zero_unlock_delay_;
115 115
116 private: 116 private:
117 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPoolTest); 117 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPoolTest);
118 }; 118 };
119 119
120 TEST_F(WebSocketTransportClientSocketPoolTest, Basic) { 120 TEST_F(WebSocketTransportClientSocketPoolTest, Basic) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_EQ(OK, request(0)->WaitForResult()); 456 EXPECT_EQ(OK, request(0)->WaitForResult());
457 EXPECT_FALSE(request(1)->handle()->is_initialized()); 457 EXPECT_FALSE(request(1)->handle()->is_initialized());
458 request(0)->handle()->Reset(); 458 request(0)->handle()->Reset();
459 RunUntilIdle(); 459 RunUntilIdle();
460 EXPECT_TRUE(request(1)->handle()->is_initialized()); 460 EXPECT_TRUE(request(1)->handle()->is_initialized());
461 } 461 }
462 462
463 // The lock on the endpoint is released when a ClientSocketHandle is deleted. 463 // The lock on the endpoint is released when a ClientSocketHandle is deleted.
464 TEST_F(WebSocketTransportClientSocketPoolTest, LockReleasedOnHandleDelete) { 464 TEST_F(WebSocketTransportClientSocketPoolTest, LockReleasedOnHandleDelete) {
465 TestCompletionCallback callback; 465 TestCompletionCallback callback;
466 scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle); 466 std::unique_ptr<ClientSocketHandle> handle(new ClientSocketHandle);
467 int rv = 467 int rv =
468 handle->Init("a", params_, LOW, ClientSocketPool::RespectLimits::ENABLED, 468 handle->Init("a", params_, LOW, ClientSocketPool::RespectLimits::ENABLED,
469 callback.callback(), &pool_, BoundNetLog()); 469 callback.callback(), &pool_, BoundNetLog());
470 EXPECT_EQ(ERR_IO_PENDING, rv); 470 EXPECT_EQ(ERR_IO_PENDING, rv);
471 471
472 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); 472 EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority));
473 EXPECT_EQ(OK, callback.WaitForResult()); 473 EXPECT_EQ(OK, callback.WaitForResult());
474 EXPECT_FALSE(request(0)->handle()->is_initialized()); 474 EXPECT_FALSE(request(0)->handle()->is_initialized());
475 handle.reset(); 475 handle.reset();
476 RunUntilIdle(); 476 RunUntilIdle();
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 EXPECT_EQ(OK, request(1)->WaitForResult()); 1094 EXPECT_EQ(OK, request(1)->WaitForResult());
1095 // Third socket should still be waiting for endpoint. 1095 // Third socket should still be waiting for endpoint.
1096 ASSERT_FALSE(request(2)->handle()->is_initialized()); 1096 ASSERT_FALSE(request(2)->handle()->is_initialized());
1097 EXPECT_EQ(LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET, 1097 EXPECT_EQ(LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET,
1098 request(2)->handle()->GetLoadState()); 1098 request(2)->handle()->GetLoadState());
1099 } 1099 }
1100 1100
1101 } // namespace 1101 } // namespace
1102 1102
1103 } // namespace net 1103 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/websocket_transport_client_socket_pool.cc ('k') | net/socket/websocket_transport_connect_sub_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698