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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 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
« no previous file with comments | « net/socket/socket_descriptor.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) 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 7
8 #include <stddef.h>
8 #include <stdint.h> 9 #include <stdint.h>
9 10
10 #include <cstring> 11 #include <cstring>
11 #include <deque> 12 #include <deque>
12 #include <string> 13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/basictypes.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/scoped_vector.h" 21 #include "base/memory/scoped_vector.h"
21 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
22 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "net/base/address_list.h" 25 #include "net/base/address_list.h"
25 #include "net/base/io_buffer.h" 26 #include "net/base/io_buffer.h"
26 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
27 #include "net/base/test_completion_callback.h" 28 #include "net/base/test_completion_callback.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 const AddressList& addresses, 511 const AddressList& addresses,
511 NetLog* net_log, 512 NetLog* net_log,
512 const NetLog::Source& source) override; 513 const NetLog::Source& source) override;
513 scoped_ptr<SSLClientSocket> CreateSSLClientSocket( 514 scoped_ptr<SSLClientSocket> CreateSSLClientSocket(
514 scoped_ptr<ClientSocketHandle> transport_socket, 515 scoped_ptr<ClientSocketHandle> transport_socket,
515 const HostPortPair& host_and_port, 516 const HostPortPair& host_and_port,
516 const SSLConfig& ssl_config, 517 const SSLConfig& ssl_config,
517 const SSLClientSocketContext& context) override; 518 const SSLClientSocketContext& context) override;
518 void ClearSSLSessionCache() override; 519 void ClearSSLSessionCache() override;
519 520
520 const std::vector<uint16>& udp_client_socket_ports() const { 521 const std::vector<uint16_t>& udp_client_socket_ports() const {
521 return udp_client_socket_ports_; 522 return udp_client_socket_ports_;
522 } 523 }
523 524
524 private: 525 private:
525 SocketDataProviderArray<SocketDataProvider> mock_data_; 526 SocketDataProviderArray<SocketDataProvider> mock_data_;
526 SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_; 527 SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_;
527 std::vector<uint16> udp_client_socket_ports_; 528 std::vector<uint16_t> udp_client_socket_ports_;
528 529
529 DISALLOW_COPY_AND_ASSIGN(MockClientSocketFactory); 530 DISALLOW_COPY_AND_ASSIGN(MockClientSocketFactory);
530 }; 531 };
531 532
532 class MockClientSocket : public SSLClientSocket { 533 class MockClientSocket : public SSLClientSocket {
533 public: 534 public:
534 // Value returned by GetTLSUniqueChannelBinding(). 535 // Value returned by GetTLSUniqueChannelBinding().
535 static const char kTlsUnique[]; 536 static const char kTlsUnique[];
536 537
537 // The BoundNetLog is needed to test LoadTimingInfo, which uses NetLog IDs as 538 // The BoundNetLog is needed to test LoadTimingInfo, which uses NetLog IDs as
538 // unique socket IDs. 539 // unique socket IDs.
539 explicit MockClientSocket(const BoundNetLog& net_log); 540 explicit MockClientSocket(const BoundNetLog& net_log);
540 541
541 // Socket implementation. 542 // Socket implementation.
542 int Read(IOBuffer* buf, 543 int Read(IOBuffer* buf,
543 int buf_len, 544 int buf_len,
544 const CompletionCallback& callback) override = 0; 545 const CompletionCallback& callback) override = 0;
545 int Write(IOBuffer* buf, 546 int Write(IOBuffer* buf,
546 int buf_len, 547 int buf_len,
547 const CompletionCallback& callback) override = 0; 548 const CompletionCallback& callback) override = 0;
548 int SetReceiveBufferSize(int32 size) override; 549 int SetReceiveBufferSize(int32_t size) override;
549 int SetSendBufferSize(int32 size) override; 550 int SetSendBufferSize(int32_t size) override;
550 551
551 // StreamSocket implementation. 552 // StreamSocket implementation.
552 int Connect(const CompletionCallback& callback) override = 0; 553 int Connect(const CompletionCallback& callback) override = 0;
553 void Disconnect() override; 554 void Disconnect() override;
554 bool IsConnected() const override; 555 bool IsConnected() const override;
555 bool IsConnectedAndIdle() const override; 556 bool IsConnectedAndIdle() const override;
556 int GetPeerAddress(IPEndPoint* address) const override; 557 int GetPeerAddress(IPEndPoint* address) const override;
557 int GetLocalAddress(IPEndPoint* address) const override; 558 int GetLocalAddress(IPEndPoint* address) const override;
558 const BoundNetLog& NetLog() const override; 559 const BoundNetLog& NetLog() const override;
559 void SetSubresourceSpeculation() override {} 560 void SetSubresourceSpeculation() override {}
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log); 717 MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log);
717 ~MockUDPClientSocket() override; 718 ~MockUDPClientSocket() override;
718 719
719 // Socket implementation. 720 // Socket implementation.
720 int Read(IOBuffer* buf, 721 int Read(IOBuffer* buf,
721 int buf_len, 722 int buf_len,
722 const CompletionCallback& callback) override; 723 const CompletionCallback& callback) override;
723 int Write(IOBuffer* buf, 724 int Write(IOBuffer* buf,
724 int buf_len, 725 int buf_len,
725 const CompletionCallback& callback) override; 726 const CompletionCallback& callback) override;
726 int SetReceiveBufferSize(int32 size) override; 727 int SetReceiveBufferSize(int32_t size) override;
727 int SetSendBufferSize(int32 size) override; 728 int SetSendBufferSize(int32_t size) override;
728 729
729 // DatagramSocket implementation. 730 // DatagramSocket implementation.
730 void Close() override; 731 void Close() override;
731 int GetPeerAddress(IPEndPoint* address) const override; 732 int GetPeerAddress(IPEndPoint* address) const override;
732 int GetLocalAddress(IPEndPoint* address) const override; 733 int GetLocalAddress(IPEndPoint* address) const override;
733 const BoundNetLog& NetLog() const override; 734 const BoundNetLog& NetLog() const override;
734 735
735 // DatagramClientSocket implementation. 736 // DatagramClientSocket implementation.
736 int BindToNetwork(NetworkChangeNotifier::NetworkHandle network) override; 737 int BindToNetwork(NetworkChangeNotifier::NetworkHandle network) override;
737 int BindToDefaultNetwork() override; 738 int BindToDefaultNetwork() override;
738 NetworkChangeNotifier::NetworkHandle GetBoundNetwork() override; 739 NetworkChangeNotifier::NetworkHandle GetBoundNetwork() override;
739 int Connect(const IPEndPoint& address) override; 740 int Connect(const IPEndPoint& address) override;
740 741
741 // AsyncSocket implementation. 742 // AsyncSocket implementation.
742 void OnReadComplete(const MockRead& data) override; 743 void OnReadComplete(const MockRead& data) override;
743 void OnWriteComplete(int rv) override; 744 void OnWriteComplete(int rv) override;
744 void OnConnectComplete(const MockConnect& data) override; 745 void OnConnectComplete(const MockConnect& data) override;
745 void OnDataProviderDestroyed() override; 746 void OnDataProviderDestroyed() override;
746 747
747 void set_source_port(uint16 port) { source_port_ = port;} 748 void set_source_port(uint16_t port) { source_port_ = port; }
748 uint16 source_port() const { return source_port_; } 749 uint16_t source_port() const { return source_port_; }
749 750
750 private: 751 private:
751 int CompleteRead(); 752 int CompleteRead();
752 753
753 void RunCallbackAsync(const CompletionCallback& callback, int result); 754 void RunCallbackAsync(const CompletionCallback& callback, int result);
754 void RunCallback(const CompletionCallback& callback, int result); 755 void RunCallback(const CompletionCallback& callback, int result);
755 756
756 bool connected_; 757 bool connected_;
757 SocketDataProvider* data_; 758 SocketDataProvider* data_;
758 int read_offset_; 759 int read_offset_;
759 MockRead read_data_; 760 MockRead read_data_;
760 bool need_read_data_; 761 bool need_read_data_;
761 uint16 source_port_; // Ephemeral source port. 762 uint16_t source_port_; // Ephemeral source port.
762 763
763 // Address of the "remote" peer we're connected to. 764 // Address of the "remote" peer we're connected to.
764 IPEndPoint peer_addr_; 765 IPEndPoint peer_addr_;
765 766
766 // While an asynchronous IO is pending, we save our user-buffer state. 767 // While an asynchronous IO is pending, we save our user-buffer state.
767 scoped_refptr<IOBuffer> pending_read_buf_; 768 scoped_refptr<IOBuffer> pending_read_buf_;
768 int pending_read_buf_len_; 769 int pending_read_buf_len_;
769 CompletionCallback pending_read_callback_; 770 CompletionCallback pending_read_callback_;
770 CompletionCallback pending_write_callback_; 771 CompletionCallback pending_write_callback_;
771 772
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 987
987 // Helper function to get the total data size of the MockReads in |reads|. 988 // Helper function to get the total data size of the MockReads in |reads|.
988 int64_t CountReadBytes(const MockRead reads[], size_t reads_size); 989 int64_t CountReadBytes(const MockRead reads[], size_t reads_size);
989 990
990 // Helper function to get the total data size of the MockWrites in |writes|. 991 // Helper function to get the total data size of the MockWrites in |writes|.
991 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size); 992 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size);
992 993
993 } // namespace net 994 } // namespace net
994 995
995 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ 996 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/socket/socket_descriptor.cc ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698