OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | |
6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "net/base/completion_callback.h" | |
12 | |
13 class MessageLoop; | |
14 | |
15 namespace net { | |
16 class DrainableIOBuffer; | |
17 class GrowableIOBuffer; | |
18 class IOBuffer; | |
19 class Socket; | |
20 class StreamSocket; | |
21 } // namespace net | |
22 | |
23 namespace remoting { | |
24 namespace protocol { | |
25 | |
26 // 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.
| |
27 // 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.
| |
28 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
| |
29 public: | |
30 StreamConnectionTester(net::StreamSocket* client_socket, | |
31 net::StreamSocket* host_socket, | |
32 int message_size, | |
33 int message_count); | |
34 ~StreamConnectionTester(); | |
35 | |
36 void Start(); | |
37 void CheckResults(); | |
38 | |
39 protected: | |
40 void Done(); | |
41 void InitBuffers(); | |
42 void DoWrite(); | |
43 void OnWritten(int result); | |
44 void HandleWriteResult(int result); | |
45 void DoRead(); | |
46 void OnRead(int result); | |
47 void HandleReadResult(int result); | |
48 | |
49 private: | |
50 MessageLoop* message_loop_; | |
51 net::StreamSocket* host_socket_; | |
52 net::StreamSocket* client_socket_; | |
53 int message_size_; | |
54 int message_count_; | |
55 int test_data_size_; | |
56 bool done_; | |
57 | |
58 scoped_refptr<net::DrainableIOBuffer> output_buffer_; | |
59 scoped_refptr<net::GrowableIOBuffer> input_buffer_; | |
60 | |
61 net::OldCompletionCallbackImpl<StreamConnectionTester> write_cb_; | |
62 net::OldCompletionCallbackImpl<StreamConnectionTester> read_cb_; | |
63 int write_errors_; | |
64 int read_errors_; | |
65 }; | |
66 | |
67 class DatagramConnectionTester { | |
68 public: | |
69 DatagramConnectionTester(net::Socket* client_socket, | |
70 net::Socket* host_socket, | |
71 int message_size, | |
72 int message_count, | |
73 int delay_ms); | |
74 ~DatagramConnectionTester() ; | |
75 | |
76 void Start(); | |
77 void CheckResults(); | |
78 | |
79 private: | |
80 void Done(); | |
81 void DoWrite(); | |
82 void OnWritten(int result); | |
83 void HandleWriteResult(int result); | |
84 void DoRead(); | |
85 void OnRead(int result); | |
86 void HandleReadResult(int result); | |
87 | |
88 MessageLoop* message_loop_; | |
89 net::Socket* host_socket_; | |
90 net::Socket* client_socket_; | |
91 int message_size_; | |
92 int message_count_; | |
93 int delay_ms_; | |
94 bool done_; | |
95 | |
96 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; | |
97 scoped_refptr<net::IOBuffer> read_buffer_; | |
98 | |
99 net::OldCompletionCallbackImpl<DatagramConnectionTester> write_cb_; | |
100 net::OldCompletionCallbackImpl<DatagramConnectionTester> read_cb_; | |
101 int write_errors_; | |
102 int read_errors_; | |
103 int packets_sent_; | |
104 int packets_received_; | |
105 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.
| |
106 }; | |
107 | |
108 } // namespace protocol | |
109 } // namespace remoting | |
110 | |
111 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | |
OLD | NEW |