Chromium Code Reviews| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 << ": Clearing stop index"; | 332 << ": Clearing stop index"; |
| 333 loop_stop_stage_ = 0; | 333 loop_stop_stage_ = 0; |
| 334 } else { | 334 } else { |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 // Record the sequence_number at which we stopped the loop. | 338 // Record the sequence_number at which we stopped the loop. |
| 339 NET_TRACE(INFO, " *** ") << "Stage " << sequence_number_ | 339 NET_TRACE(INFO, " *** ") << "Stage " << sequence_number_ |
| 340 << ": Posting Quit at read " << read_index(); | 340 << ": Posting Quit at read " << read_index(); |
| 341 loop_stop_stage_ = sequence_number_; | 341 loop_stop_stage_ = sequence_number_; |
| 342 if (!callback_.is_null()) | |
|
awong
2011/12/20 21:51:35
Are we sure we are supposed to remove this?
James Hawkins
2011/12/20 22:50:48
Yes, the variable is completely unused because it'
| |
| 343 callback_.Run(ERR_IO_PENDING); | |
| 344 } | 342 } |
| 345 | 343 |
| 346 MockRead OrderedSocketData::GetNextRead() { | 344 MockRead OrderedSocketData::GetNextRead() { |
| 347 weak_factory_.InvalidateWeakPtrs(); | 345 weak_factory_.InvalidateWeakPtrs(); |
| 348 blocked_ = false; | 346 blocked_ = false; |
| 349 const MockRead& next_read = StaticSocketDataProvider::PeekRead(); | 347 const MockRead& next_read = StaticSocketDataProvider::PeekRead(); |
| 350 if (next_read.sequence_number & MockRead::STOPLOOP) | 348 if (next_read.sequence_number & MockRead::STOPLOOP) |
| 351 EndLoop(); | 349 EndLoop(); |
| 352 if ((next_read.sequence_number & ~MockRead::STOPLOOP) <= | 350 if ((next_read.sequence_number & ~MockRead::STOPLOOP) <= |
| 353 sequence_number_++) { | 351 sequence_number_++) { |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1461 : TransportClientSocketPool(max_sockets, max_sockets_per_group, histograms, | 1459 : TransportClientSocketPool(max_sockets, max_sockets_per_group, histograms, |
| 1462 NULL, NULL, NULL), | 1460 NULL, NULL, NULL), |
| 1463 client_socket_factory_(socket_factory), | 1461 client_socket_factory_(socket_factory), |
| 1464 release_count_(0), | 1462 release_count_(0), |
| 1465 cancel_count_(0) { | 1463 cancel_count_(0) { |
| 1466 } | 1464 } |
| 1467 | 1465 |
| 1468 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} | 1466 MockTransportClientSocketPool::~MockTransportClientSocketPool() {} |
| 1469 | 1467 |
| 1470 int MockTransportClientSocketPool::RequestSocket( | 1468 int MockTransportClientSocketPool::RequestSocket( |
| 1471 const std::string& group_name, | 1469 const std::string& group_name, const void* socket_params, |
| 1472 const void* socket_params, | 1470 RequestPriority priority, ClientSocketHandle* handle, |
| 1473 RequestPriority priority, | 1471 const CompletionCallback& callback, const BoundNetLog& net_log) { |
| 1474 ClientSocketHandle* handle, | |
| 1475 OldCompletionCallback* callback, | |
| 1476 const BoundNetLog& net_log) { | |
| 1477 StreamSocket* socket = client_socket_factory_->CreateTransportClientSocket( | 1472 StreamSocket* socket = client_socket_factory_->CreateTransportClientSocket( |
| 1478 AddressList(), net_log.net_log(), net::NetLog::Source()); | 1473 AddressList(), net_log.net_log(), net::NetLog::Source()); |
| 1479 CompletionCallback cb; | 1474 MockConnectJob* job = new MockConnectJob(socket, handle, callback); |
| 1480 if (callback) { | |
| 1481 cb = base::Bind(&OldCompletionCallback::Run<int>, | |
| 1482 base::Unretained(callback)); | |
| 1483 } | |
| 1484 MockConnectJob* job = new MockConnectJob(socket, handle, cb); | |
| 1485 job_list_.push_back(job); | 1475 job_list_.push_back(job); |
| 1486 handle->set_pool_id(1); | 1476 handle->set_pool_id(1); |
| 1487 return job->Connect(); | 1477 return job->Connect(); |
| 1488 } | 1478 } |
| 1489 | 1479 |
| 1490 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, | 1480 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, |
| 1491 ClientSocketHandle* handle) { | 1481 ClientSocketHandle* handle) { |
| 1492 std::vector<MockConnectJob*>::iterator i; | 1482 std::vector<MockConnectJob*>::iterator i; |
| 1493 for (i = job_list_.begin(); i != job_list_.end(); ++i) { | 1483 for (i = job_list_.begin(); i != job_list_.end(); ++i) { |
| 1494 if ((*i)->CancelHandle(handle)) { | 1484 if ((*i)->CancelHandle(handle)) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1573 int max_sockets_per_group, | 1563 int max_sockets_per_group, |
| 1574 ClientSocketPoolHistograms* histograms, | 1564 ClientSocketPoolHistograms* histograms, |
| 1575 TransportClientSocketPool* transport_pool) | 1565 TransportClientSocketPool* transport_pool) |
| 1576 : SOCKSClientSocketPool(max_sockets, max_sockets_per_group, histograms, | 1566 : SOCKSClientSocketPool(max_sockets, max_sockets_per_group, histograms, |
| 1577 NULL, transport_pool, NULL), | 1567 NULL, transport_pool, NULL), |
| 1578 transport_pool_(transport_pool) { | 1568 transport_pool_(transport_pool) { |
| 1579 } | 1569 } |
| 1580 | 1570 |
| 1581 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} | 1571 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} |
| 1582 | 1572 |
| 1583 int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, | 1573 int MockSOCKSClientSocketPool::RequestSocket( |
| 1584 const void* socket_params, | 1574 const std::string& group_name, const void* socket_params, |
| 1585 RequestPriority priority, | 1575 RequestPriority priority, ClientSocketHandle* handle, |
| 1586 ClientSocketHandle* handle, | 1576 const CompletionCallback& callback, const BoundNetLog& net_log) { |
| 1587 OldCompletionCallback* callback, | 1577 return transport_pool_->RequestSocket( |
| 1588 const BoundNetLog& net_log) { | 1578 group_name, socket_params, priority, handle, callback, net_log); |
| 1589 return transport_pool_->RequestSocket(group_name, | |
| 1590 socket_params, | |
| 1591 priority, | |
| 1592 handle, | |
| 1593 callback, | |
| 1594 net_log); | |
| 1595 } | 1579 } |
| 1596 | 1580 |
| 1597 void MockSOCKSClientSocketPool::CancelRequest( | 1581 void MockSOCKSClientSocketPool::CancelRequest( |
| 1598 const std::string& group_name, | 1582 const std::string& group_name, |
| 1599 ClientSocketHandle* handle) { | 1583 ClientSocketHandle* handle) { |
| 1600 return transport_pool_->CancelRequest(group_name, handle); | 1584 return transport_pool_->CancelRequest(group_name, handle); |
| 1601 } | 1585 } |
| 1602 | 1586 |
| 1603 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, | 1587 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, |
| 1604 StreamSocket* socket, int id) { | 1588 StreamSocket* socket, int id) { |
| 1605 return transport_pool_->ReleaseSocket(group_name, socket, id); | 1589 return transport_pool_->ReleaseSocket(group_name, socket, id); |
| 1606 } | 1590 } |
| 1607 | 1591 |
| 1608 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; | 1592 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; |
| 1609 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); | 1593 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); |
| 1610 | 1594 |
| 1611 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; | 1595 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; |
| 1612 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); | 1596 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); |
| 1613 | 1597 |
| 1614 const char kSOCKS5OkRequest[] = | 1598 const char kSOCKS5OkRequest[] = |
| 1615 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 1599 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
| 1616 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 1600 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
| 1617 | 1601 |
| 1618 const char kSOCKS5OkResponse[] = | 1602 const char kSOCKS5OkResponse[] = |
| 1619 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 1603 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
| 1620 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 1604 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
| 1621 | 1605 |
| 1622 } // namespace net | 1606 } // namespace net |
| OLD | NEW |