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

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

Issue 2525743002: Make URLRequestContext a MemoryDumpProvider (Abandoned) (Closed)
Patch Set: rebased to 7f3d142161b15869f6bea58ac43c5f52ce5834ac Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_FILTER_MOCK_SOURCE_STREAM_H_ 5 #ifndef NET_FILTER_MOCK_SOURCE_STREAM_H_
6 #define NET_FILTER_MOCK_SOURCE_STREAM_H_ 6 #define NET_FILTER_MOCK_SOURCE_STREAM_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/filter/source_stream.h" 15 #include "net/filter/source_stream.h"
16 16
17 namespace base {
18 namespace trace_event {
19 class MemoryAllocatorDump;
20 }
21 }
22
17 namespace net { 23 namespace net {
18 24
19 class IOBuffer; 25 class IOBuffer;
20 26
21 // A SourceStream implementation used in tests. This allows tests to specify 27 // A SourceStream implementation used in tests. This allows tests to specify
22 // what data to return for each Read() call. 28 // what data to return for each Read() call.
23 class MockSourceStream : public SourceStream { 29 class MockSourceStream : public SourceStream {
24 public: 30 public:
25 enum Mode { 31 enum Mode {
26 SYNC, 32 SYNC,
27 ASYNC, 33 ASYNC,
28 }; 34 };
29 MockSourceStream(); 35 MockSourceStream();
30 // The destructor will crash in debug build if there is any pending read. 36 // The destructor will crash in debug build if there is any pending read.
31 ~MockSourceStream() override; 37 ~MockSourceStream() override;
32 38
33 // SourceStream implementation 39 // SourceStream implementation
34 int Read(IOBuffer* dest_buffer, 40 int Read(IOBuffer* dest_buffer,
35 int buffer_size, 41 int buffer_size,
36 const CompletionCallback& callback) override; 42 const CompletionCallback& callback) override;
37 std::string Description() const override; 43 std::string Description() const override;
38 44
45 void DumpMemoryStats(
46 base::trace_event::MemoryAllocatorDump* dump) const override;
39 // Enqueues a result to be returned by |Read|. This method does not make a 47 // Enqueues a result to be returned by |Read|. This method does not make a
40 // copy of |data|, so |data| must outlive this object. If |mode| is SYNC, 48 // copy of |data|, so |data| must outlive this object. If |mode| is SYNC,
41 // |Read| will return the supplied data synchronously; otherwise, consumer 49 // |Read| will return the supplied data synchronously; otherwise, consumer
42 // needs to call |CompleteNextRead| 50 // needs to call |CompleteNextRead|
43 void AddReadResult(const char* data, int len, Error error, Mode mode); 51 void AddReadResult(const char* data, int len, Error error, Mode mode);
44 52
45 // Completes a pending Read() call. Crash in debug build if there is no 53 // Completes a pending Read() call. Crash in debug build if there is no
46 // pending read. 54 // pending read.
47 void CompleteNextRead(); 55 void CompleteNextRead();
48 56
(...skipping 12 matching lines...) Expand all
61 scoped_refptr<IOBuffer> dest_buffer_; 69 scoped_refptr<IOBuffer> dest_buffer_;
62 CompletionCallback callback_; 70 CompletionCallback callback_;
63 int dest_buffer_size_; 71 int dest_buffer_size_;
64 72
65 DISALLOW_COPY_AND_ASSIGN(MockSourceStream); 73 DISALLOW_COPY_AND_ASSIGN(MockSourceStream);
66 }; 74 };
67 75
68 } // namespace net 76 } // namespace net
69 77
70 #endif // NET_FILTER_MOCK_SOURCE_STREAM_H_ 78 #endif // NET_FILTER_MOCK_SOURCE_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698