OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual int Read(net::IOBuffer* buf, int buf_len, |
70 const net::CompletionCallback& callback) OVERRIDE; | 70 const net::CompletionCallback& callback) override; |
71 virtual int Write(net::IOBuffer* buf, int buf_len, | 71 virtual int Write(net::IOBuffer* buf, int buf_len, |
72 const net::CompletionCallback& callback) OVERRIDE; | 72 const net::CompletionCallback& callback) override; |
73 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; | 73 virtual int SetReceiveBufferSize(int32 size) override; |
74 virtual int SetSendBufferSize(int32 size) OVERRIDE; | 74 virtual int SetSendBufferSize(int32 size) override; |
75 | 75 |
76 // net::StreamSocket interface. | 76 // net::StreamSocket interface. |
77 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | 77 virtual int Connect(const net::CompletionCallback& callback) override; |
78 virtual void Disconnect() OVERRIDE; | 78 virtual void Disconnect() override; |
79 virtual bool IsConnected() const OVERRIDE; | 79 virtual bool IsConnected() const override; |
80 virtual bool IsConnectedAndIdle() const OVERRIDE; | 80 virtual bool IsConnectedAndIdle() const override; |
81 virtual int GetPeerAddress(net::IPEndPoint* address) const OVERRIDE; | 81 virtual int GetPeerAddress(net::IPEndPoint* address) const override; |
82 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; | 82 virtual int GetLocalAddress(net::IPEndPoint* address) const override; |
83 virtual const net::BoundNetLog& NetLog() const OVERRIDE; | 83 virtual const net::BoundNetLog& NetLog() const override; |
84 virtual void SetSubresourceSpeculation() OVERRIDE; | 84 virtual void SetSubresourceSpeculation() override; |
85 virtual void SetOmniboxSpeculation() OVERRIDE; | 85 virtual void SetOmniboxSpeculation() override; |
86 virtual bool WasEverUsed() const OVERRIDE; | 86 virtual bool WasEverUsed() const override; |
87 virtual bool UsingTCPFastOpen() const OVERRIDE; | 87 virtual bool UsingTCPFastOpen() const override; |
88 virtual bool WasNpnNegotiated() const OVERRIDE; | 88 virtual bool WasNpnNegotiated() const override; |
89 virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; | 89 virtual net::NextProto GetNegotiatedProtocol() const override; |
90 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) OVERRIDE; | 90 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) override; |
91 | 91 |
92 private: | 92 private: |
93 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len, | 93 void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len, |
94 const net::CompletionCallback& callback); | 94 const net::CompletionCallback& callback); |
95 void DoWrite(net::IOBuffer* buf, int buf_len); | 95 void DoWrite(net::IOBuffer* buf, int buf_len); |
96 | 96 |
97 bool async_write_; | 97 bool async_write_; |
98 bool write_pending_; | 98 bool write_pending_; |
99 int write_limit_; | 99 int write_limit_; |
100 int next_write_error_; | 100 int next_write_error_; |
(...skipping 25 matching lines...) Expand all Loading... |
126 void set_asynchronous_create(bool asynchronous_create) { | 126 void set_asynchronous_create(bool asynchronous_create) { |
127 asynchronous_create_ = asynchronous_create; | 127 asynchronous_create_ = asynchronous_create; |
128 } | 128 } |
129 | 129 |
130 void set_fail_create(bool fail_create) { fail_create_ = fail_create; } | 130 void set_fail_create(bool fail_create) { fail_create_ = fail_create; } |
131 | 131 |
132 FakeStreamSocket* GetFakeChannel(const std::string& name); | 132 FakeStreamSocket* GetFakeChannel(const std::string& name); |
133 | 133 |
134 // ChannelFactory interface. | 134 // ChannelFactory interface. |
135 virtual void CreateChannel(const std::string& name, | 135 virtual void CreateChannel(const std::string& name, |
136 const ChannelCreatedCallback& callback) OVERRIDE; | 136 const ChannelCreatedCallback& callback) override; |
137 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 137 virtual void CancelChannelCreation(const std::string& name) override; |
138 | 138 |
139 private: | 139 private: |
140 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, | 140 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, |
141 const std::string& name, | 141 const std::string& name, |
142 const ChannelCreatedCallback& callback); | 142 const ChannelCreatedCallback& callback); |
143 | 143 |
144 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 144 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
145 bool asynchronous_create_; | 145 bool asynchronous_create_; |
146 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_; | 146 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_; |
147 | 147 |
148 bool fail_create_; | 148 bool fail_create_; |
149 | 149 |
150 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; | 150 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); | 152 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); |
153 }; | 153 }; |
154 | 154 |
155 } // namespace protocol | 155 } // namespace protocol |
156 } // namespace remoting | 156 } // namespace remoting |
157 | 157 |
158 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 158 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
OLD | NEW |