Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: net/filter/mock_stream_source.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 NET_FILTER_MOCK_STREAM_SOURCE_H
6 #define NET_FILTER_MOCK_STREAM_SOURCE_H
7
8 #include <queue>
9
10 #include "net/filter/stream_source.h"
11
12 namespace net {
13
14 class MockStreamSource : public StreamSource {
15 public:
16 MockStreamSource();
17 ~MockStreamSource() override;
18
19 // StreamSource implementation
20 Error Read(IOBuffer* dest_buffer,
21 size_t buffer_size,
22 size_t* bytes_read,
23 const OnReadCompleteCallback& callback) override;
24
25 // Testing helpers
26 // Enqueues a result to be returned by |Read|. This method does not make a
27 // copy of |data|, so |data| must outlive this object. If |sync| is true,
28 // |Read| will return the supplied data synchronously; otherwise, the user of
29 // this class needs to call |CompleteNextRead|.
30 void AddReadResult(const char* data, size_t len, Error error, bool sync);
31
32 // Completes a pending Read() call.
33 void CompleteNextRead();
34
35 private:
36 struct QueuedResult {
37 QueuedResult(const char* data, size_t len, Error error, bool sync);
38 const char* data;
39 size_t len;
40 Error error;
41 bool sync;
42 };
43
44 std::queue<QueuedResult> results_;
45 bool awaiting_completion_;
46 IOBuffer* dest_buffer_;
47 OnReadCompleteCallback callback_;
48 size_t dest_buffer_size_;
49 };
50
51 } // namespace net
52
53 #endif // NET_FILTER_MOCK_STREAM_SOURCE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698