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

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

Issue 667123002: Standardize usage of virtual/override/final in remoting/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/fake_session.h ('k') | remoting/protocol/host_control_dispatcher.h » ('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_STREAM_SOCKET_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ 6 #define REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 // Pending reads are supported, so if there is a pending read AppendInputData() 27 // Pending reads are supported, so if there is a pending read AppendInputData()
28 // calls the read callback. 28 // calls the read callback.
29 // 29 //
30 // Two fake sockets can be connected to each other using the 30 // Two fake sockets can be connected to each other using the
31 // PairWith() method, e.g.: a->PairWith(b). After this all data 31 // PairWith() method, e.g.: a->PairWith(b). After this all data
32 // written to |a| can be read from |b| and vice versa. Two connected 32 // written to |a| can be read from |b| and vice versa. Two connected
33 // sockets |a| and |b| must be created and used on the same thread. 33 // sockets |a| and |b| must be created and used on the same thread.
34 class FakeStreamSocket : public net::StreamSocket { 34 class FakeStreamSocket : public net::StreamSocket {
35 public: 35 public:
36 FakeStreamSocket(); 36 FakeStreamSocket();
37 virtual ~FakeStreamSocket(); 37 ~FakeStreamSocket() override;
38 38
39 // Returns all data written to the socket. 39 // Returns all data written to the socket.
40 const std::string& written_data() const { return written_data_; } 40 const std::string& written_data() const { return written_data_; }
41 41
42 // Sets maximum number of bytes written by each Write() call. 42 // Sets maximum number of bytes written by each Write() call.
43 void set_write_limit(int write_limit) { write_limit_ = write_limit; } 43 void set_write_limit(int write_limit) { write_limit_ = write_limit; }
44 44
45 // Enables asynchronous Write(). 45 // Enables asynchronous Write().
46 void set_async_write(bool async_write) { async_write_ = async_write; } 46 void set_async_write(bool async_write) { async_write_ = async_write; }
47 47
(...skipping 11 matching lines...) Expand all
59 59
60 // Current input position in bytes. 60 // Current input position in bytes.
61 int input_pos() const { return input_pos_; } 61 int input_pos() const { return input_pos_; }
62 62
63 // True if a Read() call is currently pending. 63 // True if a Read() call is currently pending.
64 bool read_pending() const { return !read_callback_.is_null(); } 64 bool read_pending() const { return !read_callback_.is_null(); }
65 65
66 base::WeakPtr<FakeStreamSocket> GetWeakPtr(); 66 base::WeakPtr<FakeStreamSocket> GetWeakPtr();
67 67
68 // net::Socket implementation. 68 // net::Socket implementation.
69 virtual int Read(net::IOBuffer* buf, int buf_len, 69 int Read(net::IOBuffer* buf,
70 const net::CompletionCallback& callback) override; 70 int buf_len,
71 virtual int Write(net::IOBuffer* buf, int buf_len, 71 const net::CompletionCallback& callback) override;
72 const net::CompletionCallback& callback) override; 72 int Write(net::IOBuffer* buf,
73 virtual int SetReceiveBufferSize(int32 size) override; 73 int buf_len,
74 virtual int SetSendBufferSize(int32 size) override; 74 const net::CompletionCallback& callback) override;
75 int SetReceiveBufferSize(int32 size) override;
76 int SetSendBufferSize(int32 size) override;
75 77
76 // net::StreamSocket interface. 78 // net::StreamSocket interface.
77 virtual int Connect(const net::CompletionCallback& callback) override; 79 int Connect(const net::CompletionCallback& callback) override;
78 virtual void Disconnect() override; 80 void Disconnect() override;
79 virtual bool IsConnected() const override; 81 bool IsConnected() const override;
80 virtual bool IsConnectedAndIdle() const override; 82 bool IsConnectedAndIdle() const override;
81 virtual int GetPeerAddress(net::IPEndPoint* address) const override; 83 int GetPeerAddress(net::IPEndPoint* address) const override;
82 virtual int GetLocalAddress(net::IPEndPoint* address) const override; 84 int GetLocalAddress(net::IPEndPoint* address) const override;
83 virtual const net::BoundNetLog& NetLog() const override; 85 const net::BoundNetLog& NetLog() const override;
84 virtual void SetSubresourceSpeculation() override; 86 void SetSubresourceSpeculation() override;
85 virtual void SetOmniboxSpeculation() override; 87 void SetOmniboxSpeculation() override;
86 virtual bool WasEverUsed() const override; 88 bool WasEverUsed() const override;
87 virtual bool UsingTCPFastOpen() const override; 89 bool UsingTCPFastOpen() const override;
88 virtual bool WasNpnNegotiated() const override; 90 bool WasNpnNegotiated() const override;
89 virtual net::NextProto GetNegotiatedProtocol() const override; 91 net::NextProto GetNegotiatedProtocol() const override;
90 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) override; 92 bool GetSSLInfo(net::SSLInfo* ssl_info) override;
91 93
92 private: 94 private:
93 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len, 95 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len,
94 const net::CompletionCallback& callback); 96 const net::CompletionCallback& callback);
95 void DoWrite(net::IOBuffer* buf, int buf_len); 97 void DoWrite(net::IOBuffer* buf, int buf_len);
96 98
97 bool async_write_; 99 bool async_write_;
98 bool write_pending_; 100 bool write_pending_;
99 int write_limit_; 101 int write_limit_;
100 int next_write_error_; 102 int next_write_error_;
(...skipping 13 matching lines...) Expand all
114 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 116 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
115 base::WeakPtrFactory<FakeStreamSocket> weak_factory_; 117 base::WeakPtrFactory<FakeStreamSocket> weak_factory_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket); 119 DISALLOW_COPY_AND_ASSIGN(FakeStreamSocket);
118 }; 120 };
119 121
120 // StreamChannelFactory that creates FakeStreamSocket. 122 // StreamChannelFactory that creates FakeStreamSocket.
121 class FakeStreamChannelFactory : public StreamChannelFactory { 123 class FakeStreamChannelFactory : public StreamChannelFactory {
122 public: 124 public:
123 FakeStreamChannelFactory(); 125 FakeStreamChannelFactory();
124 virtual ~FakeStreamChannelFactory(); 126 ~FakeStreamChannelFactory() override;
125 127
126 void set_asynchronous_create(bool asynchronous_create) { 128 void set_asynchronous_create(bool asynchronous_create) {
127 asynchronous_create_ = asynchronous_create; 129 asynchronous_create_ = asynchronous_create;
128 } 130 }
129 131
130 void set_fail_create(bool fail_create) { fail_create_ = fail_create; } 132 void set_fail_create(bool fail_create) { fail_create_ = fail_create; }
131 133
132 FakeStreamSocket* GetFakeChannel(const std::string& name); 134 FakeStreamSocket* GetFakeChannel(const std::string& name);
133 135
134 // ChannelFactory interface. 136 // ChannelFactory interface.
135 virtual void CreateChannel(const std::string& name, 137 void CreateChannel(const std::string& name,
136 const ChannelCreatedCallback& callback) override; 138 const ChannelCreatedCallback& callback) override;
137 virtual void CancelChannelCreation(const std::string& name) override; 139 void CancelChannelCreation(const std::string& name) override;
138 140
139 private: 141 private:
140 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, 142 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel,
141 const std::string& name, 143 const std::string& name,
142 const ChannelCreatedCallback& callback); 144 const ChannelCreatedCallback& callback);
143 145
144 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 146 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
145 bool asynchronous_create_; 147 bool asynchronous_create_;
146 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_; 148 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_;
147 149
148 bool fail_create_; 150 bool fail_create_;
149 151
150 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; 152 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_;
151 153
152 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); 154 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory);
153 }; 155 };
154 156
155 } // namespace protocol 157 } // namespace protocol
156 } // namespace remoting 158 } // namespace remoting
157 159
158 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ 160 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_
OLDNEW
« no previous file with comments | « remoting/protocol/fake_session.h ('k') | remoting/protocol/host_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698