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

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: fix compile on mac Created 4 years, 5 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
mmenke 2016/07/21 18:14:08 +_ (x3)
xunjieli 2016/07/27 20:32:02 Done.
7
8 #include <queue>
9
10 #include "net/base/completion_callback.h"
11 #include "net/filter/stream_source.h"
12
13 namespace net {
14
15 class IOBuffer;
16
17 class MockStreamSource : public StreamSource {
mmenke 2016/07/21 18:14:08 Think this needs a description
xunjieli 2016/07/27 20:32:03 Done.
18 public:
19 MockStreamSource();
20 ~MockStreamSource() override;
21
22 // StreamSource implementation
23 int Read(IOBuffer* dest_buffer,
24 size_t buffer_size,
25 const CompletionCallback& callback) override;
26
27 // Testing helpers
28 // Enqueues a result to be returned by |Read|. This method does not make a
29 // copy of |data|, so |data| must outlive this object. If |sync| is true,
30 // |Read| will return the supplied data synchronously; otherwise, the user of
31 // this class needs to call |CompleteNextRead|.
32 void AddReadResult(const char* data, size_t len, Error error, bool sync);
mmenke 2016/07/21 18:14:09 include net/base/net_errors.h
xunjieli 2016/07/27 20:32:02 Done.
33
34 // Completes a pending Read() call.
35 void CompleteNextRead();
36
37 private:
38 struct QueuedResult {
39 QueuedResult(const char* data, size_t len, Error error, bool sync);
mmenke 2016/07/21 18:14:09 nit: Add blank line before member variables.
xunjieli 2016/07/27 20:32:02 Done.
40 const char* data;
41 size_t len;
42 Error error;
43 bool sync;
mmenke 2016/07/21 18:14:08 Can these all be constant? Fine if not. Could ev
xunjieli 2016/07/27 20:32:03 Done. I couldn't get "std::queue<const QueuedResul
44 };
45
46 std::queue<QueuedResult> results_;
47 bool awaiting_completion_;
48 IOBuffer* dest_buffer_;
mmenke 2016/07/21 18:14:09 scoped_refptr? (+include header for it)
xunjieli 2016/07/27 20:32:02 Done.
49 CompletionCallback callback_;
50 size_t dest_buffer_size_;
51 };
52
53 } // namespace net
54
55 #endif // NET_FILTER_MOCK_STREAM_SOURCE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698