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

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

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. 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
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // |connect| the result for the connect phase. 337 // |connect| the result for the connect phase.
338 // |reads| the list of MockRead completions. 338 // |reads| the list of MockRead completions.
339 // |writes| the list of MockWrite completions. 339 // |writes| the list of MockWrite completions.
340 // Note: All MockReads and MockWrites must be async. 340 // Note: All MockReads and MockWrites must be async.
341 // Note: The MockRead and MockWrite lists musts end with a EOF 341 // Note: The MockRead and MockWrite lists musts end with a EOF
342 // e.g. a MockRead(true, 0, 0); 342 // e.g. a MockRead(true, 0, 0);
343 OrderedSocketData(const MockConnect& connect, 343 OrderedSocketData(const MockConnect& connect,
344 MockRead* reads, size_t reads_count, 344 MockRead* reads, size_t reads_count,
345 MockWrite* writes, size_t writes_count); 345 MockWrite* writes, size_t writes_count);
346 346
347 void SetCompletionCallback(const CompletionCallback& callback) {
348 callback_ = callback;
349 }
350
351 // Posts a quit message to the current message loop, if one is running. 347 // Posts a quit message to the current message loop, if one is running.
352 void EndLoop(); 348 void EndLoop();
353 349
354 // StaticSocketDataProvider: 350 // StaticSocketDataProvider:
355 virtual MockRead GetNextRead() OVERRIDE; 351 virtual MockRead GetNextRead() OVERRIDE;
356 virtual MockWriteResult OnWrite(const std::string& data) OVERRIDE; 352 virtual MockWriteResult OnWrite(const std::string& data) OVERRIDE;
357 virtual void Reset() OVERRIDE; 353 virtual void Reset() OVERRIDE;
358 virtual void CompleteRead() OVERRIDE; 354 virtual void CompleteRead() OVERRIDE;
359 355
360 private: 356 private:
361 friend class base::RefCounted<OrderedSocketData>; 357 friend class base::RefCounted<OrderedSocketData>;
362 virtual ~OrderedSocketData(); 358 virtual ~OrderedSocketData();
363 359
364 int sequence_number_; 360 int sequence_number_;
365 int loop_stop_stage_; 361 int loop_stop_stage_;
366 CompletionCallback callback_;
367 bool blocked_; 362 bool blocked_;
368 base::WeakPtrFactory<OrderedSocketData> weak_factory_; 363 base::WeakPtrFactory<OrderedSocketData> weak_factory_;
369 }; 364 };
370 365
371 class DeterministicMockTCPClientSocket; 366 class DeterministicMockTCPClientSocket;
372 367
373 // This class gives the user full control over the network activity, 368 // This class gives the user full control over the network activity,
374 // specifically the timing of the COMPLETION of I/O operations. Regardless of 369 // specifically the timing of the COMPLETION of I/O operations. Regardless of
375 // the order in which I/O operations are initiated, this class ensures that they 370 // the order in which I/O operations are initiated, this class ensures that they
376 // complete in the correct order. 371 // complete in the correct order.
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 int max_sockets, 929 int max_sockets,
935 int max_sockets_per_group, 930 int max_sockets_per_group,
936 ClientSocketPoolHistograms* histograms, 931 ClientSocketPoolHistograms* histograms,
937 ClientSocketFactory* socket_factory); 932 ClientSocketFactory* socket_factory);
938 933
939 virtual ~MockTransportClientSocketPool(); 934 virtual ~MockTransportClientSocketPool();
940 935
941 int release_count() const { return release_count_; } 936 int release_count() const { return release_count_; }
942 int cancel_count() const { return cancel_count_; } 937 int cancel_count() const { return cancel_count_; }
943 938
944 // TransportClientSocketPool methods. 939 // TransportClientSocketPool implementation.
945 virtual int RequestSocket(const std::string& group_name, 940 virtual int RequestSocket(const std::string& group_name,
946 const void* socket_params, 941 const void* socket_params,
947 RequestPriority priority, 942 RequestPriority priority,
948 ClientSocketHandle* handle, 943 ClientSocketHandle* handle,
949 OldCompletionCallback* callback, 944 const CompletionCallback& callback,
950 const BoundNetLog& net_log) OVERRIDE; 945 const BoundNetLog& net_log) OVERRIDE;
951 946
952 virtual void CancelRequest(const std::string& group_name, 947 virtual void CancelRequest(const std::string& group_name,
953 ClientSocketHandle* handle) OVERRIDE; 948 ClientSocketHandle* handle) OVERRIDE;
954 virtual void ReleaseSocket(const std::string& group_name, 949 virtual void ReleaseSocket(const std::string& group_name,
955 StreamSocket* socket, int id) OVERRIDE; 950 StreamSocket* socket, int id) OVERRIDE;
956 951
957 private: 952 private:
958 ClientSocketFactory* client_socket_factory_; 953 ClientSocketFactory* client_socket_factory_;
959 ScopedVector<MockConnectJob> job_list_; 954 ScopedVector<MockConnectJob> job_list_;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 class MockSOCKSClientSocketPool : public SOCKSClientSocketPool { 1008 class MockSOCKSClientSocketPool : public SOCKSClientSocketPool {
1014 public: 1009 public:
1015 MockSOCKSClientSocketPool( 1010 MockSOCKSClientSocketPool(
1016 int max_sockets, 1011 int max_sockets,
1017 int max_sockets_per_group, 1012 int max_sockets_per_group,
1018 ClientSocketPoolHistograms* histograms, 1013 ClientSocketPoolHistograms* histograms,
1019 TransportClientSocketPool* transport_pool); 1014 TransportClientSocketPool* transport_pool);
1020 1015
1021 virtual ~MockSOCKSClientSocketPool(); 1016 virtual ~MockSOCKSClientSocketPool();
1022 1017
1023 // SOCKSClientSocketPool methods. 1018 // SOCKSClientSocketPool implementation.
1024 virtual int RequestSocket(const std::string& group_name, 1019 virtual int RequestSocket(const std::string& group_name,
1025 const void* socket_params, 1020 const void* socket_params,
1026 RequestPriority priority, 1021 RequestPriority priority,
1027 ClientSocketHandle* handle, 1022 ClientSocketHandle* handle,
1028 OldCompletionCallback* callback, 1023 const CompletionCallback& callback,
1029 const BoundNetLog& net_log) OVERRIDE; 1024 const BoundNetLog& net_log) OVERRIDE;
1030 1025
1031 virtual void CancelRequest(const std::string& group_name, 1026 virtual void CancelRequest(const std::string& group_name,
1032 ClientSocketHandle* handle) OVERRIDE; 1027 ClientSocketHandle* handle) OVERRIDE;
1033 virtual void ReleaseSocket(const std::string& group_name, 1028 virtual void ReleaseSocket(const std::string& group_name,
1034 StreamSocket* socket, int id) OVERRIDE; 1029 StreamSocket* socket, int id) OVERRIDE;
1035 1030
1036 private: 1031 private:
1037 TransportClientSocketPool* const transport_pool_; 1032 TransportClientSocketPool* const transport_pool_;
1038 1033
1039 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); 1034 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool);
1040 }; 1035 };
1041 1036
1042 // Constants for a successful SOCKS v5 handshake. 1037 // Constants for a successful SOCKS v5 handshake.
1043 extern const char kSOCKS5GreetRequest[]; 1038 extern const char kSOCKS5GreetRequest[];
1044 extern const int kSOCKS5GreetRequestLength; 1039 extern const int kSOCKS5GreetRequestLength;
1045 1040
1046 extern const char kSOCKS5GreetResponse[]; 1041 extern const char kSOCKS5GreetResponse[];
1047 extern const int kSOCKS5GreetResponseLength; 1042 extern const int kSOCKS5GreetResponseLength;
1048 1043
1049 extern const char kSOCKS5OkRequest[]; 1044 extern const char kSOCKS5OkRequest[];
1050 extern const int kSOCKS5OkRequestLength; 1045 extern const int kSOCKS5OkRequestLength;
1051 1046
1052 extern const char kSOCKS5OkResponse[]; 1047 extern const char kSOCKS5OkResponse[];
1053 extern const int kSOCKS5OkResponseLength; 1048 extern const int kSOCKS5OkResponseLength;
1054 1049
1055 } // namespace net 1050 } // namespace net
1056 1051
1057 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ 1052 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698