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

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

Issue 10836030: Add unittests for BufferedSocketWriter and fix some bugs in that code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/buffered_socket_writer_unittest.cc ('k') | remoting/protocol/fake_session.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 REMOTING_PROTOCOL_FAKE_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_
6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 // PairWith() method, e.g.: a->PairWith(b). After this all data 33 // PairWith() method, e.g.: a->PairWith(b). After this all data
34 // written to |a| can be read from |b| and vica versa. Two connected 34 // written to |a| can be read from |b| and vica versa. Two connected
35 // sockets |a| and |b| must be created and used on the same thread. 35 // sockets |a| and |b| must be created and used on the same thread.
36 class FakeSocket : public net::StreamSocket { 36 class FakeSocket : public net::StreamSocket {
37 public: 37 public:
38 FakeSocket(); 38 FakeSocket();
39 virtual ~FakeSocket(); 39 virtual ~FakeSocket();
40 40
41 const std::string& written_data() const { return written_data_; } 41 const std::string& written_data() const { return written_data_; }
42 42
43 void set_write_limit(int write_limit) { write_limit_ = write_limit; }
44 void set_async_write(bool async_write) { async_write_ = async_write; }
45 void set_next_write_error(int error) { next_write_error_ = error; }
43 void set_next_read_error(int error) { next_read_error_ = error; } 46 void set_next_read_error(int error) { next_read_error_ = error; }
44 void AppendInputData(const std::vector<char>& data); 47 void AppendInputData(const std::vector<char>& data);
45 void PairWith(FakeSocket* peer_socket); 48 void PairWith(FakeSocket* peer_socket);
46 int input_pos() const { return input_pos_; } 49 int input_pos() const { return input_pos_; }
47 bool read_pending() const { return read_pending_; } 50 bool read_pending() const { return read_pending_; }
48 51
49 // net::Socket implementation. 52 // net::Socket implementation.
50 virtual int Read(net::IOBuffer* buf, int buf_len, 53 virtual int Read(net::IOBuffer* buf, int buf_len,
51 const net::CompletionCallback& callback) OVERRIDE; 54 const net::CompletionCallback& callback) OVERRIDE;
52 virtual int Write(net::IOBuffer* buf, int buf_len, 55 virtual int Write(net::IOBuffer* buf, int buf_len,
(...skipping 14 matching lines...) Expand all
67 virtual void SetOmniboxSpeculation() OVERRIDE; 70 virtual void SetOmniboxSpeculation() OVERRIDE;
68 virtual bool WasEverUsed() const OVERRIDE; 71 virtual bool WasEverUsed() const OVERRIDE;
69 virtual bool UsingTCPFastOpen() const OVERRIDE; 72 virtual bool UsingTCPFastOpen() const OVERRIDE;
70 virtual int64 NumBytesRead() const OVERRIDE; 73 virtual int64 NumBytesRead() const OVERRIDE;
71 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; 74 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
72 virtual bool WasNpnNegotiated() const OVERRIDE; 75 virtual bool WasNpnNegotiated() const OVERRIDE;
73 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; 76 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE;
74 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) OVERRIDE; 77 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) OVERRIDE;
75 78
76 private: 79 private:
80 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len,
81 const net::CompletionCallback& callback);
82 void DoWrite(net::IOBuffer* buf, int buf_len);
83
84 bool async_write_;
85 bool write_pending_;
86 int write_limit_;
87 int next_write_error_;
88
77 int next_read_error_; 89 int next_read_error_;
78 bool read_pending_; 90 bool read_pending_;
79 scoped_refptr<net::IOBuffer> read_buffer_; 91 scoped_refptr<net::IOBuffer> read_buffer_;
80 int read_buffer_size_; 92 int read_buffer_size_;
81 net::CompletionCallback read_callback_; 93 net::CompletionCallback read_callback_;
82 base::WeakPtr<FakeSocket> peer_socket_; 94 base::WeakPtr<FakeSocket> peer_socket_;
83 95
84 std::string written_data_; 96 std::string written_data_;
85 std::string input_data_; 97 std::string input_data_;
86 int input_pos_; 98 int input_pos_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 ErrorCode error_; 198 ErrorCode error_;
187 bool closed_; 199 bool closed_;
188 200
189 DISALLOW_COPY_AND_ASSIGN(FakeSession); 201 DISALLOW_COPY_AND_ASSIGN(FakeSession);
190 }; 202 };
191 203
192 } // namespace protocol 204 } // namespace protocol
193 } // namespace remoting 205 } // namespace remoting
194 206
195 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ 207 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/buffered_socket_writer_unittest.cc ('k') | remoting/protocol/fake_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698