OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/socket_test_util.h" | 5 #include "net/socket/socket_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 callback, result)); | 1337 callback, result)); |
1338 } | 1338 } |
1339 | 1339 |
1340 void MockUDPClientSocket::RunCallback(const CompletionCallback& callback, | 1340 void MockUDPClientSocket::RunCallback(const CompletionCallback& callback, |
1341 int result) { | 1341 int result) { |
1342 if (!callback.is_null()) | 1342 if (!callback.is_null()) |
1343 callback.Run(result); | 1343 callback.Run(result); |
1344 } | 1344 } |
1345 | 1345 |
1346 TestSocketRequest::TestSocketRequest( | 1346 TestSocketRequest::TestSocketRequest( |
1347 std::vector<TestSocketRequest*>* request_order, | 1347 std::vector<TestSocketRequest*>* request_order, size_t* completion_count) |
1348 size_t* completion_count) | |
1349 : request_order_(request_order), | 1348 : request_order_(request_order), |
1350 completion_count_(completion_count) { | 1349 completion_count_(completion_count), |
| 1350 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( |
| 1351 base::Bind(&TestSocketRequest::OnComplete, base::Unretained(this)))) { |
1351 DCHECK(request_order); | 1352 DCHECK(request_order); |
1352 DCHECK(completion_count); | 1353 DCHECK(completion_count); |
1353 } | 1354 } |
1354 | 1355 |
1355 TestSocketRequest::~TestSocketRequest() { | 1356 TestSocketRequest::~TestSocketRequest() { |
1356 } | 1357 } |
1357 | 1358 |
1358 int TestSocketRequest::WaitForResult() { | 1359 void TestSocketRequest::OnComplete(int result) { |
1359 return callback_.WaitForResult(); | 1360 SetResult(result); |
1360 } | |
1361 | |
1362 void TestSocketRequest::RunWithParams(const Tuple1<int>& params) { | |
1363 callback_.RunWithParams(params); | |
1364 (*completion_count_)++; | 1361 (*completion_count_)++; |
1365 request_order_->push_back(this); | 1362 request_order_->push_back(this); |
1366 } | 1363 } |
1367 | 1364 |
1368 // static | 1365 // static |
1369 const int ClientSocketPoolTest::kIndexOutOfBounds = -1; | 1366 const int ClientSocketPoolTest::kIndexOutOfBounds = -1; |
1370 | 1367 |
1371 // static | 1368 // static |
1372 const int ClientSocketPoolTest::kRequestNotFound = -2; | 1369 const int ClientSocketPoolTest::kRequestNotFound = -2; |
1373 | 1370 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 | 1613 |
1617 const char kSOCKS5OkRequest[] = | 1614 const char kSOCKS5OkRequest[] = |
1618 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1615 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
1619 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1616 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
1620 | 1617 |
1621 const char kSOCKS5OkResponse[] = | 1618 const char kSOCKS5OkResponse[] = |
1622 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1619 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
1623 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1620 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
1624 | 1621 |
1625 } // namespace net | 1622 } // namespace net |
OLD | NEW |