| 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_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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 int input_pos() const { return input_pos_; } | 48 int input_pos() const { return input_pos_; } |
| 49 | 49 |
| 50 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets | 50 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets |
| 51 // unpairs them. | 51 // unpairs them. |
| 52 void PairWith(FakeDatagramSocket* peer_socket); | 52 void PairWith(FakeDatagramSocket* peer_socket); |
| 53 | 53 |
| 54 base::WeakPtr<FakeDatagramSocket> GetWeakPtr(); | 54 base::WeakPtr<FakeDatagramSocket> GetWeakPtr(); |
| 55 | 55 |
| 56 // net::Socket implementation. | 56 // net::Socket implementation. |
| 57 virtual int Read(net::IOBuffer* buf, int buf_len, | 57 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 58 const net::CompletionCallback& callback) OVERRIDE; | 58 const net::CompletionCallback& callback) override; |
| 59 virtual int Write(net::IOBuffer* buf, int buf_len, | 59 virtual int Write(net::IOBuffer* buf, int buf_len, |
| 60 const net::CompletionCallback& callback) OVERRIDE; | 60 const net::CompletionCallback& callback) override; |
| 61 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; | 61 virtual int SetReceiveBufferSize(int32 size) override; |
| 62 virtual int SetSendBufferSize(int32 size) OVERRIDE; | 62 virtual int SetSendBufferSize(int32 size) override; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 int CopyReadData(net::IOBuffer* buf, int buf_len); | 65 int CopyReadData(net::IOBuffer* buf, int buf_len); |
| 66 | 66 |
| 67 base::WeakPtr<FakeDatagramSocket> peer_socket_; | 67 base::WeakPtr<FakeDatagramSocket> peer_socket_; |
| 68 | 68 |
| 69 scoped_refptr<net::IOBuffer> read_buffer_; | 69 scoped_refptr<net::IOBuffer> read_buffer_; |
| 70 int read_buffer_size_; | 70 int read_buffer_size_; |
| 71 net::CompletionCallback read_callback_; | 71 net::CompletionCallback read_callback_; |
| 72 | 72 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 96 // factory. | 96 // factory. |
| 97 void PairWith(FakeDatagramChannelFactory* peer_factory); | 97 void PairWith(FakeDatagramChannelFactory* peer_factory); |
| 98 | 98 |
| 99 // Can be used to retrieve FakeDatagramSocket created by this factory, e.g. to | 99 // Can be used to retrieve FakeDatagramSocket created by this factory, e.g. to |
| 100 // feed data into it. The caller doesn't get ownership of the result. Returns | 100 // feed data into it. The caller doesn't get ownership of the result. Returns |
| 101 // NULL if the socket doesn't exist. | 101 // NULL if the socket doesn't exist. |
| 102 FakeDatagramSocket* GetFakeChannel(const std::string& name); | 102 FakeDatagramSocket* GetFakeChannel(const std::string& name); |
| 103 | 103 |
| 104 // DatagramChannelFactory interface. | 104 // DatagramChannelFactory interface. |
| 105 virtual void CreateChannel(const std::string& name, | 105 virtual void CreateChannel(const std::string& name, |
| 106 const ChannelCreatedCallback& callback) OVERRIDE; | 106 const ChannelCreatedCallback& callback) override; |
| 107 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 107 virtual void CancelChannelCreation(const std::string& name) override; |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 typedef std::map<std::string, base::WeakPtr<FakeDatagramSocket> > ChannelsMap; | 110 typedef std::map<std::string, base::WeakPtr<FakeDatagramSocket> > ChannelsMap; |
| 111 | 111 |
| 112 void NotifyChannelCreated(scoped_ptr<FakeDatagramSocket> owned_socket, | 112 void NotifyChannelCreated(scoped_ptr<FakeDatagramSocket> owned_socket, |
| 113 const std::string& name, | 113 const std::string& name, |
| 114 const ChannelCreatedCallback& callback); | 114 const ChannelCreatedCallback& callback); |
| 115 | 115 |
| 116 base::WeakPtr<FakeDatagramChannelFactory> peer_factory_; | 116 base::WeakPtr<FakeDatagramChannelFactory> peer_factory_; |
| 117 | 117 |
| 118 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 118 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 119 bool asynchronous_create_; | 119 bool asynchronous_create_; |
| 120 ChannelsMap channels_; | 120 ChannelsMap channels_; |
| 121 | 121 |
| 122 bool fail_create_; | 122 bool fail_create_; |
| 123 | 123 |
| 124 base::WeakPtrFactory<FakeDatagramChannelFactory> weak_factory_; | 124 base::WeakPtrFactory<FakeDatagramChannelFactory> weak_factory_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(FakeDatagramChannelFactory); | 126 DISALLOW_COPY_AND_ASSIGN(FakeDatagramChannelFactory); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace protocol | 129 } // namespace protocol |
| 130 } // namespace remoting | 130 } // namespace remoting |
| 131 | 131 |
| 132 #endif // REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ | 132 #endif // REMOTING_PROTOCOL_FAKE_DATAGRAM_SOCKET_H_ |
| OLD | NEW |