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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ~FakeStreamChannelFactory() override; | 107 ~FakeStreamChannelFactory() override; |
108 | 108 |
109 void set_asynchronous_create(bool asynchronous_create) { | 109 void set_asynchronous_create(bool asynchronous_create) { |
110 asynchronous_create_ = asynchronous_create; | 110 asynchronous_create_ = asynchronous_create; |
111 } | 111 } |
112 | 112 |
113 void set_fail_create(bool fail_create) { fail_create_ = fail_create; } | 113 void set_fail_create(bool fail_create) { fail_create_ = fail_create; } |
114 | 114 |
115 FakeStreamSocket* GetFakeChannel(const std::string& name); | 115 FakeStreamSocket* GetFakeChannel(const std::string& name); |
116 | 116 |
| 117 // Pairs the socket with |peer_socket|. Deleting either of the paired sockets |
| 118 // unpairs them. |
| 119 void PairWith(FakeStreamChannelFactory* peer_factory); |
| 120 |
117 // ChannelFactory interface. | 121 // ChannelFactory interface. |
118 void CreateChannel(const std::string& name, | 122 void CreateChannel(const std::string& name, |
119 const ChannelCreatedCallback& callback) override; | 123 const ChannelCreatedCallback& callback) override; |
120 void CancelChannelCreation(const std::string& name) override; | 124 void CancelChannelCreation(const std::string& name) override; |
121 | 125 |
122 private: | 126 private: |
123 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, | 127 void NotifyChannelCreated(scoped_ptr<FakeStreamSocket> owned_channel, |
124 const std::string& name, | 128 const std::string& name, |
125 const ChannelCreatedCallback& callback); | 129 const ChannelCreatedCallback& callback); |
126 | 130 |
127 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 131 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
128 bool asynchronous_create_; | 132 bool asynchronous_create_; |
129 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_; | 133 std::map<std::string, base::WeakPtr<FakeStreamSocket> > channels_; |
130 | 134 |
131 bool fail_create_; | 135 bool fail_create_; |
132 | 136 |
| 137 base::WeakPtr<FakeStreamChannelFactory> peer_factory_; |
133 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; | 138 base::WeakPtrFactory<FakeStreamChannelFactory> weak_factory_; |
134 | 139 |
135 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); | 140 DISALLOW_COPY_AND_ASSIGN(FakeStreamChannelFactory); |
136 }; | 141 }; |
137 | 142 |
138 } // namespace protocol | 143 } // namespace protocol |
139 } // namespace remoting | 144 } // namespace remoting |
140 | 145 |
141 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ | 146 #endif // REMOTING_PROTOCOL_FAKE_STREAM_SOCKET_H_ |
OLD | NEW |