Chromium Code Reviews| 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 <deque> | |
| 8 #include <map> | 9 #include <map> |
| 9 #include <memory> | 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "remoting/protocol/fake_stream_socket.h" | 17 #include "remoting/protocol/fake_stream_socket.h" |
| 18 #include "remoting/protocol/jingle_messages.h" | |
| 17 #include "remoting/protocol/session.h" | 19 #include "remoting/protocol/session.h" |
| 18 #include "remoting/protocol/transport.h" | 20 #include "remoting/protocol/transport.h" |
| 19 | 21 |
| 20 namespace remoting { | 22 namespace remoting { |
| 21 namespace protocol { | 23 namespace protocol { |
| 22 | 24 |
| 23 extern const char kTestJid[]; | 25 extern const char kTestJid[]; |
| 24 | 26 |
| 25 class FakeAuthenticator; | 27 class FakeAuthenticator; |
| 26 | 28 |
| 27 class FakeSession : public Session { | 29 class FakeSession : public Session { |
| 28 public: | 30 public: |
| 29 FakeSession(); | 31 FakeSession(); |
| 30 ~FakeSession() override; | 32 ~FakeSession() override; |
| 31 | 33 |
| 32 void SimulateConnection(FakeSession* peer); | 34 void SimulateConnection(FakeSession* peer); |
| 33 | 35 |
| 34 EventHandler* event_handler() { return event_handler_; } | 36 EventHandler* event_handler() { return event_handler_; } |
| 35 void set_error(ErrorCode error) { error_ = error; } | 37 void set_error(ErrorCode error) { error_ = error; } |
| 36 bool is_closed() const { return closed_; } | 38 bool is_closed() const { return closed_; } |
| 37 | 39 |
| 38 // Sets delay for signaling message deliver when connected to a peer. | 40 // Sets delay for signaling message deliver when connected to a peer. |
| 39 void set_signaling_delay(base::TimeDelta signaling_delay) { | 41 void set_signaling_delay(base::TimeDelta signaling_delay) { |
| 40 signaling_delay_ = signaling_delay; | 42 signaling_delay_ = signaling_delay; |
| 41 } | 43 } |
| 42 | 44 |
| 45 // Adds an |attachment| to |round|, which will be sent to plugins added by | |
| 46 // AddPlugin() function. | |
| 47 void SetAttachment(size_t round, | |
|
Sergey Ulanov
2017/01/09 23:00:26
int would be more appropriate here than size_t, bu
Hzj_jie
2017/01/10 02:31:10
Then it would be complex if the FakeSession has be
| |
| 48 std::unique_ptr<buzz::XmlElement> attachment); | |
| 49 | |
| 43 // Session interface. | 50 // Session interface. |
| 44 void SetEventHandler(EventHandler* event_handler) override; | 51 void SetEventHandler(EventHandler* event_handler) override; |
| 45 ErrorCode error() override; | 52 ErrorCode error() override; |
| 46 const std::string& jid() override; | 53 const std::string& jid() override; |
| 47 const SessionConfig& config() override; | 54 const SessionConfig& config() override; |
| 48 void SetTransport(Transport* transport) override; | 55 void SetTransport(Transport* transport) override; |
| 49 void Close(ErrorCode error) override; | 56 void Close(ErrorCode error) override; |
| 50 void AddPlugin(SessionPlugin* plugin) override; | 57 void AddPlugin(SessionPlugin* plugin) override; |
| 51 | 58 |
| 52 private: | 59 private: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 63 | 70 |
| 64 std::unique_ptr<FakeAuthenticator> authenticator_; | 71 std::unique_ptr<FakeAuthenticator> authenticator_; |
| 65 Transport* transport_; | 72 Transport* transport_; |
| 66 | 73 |
| 67 ErrorCode error_ = OK; | 74 ErrorCode error_ = OK; |
| 68 bool closed_ = false; | 75 bool closed_ = false; |
| 69 | 76 |
| 70 base::WeakPtr<FakeSession> peer_; | 77 base::WeakPtr<FakeSession> peer_; |
| 71 base::TimeDelta signaling_delay_; | 78 base::TimeDelta signaling_delay_; |
| 72 | 79 |
| 80 std::deque<JingleMessage> attachments_; | |
|
Sergey Ulanov
2017/01/09 23:00:26
I'd prefer to avoid using std::deque<> anywhere in
Hzj_jie
2017/01/10 02:31:10
It's a little bit complex, and relates to the impl
Sergey Ulanov
2017/01/23 00:51:35
I don't think you need to store JingleMessages her
Hzj_jie
2017/02/08 01:56:29
Done.
| |
| 81 | |
| 73 base::WeakPtrFactory<FakeSession> weak_factory_; | 82 base::WeakPtrFactory<FakeSession> weak_factory_; |
| 74 | 83 |
| 75 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 84 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
| 76 }; | 85 }; |
| 77 | 86 |
| 78 } // namespace protocol | 87 } // namespace protocol |
| 79 } // namespace remoting | 88 } // namespace remoting |
| 80 | 89 |
| 81 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 90 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |