| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "remoting/protocol/fake_stream_socket.h" | 16 #include "remoting/protocol/fake_stream_socket.h" |
| 17 #include "remoting/protocol/jingle_messages.h" |
| 17 #include "remoting/protocol/session.h" | 18 #include "remoting/protocol/session.h" |
| 18 #include "remoting/protocol/transport.h" | 19 #include "remoting/protocol/transport.h" |
| 19 | 20 |
| 20 namespace remoting { | 21 namespace remoting { |
| 21 namespace protocol { | 22 namespace protocol { |
| 22 | 23 |
| 23 extern const char kTestJid[]; | 24 extern const char kTestJid[]; |
| 24 | 25 |
| 25 class FakeAuthenticator; | 26 class FakeAuthenticator; |
| 26 | 27 |
| 27 class FakeSession : public Session { | 28 class FakeSession : public Session { |
| 28 public: | 29 public: |
| 29 FakeSession(); | 30 FakeSession(); |
| 30 ~FakeSession() override; | 31 ~FakeSession() override; |
| 31 | 32 |
| 32 void SimulateConnection(FakeSession* peer); | 33 void SimulateConnection(FakeSession* peer); |
| 33 | 34 |
| 34 EventHandler* event_handler() { return event_handler_; } | 35 EventHandler* event_handler() { return event_handler_; } |
| 35 void set_error(ErrorCode error) { error_ = error; } | 36 void set_error(ErrorCode error) { error_ = error; } |
| 36 bool is_closed() const { return closed_; } | 37 bool is_closed() const { return closed_; } |
| 37 | 38 |
| 38 // Sets delay for signaling message deliver when connected to a peer. | 39 // Sets delay for signaling message deliver when connected to a peer. |
| 39 void set_signaling_delay(base::TimeDelta signaling_delay) { | 40 void set_signaling_delay(base::TimeDelta signaling_delay) { |
| 40 signaling_delay_ = signaling_delay; | 41 signaling_delay_ = signaling_delay; |
| 41 } | 42 } |
| 42 | 43 |
| 44 // Adds an |attachment| to |round|, which will be sent to plugins added by |
| 45 // AddPlugin() function. |
| 46 void SetAttachment(size_t round, |
| 47 std::unique_ptr<buzz::XmlElement> attachment); |
| 48 |
| 43 // Session interface. | 49 // Session interface. |
| 44 void SetEventHandler(EventHandler* event_handler) override; | 50 void SetEventHandler(EventHandler* event_handler) override; |
| 45 ErrorCode error() override; | 51 ErrorCode error() override; |
| 46 const std::string& jid() override; | 52 const std::string& jid() override; |
| 47 const SessionConfig& config() override; | 53 const SessionConfig& config() override; |
| 48 void SetTransport(Transport* transport) override; | 54 void SetTransport(Transport* transport) override; |
| 49 void Close(ErrorCode error) override; | 55 void Close(ErrorCode error) override; |
| 50 void AddPlugin(SessionPlugin* plugin) override; | 56 void AddPlugin(SessionPlugin* plugin) override; |
| 51 | 57 |
| 52 private: | 58 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 | 69 |
| 64 std::unique_ptr<FakeAuthenticator> authenticator_; | 70 std::unique_ptr<FakeAuthenticator> authenticator_; |
| 65 Transport* transport_; | 71 Transport* transport_; |
| 66 | 72 |
| 67 ErrorCode error_ = OK; | 73 ErrorCode error_ = OK; |
| 68 bool closed_ = false; | 74 bool closed_ = false; |
| 69 | 75 |
| 70 base::WeakPtr<FakeSession> peer_; | 76 base::WeakPtr<FakeSession> peer_; |
| 71 base::TimeDelta signaling_delay_; | 77 base::TimeDelta signaling_delay_; |
| 72 | 78 |
| 79 std::vector<std::unique_ptr<buzz::XmlElement>> attachments_; |
| 80 |
| 73 base::WeakPtrFactory<FakeSession> weak_factory_; | 81 base::WeakPtrFactory<FakeSession> weak_factory_; |
| 74 | 82 |
| 75 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 83 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
| 76 }; | 84 }; |
| 77 | 85 |
| 78 } // namespace protocol | 86 } // namespace protocol |
| 79 } // namespace remoting | 87 } // namespace remoting |
| 80 | 88 |
| 81 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 89 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |