| 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_CONNECTION_TESTER_H_ | 5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
| 6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | 6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "remoting/protocol/message_pipe.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 class DrainableIOBuffer; | 18 class DrainableIOBuffer; |
| 18 class GrowableIOBuffer; | 19 class GrowableIOBuffer; |
| 19 class IOBuffer; | 20 class IOBuffer; |
| 20 } // namespace net | 21 } // namespace net |
| 21 | 22 |
| 22 namespace remoting { | 23 namespace remoting { |
| 23 | 24 |
| 24 class CompoundBuffer; | 25 class CompoundBuffer; |
| 25 class VideoPacket; | 26 class VideoPacket; |
| 26 | 27 |
| 27 namespace protocol { | 28 namespace protocol { |
| 28 | 29 |
| 29 class MessagePipe; | |
| 30 class P2PDatagramSocket; | 30 class P2PDatagramSocket; |
| 31 class P2PStreamSocket; | 31 class P2PStreamSocket; |
| 32 | 32 |
| 33 // This class is used by unit tests to verify that a connection | 33 // This class is used by unit tests to verify that a connection |
| 34 // between two sockets works properly, i.e. data is delivered from one | 34 // between two sockets works properly, i.e. data is delivered from one |
| 35 // end to the other. | 35 // end to the other. |
| 36 class StreamConnectionTester { | 36 class StreamConnectionTester { |
| 37 public: | 37 public: |
| 38 StreamConnectionTester(P2PStreamSocket* client_socket, | 38 StreamConnectionTester(P2PStreamSocket* client_socket, |
| 39 P2PStreamSocket* host_socket, | 39 P2PStreamSocket* host_socket, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; | 102 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; |
| 103 scoped_refptr<net::IOBuffer> read_buffer_; | 103 scoped_refptr<net::IOBuffer> read_buffer_; |
| 104 | 104 |
| 105 int write_errors_; | 105 int write_errors_; |
| 106 int read_errors_; | 106 int read_errors_; |
| 107 int packets_sent_; | 107 int packets_sent_; |
| 108 int packets_received_; | 108 int packets_received_; |
| 109 int bad_packets_received_; | 109 int bad_packets_received_; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 class MessagePipeConnectionTester { | 112 class MessagePipeConnectionTester : public MessagePipe::EventHandler { |
| 113 public: | 113 public: |
| 114 MessagePipeConnectionTester(MessagePipe* client_pipe, | 114 MessagePipeConnectionTester(MessagePipe* client_pipe, |
| 115 MessagePipe* host_pipe, | 115 MessagePipe* host_pipe, |
| 116 int message_size, | 116 int message_size, |
| 117 int message_count); | 117 int message_count); |
| 118 ~MessagePipeConnectionTester(); | 118 ~MessagePipeConnectionTester() override; |
| 119 | 119 |
| 120 void RunAndCheckResults(); | 120 void RunAndCheckResults(); |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 void OnMessageReceived(std::unique_ptr<CompoundBuffer> message); | 123 // MessagePipe::EventHandler interface. |
| 124 void OnMessageReceived(std::unique_ptr<CompoundBuffer> message) override; |
| 125 void OnMessagePipeClosed() override; |
| 124 | 126 |
| 125 private: | 127 private: |
| 126 base::RunLoop run_loop_; | 128 base::RunLoop run_loop_; |
| 127 MessagePipe* host_pipe_; | 129 MessagePipe* host_pipe_; |
| 128 MessagePipe* client_pipe_; | 130 MessagePipe* client_pipe_; |
| 129 int message_size_; | 131 int message_size_; |
| 130 int message_count_; | 132 int message_count_; |
| 131 | 133 |
| 132 std::vector<std::unique_ptr<VideoPacket>> sent_messages_; | 134 std::vector<std::unique_ptr<VideoPacket>> sent_messages_; |
| 133 std::vector<std::unique_ptr<VideoPacket>> received_messages_; | 135 std::vector<std::unique_ptr<VideoPacket>> received_messages_; |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 } // namespace protocol | 138 } // namespace protocol |
| 137 } // namespace remoting | 139 } // namespace remoting |
| 138 | 140 |
| 139 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | 141 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
| OLD | NEW |