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

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

Issue 2994003: Refactor how ClientSocketPoolBaseHelper avoids re-entrancy. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Merge. Created 10 years, 5 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
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/socks_client_socket_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 10
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 return false; 785 return false;
786 socket_.reset(); 786 socket_.reset();
787 handle_ = NULL; 787 handle_ = NULL;
788 user_callback_ = NULL; 788 user_callback_ = NULL;
789 return true; 789 return true;
790 } 790 }
791 791
792 void MockTCPClientSocketPool::MockConnectJob::OnConnect(int rv) { 792 void MockTCPClientSocketPool::MockConnectJob::OnConnect(int rv) {
793 if (!socket_.get()) 793 if (!socket_.get())
794 return; 794 return;
795 if (rv == OK) 795 if (rv == OK) {
796 handle_->set_socket(socket_.release()); 796 handle_->set_socket(socket_.release());
797 else 797 } else {
798 socket_.reset(); 798 socket_.reset();
799 }
799 800
800 handle_ = NULL; 801 handle_ = NULL;
801 802
802 if (user_callback_) { 803 if (user_callback_) {
803 CompletionCallback* callback = user_callback_; 804 CompletionCallback* callback = user_callback_;
804 user_callback_ = NULL; 805 user_callback_ = NULL;
805 callback->Run(rv); 806 callback->Run(rv);
806 } 807 }
807 } 808 }
808 809
(...skipping 17 matching lines...) Expand all
826 const BoundNetLog& net_log) { 827 const BoundNetLog& net_log) {
827 ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket( 828 ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket(
828 AddressList(), net_log.net_log()); 829 AddressList(), net_log.net_log());
829 MockConnectJob* job = new MockConnectJob(socket, handle, callback); 830 MockConnectJob* job = new MockConnectJob(socket, handle, callback);
830 job_list_.push_back(job); 831 job_list_.push_back(job);
831 handle->set_pool_id(1); 832 handle->set_pool_id(1);
832 return job->Connect(); 833 return job->Connect();
833 } 834 }
834 835
835 void MockTCPClientSocketPool::CancelRequest(const std::string& group_name, 836 void MockTCPClientSocketPool::CancelRequest(const std::string& group_name,
836 const ClientSocketHandle* handle) { 837 ClientSocketHandle* handle) {
837 std::vector<MockConnectJob*>::iterator i; 838 std::vector<MockConnectJob*>::iterator i;
838 for (i = job_list_.begin(); i != job_list_.end(); ++i) { 839 for (i = job_list_.begin(); i != job_list_.end(); ++i) {
839 if ((*i)->CancelHandle(handle)) { 840 if ((*i)->CancelHandle(handle)) {
840 cancel_count_++; 841 cancel_count_++;
841 break; 842 break;
842 } 843 }
843 } 844 }
844 } 845 }
845 846
846 void MockTCPClientSocketPool::ReleaseSocket(const std::string& group_name, 847 void MockTCPClientSocketPool::ReleaseSocket(const std::string& group_name,
(...skipping 20 matching lines...) Expand all
867 RequestPriority priority, 868 RequestPriority priority,
868 ClientSocketHandle* handle, 869 ClientSocketHandle* handle,
869 CompletionCallback* callback, 870 CompletionCallback* callback,
870 const BoundNetLog& net_log) { 871 const BoundNetLog& net_log) {
871 return tcp_pool_->RequestSocket(group_name, socket_params, priority, handle, 872 return tcp_pool_->RequestSocket(group_name, socket_params, priority, handle,
872 callback, net_log); 873 callback, net_log);
873 } 874 }
874 875
875 void MockSOCKSClientSocketPool::CancelRequest( 876 void MockSOCKSClientSocketPool::CancelRequest(
876 const std::string& group_name, 877 const std::string& group_name,
877 const ClientSocketHandle* handle) { 878 ClientSocketHandle* handle) {
878 return tcp_pool_->CancelRequest(group_name, handle); 879 return tcp_pool_->CancelRequest(group_name, handle);
879 } 880 }
880 881
881 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, 882 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name,
882 ClientSocket* socket, int id) { 883 ClientSocket* socket, int id) {
883 return tcp_pool_->ReleaseSocket(group_name, socket, id); 884 return tcp_pool_->ReleaseSocket(group_name, socket, id);
884 } 885 }
885 886
886 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} 887 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {}
887 888
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 941
941 const char kSOCKS5OkRequest[] = 942 const char kSOCKS5OkRequest[] =
942 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 943 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
943 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 944 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
944 945
945 const char kSOCKS5OkResponse[] = 946 const char kSOCKS5OkResponse[] =
946 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 947 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
947 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 948 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
948 949
949 } // namespace net 950 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/socks_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698