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

Side by Side Diff: remoting/protocol/fake_datagram_socket.h

Issue 1273233002: Implement QuicChannel and QuicChannelFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « remoting/protocol/BUILD.gn ('k') | remoting/protocol/fake_datagram_socket.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_
6 #define REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ 6 #define REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 // sockets |a| and |b| must be created and used on the same thread. 34 // sockets |a| and |b| must be created and used on the same thread.
35 class FakeDatagramSocket : public P2PDatagramSocket { 35 class FakeDatagramSocket : public P2PDatagramSocket {
36 public: 36 public:
37 FakeDatagramSocket(); 37 FakeDatagramSocket();
38 ~FakeDatagramSocket() override; 38 ~FakeDatagramSocket() override;
39 39
40 const std::vector<std::string>& written_packets() const { 40 const std::vector<std::string>& written_packets() const {
41 return written_packets_; 41 return written_packets_;
42 } 42 }
43 43
44 // Enables asynchronous Write().
45 void set_async_send(bool async_send) { async_send_ = async_send; }
46
47 // Set error codes for the next Write() call. Once returned the
48 // value is automatically reset to net::OK .
49 void set_next_send_error(int error) { next_send_error_ = error; }
50
44 void AppendInputPacket(const std::string& data); 51 void AppendInputPacket(const std::string& data);
45 52
46 // Current position in the input in number of packets, i.e. number of finished 53 // Current position in the input in number of packets, i.e. number of finished
47 // Recv() calls. 54 // Recv() calls.
48 int input_pos() const { return input_pos_; } 55 int input_pos() const { return input_pos_; }
49 56
50 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets 57 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets
51 // unpairs them. 58 // unpairs them.
52 void PairWith(FakeDatagramSocket* peer_socket); 59 void PairWith(FakeDatagramSocket* peer_socket);
53 60
54 base::WeakPtr<FakeDatagramSocket> GetWeakPtr(); 61 base::WeakPtr<FakeDatagramSocket> GetWeakPtr();
55 62
56 // P2PDatagramSocket implementation. 63 // P2PDatagramSocket implementation.
57 int Recv(const scoped_refptr<net::IOBuffer>& buf, int buf_len, 64 int Recv(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
58 const net::CompletionCallback& callback) override; 65 const net::CompletionCallback& callback) override;
59 int Send(const scoped_refptr<net::IOBuffer>& buf, int buf_len, 66 int Send(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
60 const net::CompletionCallback& callback) override; 67 const net::CompletionCallback& callback) override;
61 68
62 private: 69 private:
63 int CopyReadData(const scoped_refptr<net::IOBuffer>& buf, int buf_len); 70 int CopyReadData(const scoped_refptr<net::IOBuffer>& buf, int buf_len);
64 71
72 void DoAsyncSend(const scoped_refptr<net::IOBuffer>& buf, int buf_len,
73 const net::CompletionCallback& callback);
74 int DoSend(const scoped_refptr<net::IOBuffer>& buf, int buf_len);
75
76 bool async_send_ = false;
77 bool send_pending_ = false;
78 int next_send_error_ = 0;
79
65 base::WeakPtr<FakeDatagramSocket> peer_socket_; 80 base::WeakPtr<FakeDatagramSocket> peer_socket_;
66 81
67 scoped_refptr<net::IOBuffer> read_buffer_; 82 scoped_refptr<net::IOBuffer> read_buffer_;
68 int read_buffer_size_; 83 int read_buffer_size_;
69 net::CompletionCallback read_callback_; 84 net::CompletionCallback read_callback_;
70 85
71 std::vector<std::string> written_packets_; 86 std::vector<std::string> written_packets_;
72 std::vector<std::string> input_packets_; 87 std::vector<std::string> input_packets_;
73 int input_pos_; 88 int input_pos_;
74 89
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 136
122 base::WeakPtrFactory<FakeDatagramChannelFactory> weak_factory_; 137 base::WeakPtrFactory<FakeDatagramChannelFactory> weak_factory_;
123 138
124 DISALLOW_COPY_AND_ASSIGN(FakeDatagramChannelFactory); 139 DISALLOW_COPY_AND_ASSIGN(FakeDatagramChannelFactory);
125 }; 140 };
126 141
127 } // namespace protocol 142 } // namespace protocol
128 } // namespace remoting 143 } // namespace remoting
129 144
130 #endif // REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ 145 #endif // REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_
OLDNEW
« no previous file with comments | « remoting/protocol/BUILD.gn ('k') | remoting/protocol/fake_datagram_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698