| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ | 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.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 "net/socket/socket.h" | 15 #include "net/socket/socket.h" |
| 16 #include "net/socket/stream_socket.h" | 16 #include "net/socket/stream_socket.h" |
| 17 #include "remoting/protocol/channel_factory.h" | |
| 18 #include "remoting/protocol/session.h" | 17 #include "remoting/protocol/session.h" |
| 18 #include "remoting/protocol/stream_channel_factory.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class MessageLoop; | 21 class MessageLoop; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace remoting { | 24 namespace remoting { |
| 25 namespace protocol { | 25 namespace protocol { |
| 26 | 26 |
| 27 extern const char kTestJid[]; | 27 extern const char kTestJid[]; |
| 28 | 28 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 int input_pos_; | 141 int input_pos_; |
| 142 | 142 |
| 143 base::MessageLoop* message_loop_; | 143 base::MessageLoop* message_loop_; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket); | 145 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 // FakeSession is a dummy protocol::Session that uses FakeSocket for all | 148 // FakeSession is a dummy protocol::Session that uses FakeSocket for all |
| 149 // channels. | 149 // channels. |
| 150 class FakeSession : public Session, | 150 class FakeSession : public Session, |
| 151 public ChannelFactory { | 151 public StreamChannelFactory { |
| 152 public: | 152 public: |
| 153 FakeSession(); | 153 FakeSession(); |
| 154 virtual ~FakeSession(); | 154 virtual ~FakeSession(); |
| 155 | 155 |
| 156 EventHandler* event_handler() { return event_handler_; } | 156 EventHandler* event_handler() { return event_handler_; } |
| 157 | 157 |
| 158 void set_async_creation(bool async_creation) { | 158 void set_async_creation(bool async_creation) { |
| 159 async_creation_ = async_creation; | 159 async_creation_ = async_creation; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void set_error(ErrorCode error) { error_ = error; } | 162 void set_error(ErrorCode error) { error_ = error; } |
| 163 | 163 |
| 164 bool is_closed() const { return closed_; } | 164 bool is_closed() const { return closed_; } |
| 165 | 165 |
| 166 FakeSocket* GetStreamChannel(const std::string& name); | 166 FakeSocket* GetStreamChannel(const std::string& name); |
| 167 FakeUdpSocket* GetDatagramChannel(const std::string& name); | 167 FakeUdpSocket* GetDatagramChannel(const std::string& name); |
| 168 | 168 |
| 169 // Session interface. | 169 // Session interface. |
| 170 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE; | 170 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE; |
| 171 virtual ErrorCode error() OVERRIDE; | 171 virtual ErrorCode error() OVERRIDE; |
| 172 virtual const std::string& jid() OVERRIDE; | 172 virtual const std::string& jid() OVERRIDE; |
| 173 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; | 173 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; |
| 174 virtual const SessionConfig& config() OVERRIDE; | 174 virtual const SessionConfig& config() OVERRIDE; |
| 175 virtual void set_config(const SessionConfig& config) OVERRIDE; | 175 virtual void set_config(const SessionConfig& config) OVERRIDE; |
| 176 virtual ChannelFactory* GetTransportChannelFactory() OVERRIDE; | 176 virtual StreamChannelFactory* GetTransportChannelFactory() OVERRIDE; |
| 177 virtual ChannelFactory* GetMultiplexedChannelFactory() OVERRIDE; | 177 virtual StreamChannelFactory* GetMultiplexedChannelFactory() OVERRIDE; |
| 178 virtual void Close() OVERRIDE; | 178 virtual void Close() OVERRIDE; |
| 179 | 179 |
| 180 // ChannelFactory interface. | 180 // StreamChannelFactory interface. |
| 181 virtual void CreateChannel(const std::string& name, | 181 virtual void CreateChannel(const std::string& name, |
| 182 const ChannelCreatedCallback& callback) OVERRIDE; | 182 const ChannelCreatedCallback& callback) OVERRIDE; |
| 183 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; | 183 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; |
| 184 | 184 |
| 185 public: | 185 public: |
| 186 void NotifyChannelCreated(const std::string& name, | 186 void NotifyChannelCreated(const std::string& name, |
| 187 const ChannelCreatedCallback& callback); | 187 const ChannelCreatedCallback& callback); |
| 188 | 188 |
| 189 EventHandler* event_handler_; | 189 EventHandler* event_handler_; |
| 190 scoped_ptr<const CandidateSessionConfig> candidate_config_; | 190 scoped_ptr<const CandidateSessionConfig> candidate_config_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 203 | 203 |
| 204 base::WeakPtrFactory<FakeSession> weak_factory_; | 204 base::WeakPtrFactory<FakeSession> weak_factory_; |
| 205 | 205 |
| 206 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 206 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 } // namespace protocol | 209 } // namespace protocol |
| 210 } // namespace remoting | 210 } // namespace remoting |
| 211 | 211 |
| 212 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 212 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |