| OLD | NEW | 
|---|
| (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 | 
| OLD | NEW | 
|---|