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

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

Issue 8898036: base::Bind: Convert proxy_resolving_client_socket.[cc,h] and deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Possible test fix. Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/deterministic_socket_data_unittest.cc ('k') | net/socket/socket_test_util.cc » ('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) 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 #ifndef NET_SOCKET_SOCKET_TEST_UTIL_H_ 5 #ifndef NET_SOCKET_SOCKET_TEST_UTIL_H_
6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ 6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <cstring> 9 #include <cstring>
10 #include <deque> 10 #include <deque>
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 int pending_buf_len_; 825 int pending_buf_len_;
826 CompletionCallback pending_callback_; 826 CompletionCallback pending_callback_;
827 827
828 BoundNetLog net_log_; 828 BoundNetLog net_log_;
829 829
830 base::WeakPtrFactory<MockUDPClientSocket> weak_factory_; 830 base::WeakPtrFactory<MockUDPClientSocket> weak_factory_;
831 831
832 DISALLOW_COPY_AND_ASSIGN(MockUDPClientSocket); 832 DISALLOW_COPY_AND_ASSIGN(MockUDPClientSocket);
833 }; 833 };
834 834
835 class TestSocketRequest : public CallbackRunner< Tuple1<int> > { 835 class TestSocketRequest : public TestCompletionCallbackBase {
836 public: 836 public:
837 TestSocketRequest( 837 TestSocketRequest(std::vector<TestSocketRequest*>* request_order,
838 std::vector<TestSocketRequest*>* request_order, 838 size_t* completion_count);
839 size_t* completion_count);
840 virtual ~TestSocketRequest(); 839 virtual ~TestSocketRequest();
841 840
842 ClientSocketHandle* handle() { return &handle_; } 841 ClientSocketHandle* handle() { return &handle_; }
843 842
844 int WaitForResult(); 843 const net::CompletionCallback& callback() const { return callback_; }
845 virtual void RunWithParams(const Tuple1<int>& params) OVERRIDE;
846 844
847 private: 845 private:
846 void OnComplete(int result);
847
848 ClientSocketHandle handle_; 848 ClientSocketHandle handle_;
849 std::vector<TestSocketRequest*>* request_order_; 849 std::vector<TestSocketRequest*>* request_order_;
850 size_t* completion_count_; 850 size_t* completion_count_;
851 TestOldCompletionCallback callback_; 851 CompletionCallback callback_;
852
853 DISALLOW_COPY_AND_ASSIGN(TestSocketRequest);
852 }; 854 };
853 855
854 class ClientSocketPoolTest { 856 class ClientSocketPoolTest {
855 public: 857 public:
856 enum KeepAlive { 858 enum KeepAlive {
857 KEEP_ALIVE, 859 KEEP_ALIVE,
858 860
859 // A socket will be disconnected in addition to handle being reset. 861 // A socket will be disconnected in addition to handle being reset.
860 NO_KEEP_ALIVE, 862 NO_KEEP_ALIVE,
861 }; 863 };
862 864
863 static const int kIndexOutOfBounds; 865 static const int kIndexOutOfBounds;
864 static const int kRequestNotFound; 866 static const int kRequestNotFound;
865 867
866 ClientSocketPoolTest(); 868 ClientSocketPoolTest();
867 ~ClientSocketPoolTest(); 869 ~ClientSocketPoolTest();
868 870
869 template <typename PoolType, typename SocketParams> 871 template <typename PoolType, typename SocketParams>
870 int StartRequestUsingPool(PoolType* socket_pool, 872 int StartRequestUsingPool(PoolType* socket_pool,
871 const std::string& group_name, 873 const std::string& group_name,
872 RequestPriority priority, 874 RequestPriority priority,
873 const scoped_refptr<SocketParams>& socket_params) { 875 const scoped_refptr<SocketParams>& socket_params) {
874 DCHECK(socket_pool); 876 DCHECK(socket_pool);
875 TestSocketRequest* request = new TestSocketRequest(&request_order_, 877 TestSocketRequest* request = new TestSocketRequest(&request_order_,
876 &completion_count_); 878 &completion_count_);
877 requests_.push_back(request); 879 requests_.push_back(request);
878 int rv = request->handle()->Init( 880 int rv = request->handle()->Init(
879 group_name, socket_params, priority, request, 881 group_name, socket_params, priority, request->callback(),
880 socket_pool, BoundNetLog()); 882 socket_pool, BoundNetLog());
881 if (rv != ERR_IO_PENDING) 883 if (rv != ERR_IO_PENDING)
882 request_order_.push_back(request); 884 request_order_.push_back(request);
883 return rv; 885 return rv;
884 } 886 }
885 887
886 // Provided there were n requests started, takes |index| in range 1..n 888 // Provided there were n requests started, takes |index| in range 1..n
887 // and returns order in which that request completed, in range 1..n, 889 // and returns order in which that request completed, in range 1..n,
888 // or kIndexOutOfBounds if |index| is out of bounds, or kRequestNotFound 890 // or kIndexOutOfBounds if |index| is out of bounds, or kRequestNotFound
889 // if that request did not complete (for example was canceled). 891 // if that request did not complete (for example was canceled).
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1048
1047 extern const char kSOCKS5OkRequest[]; 1049 extern const char kSOCKS5OkRequest[];
1048 extern const int kSOCKS5OkRequestLength; 1050 extern const int kSOCKS5OkRequestLength;
1049 1051
1050 extern const char kSOCKS5OkResponse[]; 1052 extern const char kSOCKS5OkResponse[];
1051 extern const int kSOCKS5OkResponseLength; 1053 extern const int kSOCKS5OkResponseLength;
1052 1054
1053 } // namespace net 1055 } // namespace net
1054 1056
1055 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ 1057 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/socket/deterministic_socket_data_unittest.cc ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698