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

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: Refactor common logic Created 4 years, 9 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 #include <queue>
6
7 #include "net/filter/stream_source.h"
8
9 namespace net {
10
11 class MockStreamSource : public StreamSource {
12 public:
13 MockStreamSource();
14 ~MockStreamSource() override;
15
16 // Testing helpers
17 // Enqueues a result to be returned by |Read|. This method does not make a
18 // copy of |data|, so |data| must outlive this object. If |sync| is true,
19 // |Read| will return the supplied data synchronously; otherwise, the user of
20 // this class needs to call |CompleteNextRead|.
21 void AddReadResult(const char* data, size_t len, Error error, bool sync);
22
23 // Completes a pending Read() call.
24 void CompleteNextRead();
25
26 private:
27 struct QueuedResult {
28 QueuedResult(const char* data, size_t len, Error error, bool sync);
29 const char* data;
30 size_t len;
31 Error error;
32 bool sync;
33 };
34
35 // StreamSource implementation
36 Error ReadInternal(IOBuffer* dest_buffer,
37 size_t buffer_size,
38 size_t* bytes_read) override;
39
40 std::queue<QueuedResult> results_;
41 bool awaiting_completion_;
42 IOBuffer* dest_buffer_;
43 size_t dest_buffer_size_;
44 };
45
46 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698