Don't use mContentViewCore after WebView has been destroyed.
[chromium-blink-merge.git] / remoting / protocol / connection_tester.h
blob6c95c71f81fb36ae9a52abf5377463aa32dbab44
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
12 namespace base {
13 class MessageLoop;
16 namespace net {
17 class DrainableIOBuffer;
18 class GrowableIOBuffer;
19 class IOBuffer;
20 class Socket;
21 class StreamSocket;
22 } // namespace net
24 namespace remoting {
25 namespace protocol {
27 // This class is used by unit tests to verify that a connection
28 // between two sockets works properly, i.e. data is delivered from one
29 // end to the other.
30 class StreamConnectionTester {
31 public:
32 StreamConnectionTester(net::StreamSocket* client_socket,
33 net::StreamSocket* host_socket,
34 int message_size,
35 int message_count);
36 ~StreamConnectionTester();
38 void Start();
39 bool done() { return done_; }
40 void CheckResults();
42 protected:
43 void Done();
44 void InitBuffers();
45 void DoWrite();
46 void OnWritten(int result);
47 void HandleWriteResult(int result);
48 void DoRead();
49 void OnRead(int result);
50 void HandleReadResult(int result);
52 private:
53 base::MessageLoop* message_loop_;
54 net::StreamSocket* host_socket_;
55 net::StreamSocket* client_socket_;
56 int message_size_;
57 int test_data_size_;
58 bool done_;
60 scoped_refptr<net::DrainableIOBuffer> output_buffer_;
61 scoped_refptr<net::GrowableIOBuffer> input_buffer_;
63 int write_errors_;
64 int read_errors_;
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() ;
76 void Start();
77 void CheckResults();
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);
88 base::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_;
96 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_;
97 scoped_refptr<net::IOBuffer> read_buffer_;
99 int write_errors_;
100 int read_errors_;
101 int packets_sent_;
102 int packets_received_;
103 int bad_packets_received_;
106 } // namespace protocol
107 } // namespace remoting
109 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_