Chromium Code Reviews| Index: remoting/protocol/connection_tester.h |
| diff --git a/remoting/protocol/connection_tester.h b/remoting/protocol/connection_tester.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dcc8c833b9694f2ed41b1101232a220efbe5ba14 |
| --- /dev/null |
| +++ b/remoting/protocol/connection_tester.h |
| @@ -0,0 +1,111 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
| +#define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "net/base/completion_callback.h" |
| + |
| +class MessageLoop; |
| + |
| +namespace net { |
| +class DrainableIOBuffer; |
| +class GrowableIOBuffer; |
| +class IOBuffer; |
| +class Socket; |
| +class StreamSocket; |
| +} // namespace net |
| + |
| +namespace remoting { |
| +namespace protocol { |
| + |
| +// This class is used by unit tests to verify that connection between |
|
Wez
2011/12/09 23:42:33
nit: ... a connection ...
Sergey Ulanov
2011/12/12 22:52:00
Done.
|
| +// two sockets works propertly. |
|
Wez
2011/12/09 23:42:33
typo: properly
Wez
2011/12/09 23:42:33
What do we mean by "works"? We see a successful c
Sergey Ulanov
2011/12/12 22:52:00
Done.
Sergey Ulanov
2011/12/12 22:52:00
Done.
|
| +class StreamConnectionTester { |
|
Wez
2011/12/09 23:42:33
Is there no general-purpose StreamSocket tester un
Wez
2011/12/09 23:42:33
This might be better named StreamSocketTester?
Sergey Ulanov
2011/12/12 22:52:00
No, at least I didn't find one.
Sergey Ulanov
2011/12/12 22:52:00
StreamSocketTester would imply that it tests socke
|
| + public: |
| + StreamConnectionTester(net::StreamSocket* client_socket, |
| + net::StreamSocket* host_socket, |
| + int message_size, |
| + int message_count); |
| + ~StreamConnectionTester(); |
| + |
| + void Start(); |
| + void CheckResults(); |
| + |
| + protected: |
| + void Done(); |
| + void InitBuffers(); |
| + void DoWrite(); |
| + void OnWritten(int result); |
| + void HandleWriteResult(int result); |
| + void DoRead(); |
| + void OnRead(int result); |
| + void HandleReadResult(int result); |
| + |
| + private: |
| + MessageLoop* message_loop_; |
| + net::StreamSocket* host_socket_; |
| + net::StreamSocket* client_socket_; |
| + int message_size_; |
| + int message_count_; |
| + int test_data_size_; |
| + bool done_; |
| + |
| + scoped_refptr<net::DrainableIOBuffer> output_buffer_; |
| + scoped_refptr<net::GrowableIOBuffer> input_buffer_; |
| + |
| + net::OldCompletionCallbackImpl<StreamConnectionTester> write_cb_; |
| + net::OldCompletionCallbackImpl<StreamConnectionTester> read_cb_; |
| + int write_errors_; |
| + int read_errors_; |
| +}; |
| + |
| +class DatagramConnectionTester { |
| + public: |
| + DatagramConnectionTester(net::Socket* client_socket, |
| + net::Socket* host_socket, |
| + int message_size, |
| + int message_count, |
| + int delay_ms); |
| + ~DatagramConnectionTester() ; |
| + |
| + void Start(); |
| + void CheckResults(); |
| + |
| + private: |
| + void Done(); |
| + void DoWrite(); |
| + void OnWritten(int result); |
| + void HandleWriteResult(int result); |
| + void DoRead(); |
| + void OnRead(int result); |
| + void HandleReadResult(int result); |
| + |
| + MessageLoop* message_loop_; |
| + net::Socket* host_socket_; |
| + net::Socket* client_socket_; |
| + int message_size_; |
| + int message_count_; |
| + int delay_ms_; |
| + bool done_; |
| + |
| + std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; |
| + scoped_refptr<net::IOBuffer> read_buffer_; |
| + |
| + net::OldCompletionCallbackImpl<DatagramConnectionTester> write_cb_; |
| + net::OldCompletionCallbackImpl<DatagramConnectionTester> read_cb_; |
| + int write_errors_; |
| + int read_errors_; |
| + int packets_sent_; |
| + int packets_received_; |
| + int broken_packets_; |
|
Wez
2011/12/09 23:42:33
nit: bad_packets_received_ would be less ambiguous
Sergey Ulanov
2011/12/12 22:52:00
Done.
|
| +}; |
| + |
| +} // namespace protocol |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |