| 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 "remoting/protocol/fake_stream_socket.h" | 13 #include "remoting/protocol/fake_stream_socket.h" |
| 14 #include "remoting/protocol/session.h" | 14 #include "remoting/protocol/session.h" |
| 15 #include "remoting/protocol/transport.h" | |
| 16 | 15 |
| 17 namespace remoting { | 16 namespace remoting { |
| 18 namespace protocol { | 17 namespace protocol { |
| 19 | 18 |
| 20 extern const char kTestJid[]; | 19 extern const char kTestJid[]; |
| 21 | 20 |
| 22 class FakeTransportSession : public TransportSession { | |
| 23 public: | |
| 24 FakeTransportSession(); | |
| 25 ~FakeTransportSession() override; | |
| 26 | |
| 27 // TransportSession interface. | |
| 28 void Start(EventHandler* event_handler, | |
| 29 Authenticator* authenticator) override; | |
| 30 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | |
| 31 DatagramChannelFactory* GetDatagramChannelFactory() override; | |
| 32 FakeStreamChannelFactory* GetStreamChannelFactory() override; | |
| 33 FakeStreamChannelFactory* GetMultiplexedChannelFactory() override; | |
| 34 | |
| 35 private: | |
| 36 FakeStreamChannelFactory channel_factory_; | |
| 37 }; | |
| 38 | |
| 39 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all | 21 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all |
| 40 // channels. | 22 // channels. |
| 41 class FakeSession : public Session { | 23 class FakeSession : public Session { |
| 42 public: | 24 public: |
| 43 FakeSession(); | 25 FakeSession(); |
| 44 ~FakeSession() override; | 26 ~FakeSession() override; |
| 45 | 27 |
| 46 EventHandler* event_handler() { return event_handler_; } | 28 EventHandler* event_handler() { return event_handler_; } |
| 47 | 29 |
| 48 void set_error(ErrorCode error) { error_ = error; } | 30 void set_error(ErrorCode error) { error_ = error; } |
| 49 | 31 |
| 50 bool is_closed() const { return closed_; } | 32 bool is_closed() const { return closed_; } |
| 51 | 33 |
| 34 FakeStreamChannelFactory& fake_channel_factory() { return channel_factory_; } |
| 35 |
| 52 // Session interface. | 36 // Session interface. |
| 53 void SetEventHandler(EventHandler* event_handler) override; | 37 void SetEventHandler(EventHandler* event_handler) override; |
| 54 ErrorCode error() override; | 38 ErrorCode error() override; |
| 55 const std::string& jid() override; | 39 const std::string& jid() override; |
| 56 const SessionConfig& config() override; | 40 const SessionConfig& config() override; |
| 57 FakeTransportSession* GetTransportSession() override; | 41 StreamChannelFactory* GetTransportChannelFactory() override; |
| 58 FakeStreamChannelFactory* GetQuicChannelFactory() override; | 42 StreamChannelFactory* GetMultiplexedChannelFactory() override; |
| 43 StreamChannelFactory* GetQuicChannelFactory() override; |
| 59 void Close() override; | 44 void Close() override; |
| 60 | 45 |
| 61 public: | 46 public: |
| 62 EventHandler* event_handler_; | 47 EventHandler* event_handler_; |
| 63 scoped_ptr<SessionConfig> config_; | 48 scoped_ptr<SessionConfig> config_; |
| 64 | 49 |
| 50 FakeStreamChannelFactory channel_factory_; |
| 51 |
| 65 std::string jid_; | 52 std::string jid_; |
| 66 | 53 |
| 67 FakeTransportSession transport_session_; | |
| 68 | |
| 69 ErrorCode error_; | 54 ErrorCode error_; |
| 70 bool closed_; | 55 bool closed_; |
| 71 | 56 |
| 72 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 57 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
| 73 }; | 58 }; |
| 74 | 59 |
| 75 } // namespace protocol | 60 } // namespace protocol |
| 76 } // namespace remoting | 61 } // namespace remoting |
| 77 | 62 |
| 78 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 63 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |