| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CONNECTION_H_ | 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_FAKE_CONNECTION_H_ | 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "net/socket/socket.h" | 11 #include "net/socket/socket.h" |
| 12 #include "remoting/protocol/chromotocol_connection.h" | 12 #include "remoting/protocol/session.h" |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 namespace protocol { |
| 17 |
| 16 extern const char kTestJid[]; | 18 extern const char kTestJid[]; |
| 17 | 19 |
| 18 // FakeSocket implement net::Socket interface for FakeConnection. All data | 20 // FakeSocket implement net::Socket interface for FakeConnection. All data |
| 19 // written to FakeSocket is stored in a buffer returned by written_data(). | 21 // written to FakeSocket is stored in a buffer returned by written_data(). |
| 20 // Read() reads data from another buffer that can be set with AppendInputData(). | 22 // Read() reads data from another buffer that can be set with AppendInputData(). |
| 21 // Pending reads are supported, so if there is a pending read AppendInputData() | 23 // Pending reads are supported, so if there is a pending read AppendInputData() |
| 22 // calls the read callback. | 24 // calls the read callback. |
| 23 class FakeSocket : public net::Socket { | 25 class FakeSocket : public net::Socket { |
| 24 public: | 26 public: |
| 25 FakeSocket(); | 27 FakeSocket(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 bool read_pending_; | 45 bool read_pending_; |
| 44 scoped_refptr<net::IOBuffer> read_buffer_; | 46 scoped_refptr<net::IOBuffer> read_buffer_; |
| 45 int read_buffer_size_; | 47 int read_buffer_size_; |
| 46 net::CompletionCallback* read_callback_; | 48 net::CompletionCallback* read_callback_; |
| 47 | 49 |
| 48 std::vector<char> written_data_; | 50 std::vector<char> written_data_; |
| 49 std::vector<char> input_data_; | 51 std::vector<char> input_data_; |
| 50 int input_pos_; | 52 int input_pos_; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 // FakeChromotocolConnection is a dummy ChromotocolConnection that uses | 55 // FakeSession is a dummy protocol::Session that uses FakeSocket for all |
| 54 // FakeSocket for all channels. | 56 // channels. |
| 55 class FakeChromotocolConnection : public ChromotocolConnection { | 57 class FakeSession : public Session { |
| 56 public: | 58 public: |
| 57 FakeChromotocolConnection(); | 59 FakeSession(); |
| 58 virtual ~FakeChromotocolConnection(); | 60 virtual ~FakeSession(); |
| 59 | 61 |
| 60 StateChangeCallback* state_change_callback() { return callback_.get(); } | 62 StateChangeCallback* state_change_callback() { return callback_.get(); } |
| 61 | 63 |
| 62 void set_message_loop(MessageLoop* message_loop) { | 64 void set_message_loop(MessageLoop* message_loop) { |
| 63 message_loop_ = message_loop; | 65 message_loop_ = message_loop; |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool is_closed() { return closed_; } | 68 bool is_closed() { return closed_; } |
| 67 | 69 |
| 68 virtual void SetStateChangeCallback(StateChangeCallback* callback); | 70 virtual void SetStateChangeCallback(StateChangeCallback* callback); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 90 MessageLoop* message_loop_; | 92 MessageLoop* message_loop_; |
| 91 FakeSocket control_channel_; | 93 FakeSocket control_channel_; |
| 92 FakeSocket event_channel_; | 94 FakeSocket event_channel_; |
| 93 FakeSocket video_channel_; | 95 FakeSocket video_channel_; |
| 94 FakeSocket video_rtp_channel_; | 96 FakeSocket video_rtp_channel_; |
| 95 FakeSocket video_rtcp_channel_; | 97 FakeSocket video_rtcp_channel_; |
| 96 std::string jid_; | 98 std::string jid_; |
| 97 bool closed_; | 99 bool closed_; |
| 98 }; | 100 }; |
| 99 | 101 |
| 102 } // namespace protocol |
| 103 |
| 100 } // namespace remoting | 104 } // namespace remoting |
| 101 | 105 |
| 102 #endif // REMOTING_PROTOCOL_FAKE_CONNECTION_H_ | 106 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ |
| OLD | NEW |