| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "net/filter/mock_source_stream.h" | 5 #include "net/filter/mock_source_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/trace_event/memory_allocator_dump.h" |
| 8 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 9 | 10 |
| 10 namespace net { | 11 namespace net { |
| 11 | 12 |
| 12 MockSourceStream::MockSourceStream() | 13 MockSourceStream::MockSourceStream() |
| 13 : SourceStream(SourceStream::TYPE_NONE), | 14 : SourceStream(SourceStream::TYPE_NONE), |
| 14 awaiting_completion_(false), | 15 awaiting_completion_(false), |
| 15 dest_buffer_(nullptr), | 16 dest_buffer_(nullptr), |
| 16 dest_buffer_size_(0) {} | 17 dest_buffer_size_(0) {} |
| 17 | 18 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 results_.pop(); | 43 results_.pop(); |
| 43 memcpy(dest_buffer->data(), r.data, r.len); | 44 memcpy(dest_buffer->data(), r.data, r.len); |
| 44 return r.error == OK ? r.len : r.error; | 45 return r.error == OK ? r.len : r.error; |
| 45 } | 46 } |
| 46 | 47 |
| 47 std::string MockSourceStream::Description() const { | 48 std::string MockSourceStream::Description() const { |
| 48 return ""; | 49 return ""; |
| 49 } | 50 } |
| 50 | 51 |
| 52 void MockSourceStream::DumpMemoryStats( |
| 53 base::trace_event::MemoryAllocatorDump* dump) const {} |
| 54 |
| 51 MockSourceStream::QueuedResult::QueuedResult(const char* data, | 55 MockSourceStream::QueuedResult::QueuedResult(const char* data, |
| 52 int len, | 56 int len, |
| 53 Error error, | 57 Error error, |
| 54 Mode mode) | 58 Mode mode) |
| 55 : data(data), len(len), error(error), mode(mode) {} | 59 : data(data), len(len), error(error), mode(mode) {} |
| 56 | 60 |
| 57 void MockSourceStream::AddReadResult(const char* data, | 61 void MockSourceStream::AddReadResult(const char* data, |
| 58 int len, | 62 int len, |
| 59 Error error, | 63 Error error, |
| 60 Mode mode) { | 64 Mode mode) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 QueuedResult r = results_.front(); | 77 QueuedResult r = results_.front(); |
| 74 DCHECK_EQ(ASYNC, r.mode); | 78 DCHECK_EQ(ASYNC, r.mode); |
| 75 results_.pop(); | 79 results_.pop(); |
| 76 DCHECK_GE(dest_buffer_size_, r.len); | 80 DCHECK_GE(dest_buffer_size_, r.len); |
| 77 memcpy(dest_buffer_->data(), r.data, r.len); | 81 memcpy(dest_buffer_->data(), r.data, r.len); |
| 78 dest_buffer_ = nullptr; | 82 dest_buffer_ = nullptr; |
| 79 callback_.Run(r.error == OK ? r.len : r.error); | 83 callback_.Run(r.error == OK ? r.len : r.error); |
| 80 } | 84 } |
| 81 | 85 |
| 82 } // namespace net | 86 } // namespace net |
| OLD | NEW |