| 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 <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "remoting/protocol/p2p_stream_socket.h" | 15 #include "remoting/protocol/p2p_stream_socket.h" |
| 16 #include "remoting/protocol/stream_channel_factory.h" | 16 #include "remoting/protocol/stream_channel_factory.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace remoting { | 22 namespace remoting { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets | 121 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets |
| 122 // unpairs them. | 122 // unpairs them. |
| 123 void PairWith(FakeStreamChannelFactory* peer_factory); | 123 void PairWith(FakeStreamChannelFactory* peer_factory); |
| 124 | 124 |
| 125 // ChannelFactory interface. | 125 // ChannelFactory interface. |
| 126 void CreateChannel(const std::string& name, | 126 void CreateChannel(const std::string& name, |
| 127 const ChannelCreatedCallback& callback) override; | 127 const ChannelCreatedCallback& callback) override; |
| 128 void CancelChannelCreation(const std::string& name) override; | 128 void CancelChannelCreation(const std::string& name) override; |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, | 131 void NotifyChannelCreated(std::unique_ptr<FakeStreamSocket> owned_channel, |
| 132 const std::string& name, | 132 const std::string& name, |
| 133 const ChannelCreatedCallback& callback); | 133 const ChannelCreatedCallback& callback); |
| 134 | 134 |
| 135 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 135 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 136 bool asynchronous_create_ = false; | 136 bool asynchronous_create_ = false; |
| 137 std::map<std::string, base::WeakPtr<FakeStreamSocket>> channels_; | 137 std::map<std::string, base::WeakPtr<FakeStreamSocket>> channels_; |
| 138 | 138 |
| 139 bool fail_create_ = false; | 139 bool fail_create_ = false; |
| 140 | 140 |
| 141 bool async_write_ = false; | 141 bool async_write_ = false; |
| 142 | 142 |
| 143 base::WeakPtr<FakeStreamChannelFactory> peer_factory_; | 143 base::WeakPtr<FakeStreamChannelFactory> peer_factory_; |
| 144 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; | 144 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); | 146 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace protocol | 149 } // namespace protocol |
| 150 } // namespace remoting | 150 } // namespace remoting |
| 151 | 151 |
| 152 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 152 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
| OLD | NEW |