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

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

Issue 9959033: Move NextProto enum to a new file net/socket/next_proto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unwrap short lines. Created 8 years, 8 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 | Annotate | Revision Log
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 #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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 DISALLOW_COPY_AND_ASSIGN(DynamicSocketDataProvider); 263 DISALLOW_COPY_AND_ASSIGN(DynamicSocketDataProvider);
264 }; 264 };
265 265
266 // SSLSocketDataProviders only need to keep track of the return code from calls 266 // SSLSocketDataProviders only need to keep track of the return code from calls
267 // to Connect(). 267 // to Connect().
268 struct SSLSocketDataProvider { 268 struct SSLSocketDataProvider {
269 SSLSocketDataProvider(IoMode mode, int result); 269 SSLSocketDataProvider(IoMode mode, int result);
270 ~SSLSocketDataProvider(); 270 ~SSLSocketDataProvider();
271 271
272 void SetNextProto(SSLClientSocket::NextProto proto); 272 void SetNextProto(NextProto proto);
273 273
274 MockConnect connect; 274 MockConnect connect;
275 SSLClientSocket::NextProtoStatus next_proto_status; 275 SSLClientSocket::NextProtoStatus next_proto_status;
276 std::string next_proto; 276 std::string next_proto;
277 std::string server_protos; 277 std::string server_protos;
278 bool was_npn_negotiated; 278 bool was_npn_negotiated;
279 SSLClientSocket::NextProto protocol_negotiated; 279 NextProto protocol_negotiated;
280 bool client_cert_sent; 280 bool client_cert_sent;
281 SSLCertRequestInfo* cert_request_info; 281 SSLCertRequestInfo* cert_request_info;
282 scoped_refptr<X509Certificate> cert; 282 scoped_refptr<X509Certificate> cert;
283 SSLClientCertType domain_bound_cert_type; 283 SSLClientCertType domain_bound_cert_type;
284 ServerBoundCertService* server_bound_cert_service; 284 ServerBoundCertService* server_bound_cert_service;
285 }; 285 };
286 286
287 // A DataProvider where the client must write a request before the reads (e.g. 287 // A DataProvider where the client must write a request before the reads (e.g.
288 // the response) will complete. 288 // the response) will complete.
289 class DelayedSocketData : public StaticSocketDataProvider { 289 class DelayedSocketData : public StaticSocketDataProvider {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 // SSLClientSocket implementation. 594 // SSLClientSocket implementation.
595 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; 595 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
596 virtual void GetSSLCertRequestInfo( 596 virtual void GetSSLCertRequestInfo(
597 SSLCertRequestInfo* cert_request_info) OVERRIDE; 597 SSLCertRequestInfo* cert_request_info) OVERRIDE;
598 virtual int ExportKeyingMaterial(const base::StringPiece& label, 598 virtual int ExportKeyingMaterial(const base::StringPiece& label,
599 bool has_context, 599 bool has_context,
600 const base::StringPiece& context, 600 const base::StringPiece& context,
601 unsigned char* out, 601 unsigned char* out,
602 unsigned int outlen) OVERRIDE; 602 unsigned int outlen) OVERRIDE;
603 virtual NextProtoStatus GetNextProto(std::string* proto, 603 virtual SSLClientSocket::NextProtoStatus GetNextProto(std::string* proto,
wtc 2012/03/30 20:53:51 Why is it necessary to add SSLClientSocket:: to th
Ryan Hamilton 2012/03/30 21:12:13 Whoops, I cooked up a script to help me with this
604 std::string* server_protos) OVERRIDE; 604 std::string* server_protos) OVERRIDE;
605 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; 605 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE;
606 606
607 protected: 607 protected:
608 virtual ~MockClientSocket(); 608 virtual ~MockClientSocket();
609 void RunCallbackAsync(const CompletionCallback& callback, int result); 609 void RunCallbackAsync(const CompletionCallback& callback, int result);
610 void RunCallback(const CompletionCallback& callback, int result); 610 void RunCallback(const CompletionCallback& callback, int result);
611 611
612 base::WeakPtrFactory<MockClientSocket> weak_factory_; 612 base::WeakPtrFactory<MockClientSocket> weak_factory_;
613 613
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 virtual bool IsConnected() const OVERRIDE; 739 virtual bool IsConnected() const OVERRIDE;
740 virtual bool WasEverUsed() const OVERRIDE; 740 virtual bool WasEverUsed() const OVERRIDE;
741 virtual bool UsingTCPFastOpen() const OVERRIDE; 741 virtual bool UsingTCPFastOpen() const OVERRIDE;
742 virtual int64 NumBytesRead() const OVERRIDE; 742 virtual int64 NumBytesRead() const OVERRIDE;
743 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; 743 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
744 744
745 // SSLClientSocket implementation. 745 // SSLClientSocket implementation.
746 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; 746 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
747 virtual void GetSSLCertRequestInfo( 747 virtual void GetSSLCertRequestInfo(
748 SSLCertRequestInfo* cert_request_info) OVERRIDE; 748 SSLCertRequestInfo* cert_request_info) OVERRIDE;
749 virtual NextProtoStatus GetNextProto(std::string* proto, 749 virtual SSLClientSocket::NextProtoStatus GetNextProto(std::string* proto,
750 std::string* server_protos) OVERRIDE; 750 std::string* server_protos) OVERRIDE;
751 virtual bool was_npn_negotiated() const OVERRIDE; 751 virtual bool was_npn_negotiated() const OVERRIDE;
752 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; 752 virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE;
753 virtual SSLClientSocket::NextProto protocol_negotiated() const OVERRIDE; 753 virtual NextProto protocol_negotiated() const OVERRIDE;
754 virtual void set_protocol_negotiated( 754 virtual void set_protocol_negotiated(
755 SSLClientSocket::NextProto protocol_negotiated) OVERRIDE; 755 NextProto protocol_negotiated) OVERRIDE;
756 756
757 // This MockSocket does not implement the manual async IO feature. 757 // This MockSocket does not implement the manual async IO feature.
758 virtual void OnReadComplete(const MockRead& data) OVERRIDE; 758 virtual void OnReadComplete(const MockRead& data) OVERRIDE;
759 759
760 virtual bool WasDomainBoundCertSent() const OVERRIDE; 760 virtual bool WasDomainBoundCertSent() const OVERRIDE;
761 virtual SSLClientCertType domain_bound_cert_type() const OVERRIDE; 761 virtual SSLClientCertType domain_bound_cert_type() const OVERRIDE;
762 virtual SSLClientCertType set_domain_bound_cert_type( 762 virtual SSLClientCertType set_domain_bound_cert_type(
763 SSLClientCertType type) OVERRIDE; 763 SSLClientCertType type) OVERRIDE;
764 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; 764 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE;
765 765
766 private: 766 private:
767 static void ConnectCallback(MockSSLClientSocket *ssl_client_socket, 767 static void ConnectCallback(MockSSLClientSocket *ssl_client_socket,
768 const CompletionCallback& callback, 768 const CompletionCallback& callback,
769 int rv); 769 int rv);
770 770
771 scoped_ptr<ClientSocketHandle> transport_; 771 scoped_ptr<ClientSocketHandle> transport_;
772 SSLSocketDataProvider* data_; 772 SSLSocketDataProvider* data_;
773 bool is_npn_state_set_; 773 bool is_npn_state_set_;
774 bool new_npn_value_; 774 bool new_npn_value_;
775 bool was_used_to_convey_data_; 775 bool was_used_to_convey_data_;
776 bool is_protocol_negotiated_set_; 776 bool is_protocol_negotiated_set_;
777 SSLClientSocket::NextProto protocol_negotiated_; 777 NextProto protocol_negotiated_;
778 }; 778 };
779 779
780 class MockUDPClientSocket : public DatagramClientSocket, 780 class MockUDPClientSocket : public DatagramClientSocket,
781 public AsyncSocket { 781 public AsyncSocket {
782 public: 782 public:
783 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log); 783 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log);
784 virtual ~MockUDPClientSocket(); 784 virtual ~MockUDPClientSocket();
785 785
786 // Socket implementation. 786 // Socket implementation.
787 virtual int Read(IOBuffer* buf, int buf_len, 787 virtual int Read(IOBuffer* buf, int buf_len,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 1043
1044 extern const char kSOCKS5OkRequest[]; 1044 extern const char kSOCKS5OkRequest[];
1045 extern const int kSOCKS5OkRequestLength; 1045 extern const int kSOCKS5OkRequestLength;
1046 1046
1047 extern const char kSOCKS5OkResponse[]; 1047 extern const char kSOCKS5OkResponse[];
1048 extern const int kSOCKS5OkResponseLength; 1048 extern const int kSOCKS5OkResponseLength;
1049 1049
1050 } // namespace net 1050 } // namespace net
1051 1051
1052 #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