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

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

Issue 1459633003: Remove ScopedVector from net/socket tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 (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/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 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 1780
1781 ClientSocketPoolTest::ClientSocketPoolTest() : completion_count_(0) {} 1781 ClientSocketPoolTest::ClientSocketPoolTest() : completion_count_(0) {}
1782 ClientSocketPoolTest::~ClientSocketPoolTest() {} 1782 ClientSocketPoolTest::~ClientSocketPoolTest() {}
1783 1783
1784 int ClientSocketPoolTest::GetOrderOfRequest(size_t index) const { 1784 int ClientSocketPoolTest::GetOrderOfRequest(size_t index) const {
1785 index--; 1785 index--;
1786 if (index >= requests_.size()) 1786 if (index >= requests_.size())
1787 return kIndexOutOfBounds; 1787 return kIndexOutOfBounds;
1788 1788
1789 for (size_t i = 0; i < request_order_.size(); i++) 1789 for (size_t i = 0; i < request_order_.size(); i++)
1790 if (requests_[index] == request_order_[i]) 1790 if (requests_[index].get() == request_order_[i])
1791 return i + 1; 1791 return i + 1;
1792 1792
1793 return kRequestNotFound; 1793 return kRequestNotFound;
1794 } 1794 }
1795 1795
1796 bool ClientSocketPoolTest::ReleaseOneConnection(KeepAlive keep_alive) { 1796 bool ClientSocketPoolTest::ReleaseOneConnection(KeepAlive keep_alive) {
1797 ScopedVector<TestSocketRequest>::iterator i; 1797 for (scoped_ptr<TestSocketRequest>& it : requests_) {
1798 for (i = requests_.begin(); i != requests_.end(); ++i) { 1798 if (it->handle()->is_initialized()) {
1799 if ((*i)->handle()->is_initialized()) {
1800 if (keep_alive == NO_KEEP_ALIVE) 1799 if (keep_alive == NO_KEEP_ALIVE)
1801 (*i)->handle()->socket()->Disconnect(); 1800 it->handle()->socket()->Disconnect();
1802 (*i)->handle()->Reset(); 1801 it->handle()->Reset();
1803 base::RunLoop().RunUntilIdle(); 1802 base::RunLoop().RunUntilIdle();
1804 return true; 1803 return true;
1805 } 1804 }
1806 } 1805 }
1807 return false; 1806 return false;
1808 } 1807 }
1809 1808
1810 void ClientSocketPoolTest::ReleaseAllConnections(KeepAlive keep_alive) { 1809 void ClientSocketPoolTest::ReleaseAllConnections(KeepAlive keep_alive) {
1811 bool released_one; 1810 bool released_one;
1812 do { 1811 do {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 1896
1898 int MockTransportClientSocketPool::RequestSocket( 1897 int MockTransportClientSocketPool::RequestSocket(
1899 const std::string& group_name, const void* socket_params, 1898 const std::string& group_name, const void* socket_params,
1900 RequestPriority priority, ClientSocketHandle* handle, 1899 RequestPriority priority, ClientSocketHandle* handle,
1901 const CompletionCallback& callback, const BoundNetLog& net_log) { 1900 const CompletionCallback& callback, const BoundNetLog& net_log) {
1902 last_request_priority_ = priority; 1901 last_request_priority_ = priority;
1903 scoped_ptr<StreamSocket> socket = 1902 scoped_ptr<StreamSocket> socket =
1904 client_socket_factory_->CreateTransportClientSocket( 1903 client_socket_factory_->CreateTransportClientSocket(
1905 AddressList(), net_log.net_log(), NetLog::Source()); 1904 AddressList(), net_log.net_log(), NetLog::Source());
1906 MockConnectJob* job = new MockConnectJob(socket.Pass(), handle, callback); 1905 MockConnectJob* job = new MockConnectJob(socket.Pass(), handle, callback);
1907 job_list_.push_back(job); 1906 job_list_.push_back(make_scoped_ptr(job));
mmenke 2015/11/19 16:26:12 Other comment applies here, too.
1908 handle->set_pool_id(1); 1907 handle->set_pool_id(1);
1909 return job->Connect(); 1908 return job->Connect();
1910 } 1909 }
1911 1910
1912 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, 1911 void MockTransportClientSocketPool::CancelRequest(const std::string& group_name,
1913 ClientSocketHandle* handle) { 1912 ClientSocketHandle* handle) {
1914 std::vector<MockConnectJob*>::iterator i; 1913 for (scoped_ptr<MockConnectJob>& it : job_list_) {
1915 for (i = job_list_.begin(); i != job_list_.end(); ++i) { 1914 if (it->CancelHandle(handle)) {
1916 if ((*i)->CancelHandle(handle)) {
1917 cancel_count_++; 1915 cancel_count_++;
1918 break; 1916 break;
1919 } 1917 }
1920 } 1918 }
1921 } 1919 }
1922 1920
1923 void MockTransportClientSocketPool::ReleaseSocket( 1921 void MockTransportClientSocketPool::ReleaseSocket(
1924 const std::string& group_name, 1922 const std::string& group_name,
1925 scoped_ptr<StreamSocket> socket, 1923 scoped_ptr<StreamSocket> socket,
1926 int id) { 1924 int id) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 } 2068 }
2071 2069
2072 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { 2070 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) {
2073 int64_t total = 0; 2071 int64_t total = 0;
2074 for (const MockWrite* write = writes; write != writes + writes_size; ++write) 2072 for (const MockWrite* write = writes; write != writes + writes_size; ++write)
2075 total += write->data_len; 2073 total += write->data_len;
2076 return total; 2074 return total;
2077 } 2075 }
2078 2076
2079 } // namespace net 2077 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698