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 <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 "remoting/protocol/fake_stream_socket.h" | 14 #include "remoting/protocol/fake_stream_socket.h" |
| 14 #include "remoting/protocol/session.h" | 15 #include "remoting/protocol/session.h" |
| 15 #include "remoting/protocol/transport.h" | 16 #include "remoting/protocol/transport.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 namespace protocol { | 19 namespace protocol { |
| 19 | 20 |
| 20 extern const char kTestJid[]; | 21 extern const char kTestJid[]; |
| 21 | 22 |
| 22 class FakeTransport : public Transport { | 23 class FakeTransport : public Transport { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 35 FakeStreamChannelFactory channel_factory_; | 36 FakeStreamChannelFactory channel_factory_; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all | 39 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all |
| 39 // channels. | 40 // channels. |
| 40 class FakeSession : public Session { | 41 class FakeSession : public Session { |
| 41 public: | 42 public: |
| 42 FakeSession(); | 43 FakeSession(); |
| 43 ~FakeSession() override; | 44 ~FakeSession() override; |
| 44 | 45 |
| 46 void SimulateConnection(FakeSession* peer); | |
| 47 | |
| 45 EventHandler* event_handler() { return event_handler_; } | 48 EventHandler* event_handler() { return event_handler_; } |
| 46 | |
| 47 void set_error(ErrorCode error) { error_ = error; } | 49 void set_error(ErrorCode error) { error_ = error; } |
| 48 | |
| 49 bool is_closed() const { return closed_; } | 50 bool is_closed() const { return closed_; } |
| 50 | 51 |
| 51 // Session interface. | 52 // Session interface. |
| 52 void SetEventHandler(EventHandler* event_handler) override; | 53 void SetEventHandler(EventHandler* event_handler) override; |
| 53 ErrorCode error() override; | 54 ErrorCode error() override; |
| 54 const std::string& jid() override; | 55 const std::string& jid() override; |
| 55 const SessionConfig& config() override; | 56 const SessionConfig& config() override; |
| 56 FakeTransport* GetTransport() override; | 57 FakeTransport* GetTransport() override; |
| 57 void Close(ErrorCode error) override; | 58 void Close(ErrorCode error) override; |
| 58 | 59 |
| 59 public: | 60 public: |
|
joedow
2015/12/17 17:29:11
not part of your change, but why is public set twi
Sergey Ulanov
2015/12/17 17:36:18
Thanks for catching this!
| |
| 60 EventHandler* event_handler_; | 61 EventHandler* event_handler_ = nullptr; |
| 61 scoped_ptr<SessionConfig> config_; | 62 scoped_ptr<SessionConfig> config_; |
| 62 | 63 |
| 63 std::string jid_; | 64 std::string jid_; |
| 64 | 65 |
| 65 FakeTransport transport_; | 66 FakeTransport transport_; |
| 66 | 67 |
| 67 ErrorCode error_; | 68 ErrorCode error_ = OK; |
| 68 bool closed_; | 69 bool closed_ = false; |
| 70 | |
| 71 base::WeakPtr<FakeSession> peer_; | |
| 72 | |
| 73 base::WeakPtrFactory<FakeSession> weak_factory_; | |
| 69 | 74 |
| 70 DISALLOW_COPY_AND_ASSIGN(FakeSession); | 75 DISALLOW_COPY_AND_ASSIGN(FakeSession); |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 } // namespace protocol | 78 } // namespace protocol |
| 74 } // namespace remoting | 79 } // namespace remoting |
| 75 | 80 |
| 76 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ | 81 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |