OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_TEST_DATA_PROVIDER_H_ | |
6 #define GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_TEST_DATA_PROVIDER_H_ | |
7 | |
8 #include <queue> | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "google_apis/gcm/base/socket_stream.h" | |
13 #include "net/socket/socket_test_util.h" | |
14 | |
15 namespace gcm { | |
16 | |
17 class SocketStreamTestDataProvider : public net::SocketDataProvider { | |
Ryan Sleevi
2013/09/03 23:04:08
I'm not clear the motivation why you needed to do
Nicolas Zea
2013/09/04 00:43:33
Ah, I missed most of those implementations. I'll t
Nicolas Zea
2013/09/07 01:07:52
Switched to Delayed SDP.
| |
18 public: | |
19 SocketStreamTestDataProvider(); | |
20 virtual ~SocketStreamTestDataProvider(); | |
21 | |
22 // net::SocketDataProvider implementation. | |
23 // If there's no read, sets the "has pending read" flag. Otherwise, | |
24 // pops the next read. | |
25 virtual net::MockRead GetNextRead() OVERRIDE; | |
26 // Simply pops the next write and, if applicable, compares it to | |
27 // |data|. | |
28 virtual net::MockWriteResult OnWrite(const std::string& data) OVERRIDE; | |
29 // We ignore resets so we can pre-load the socket data provider with | |
30 // read/write events. | |
31 virtual void Reset() OVERRIDE; | |
32 | |
33 // If there is a pending read, completes it with the given read. | |
34 // Otherwise, queues up the given read. | |
35 void AddRead(const net::MockRead& mock_read); | |
36 | |
37 // If there is a pending write, completes it with the given write. | |
38 // Otherwise, queues up the given write. | |
39 void AddWrite(const net::MockWrite& mock_write); | |
40 | |
41 private: | |
42 std::deque<net::MockRead> reads_; | |
43 bool has_pending_read_; | |
44 | |
45 std::deque<net::MockWrite> writes_; | |
46 bool has_pending_write_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(SocketStreamTestDataProvider); | |
49 }; | |
50 | |
51 } // namespace gcm | |
52 | |
53 #endif // GOOGLE_APIS_GCM_BASE_SOCKET_STREAM_TEST_DATA_PROVIDER_H_ | |
OLD | NEW |