OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <functional> | 5 #include <functional> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "remoting/base/multiple_array_input_stream.h" | 9 #include "remoting/base/multiple_array_input_stream.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 MultipleArrayInputStream::MultipleArrayInputStream() | 13 MultipleArrayInputStream::MultipleArrayInputStream() |
14 : current_buffer_(0), | 14 : current_buffer_(0), |
15 position_(0), | 15 position_(0), |
16 last_returned_size_(0) { | 16 last_returned_size_(0) { |
17 } | 17 } |
18 | 18 |
19 MultipleArrayInputStream::~MultipleArrayInputStream() { | 19 MultipleArrayInputStream::~MultipleArrayInputStream() { |
20 } | 20 } |
21 | 21 |
22 void MultipleArrayInputStream::AddBuffer(net::IOBuffer* buffer, int size) { | 22 void MultipleArrayInputStream::AddBuffer(net::IOBuffer* buffer, int size) { |
23 DCHECK_EQ(position_, 0); // Haven't started reading. | 23 DCHECK_EQ(position_, 0); // Haven't started reading. |
24 buffers_.push_back(new net::DrainableIOBuffer(buffer, size)); | 24 buffers_.push_back(make_scoped_refptr( |
| 25 new net::DrainableIOBuffer(buffer, size))); |
25 } | 26 } |
26 | 27 |
27 bool MultipleArrayInputStream::Next(const void** data, int* size) { | 28 bool MultipleArrayInputStream::Next(const void** data, int* size) { |
28 if (current_buffer_ < buffers_.size()) { | 29 if (current_buffer_ < buffers_.size()) { |
29 // Reply with the number of bytes remaining in the current buffer. | 30 // Reply with the number of bytes remaining in the current buffer. |
30 scoped_refptr<net::DrainableIOBuffer> buffer = buffers_[current_buffer_]; | 31 scoped_refptr<net::DrainableIOBuffer> buffer = buffers_[current_buffer_]; |
31 last_returned_size_ = buffer->BytesRemaining(); | 32 last_returned_size_ = buffer->BytesRemaining(); |
32 *data = buffer->data(); | 33 *data = buffer->data(); |
33 *size = last_returned_size_; | 34 *size = last_returned_size_; |
34 | 35 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ++current_buffer_; | 78 ++current_buffer_; |
78 } | 79 } |
79 return count == 0; | 80 return count == 0; |
80 } | 81 } |
81 | 82 |
82 int64 MultipleArrayInputStream::ByteCount() const { | 83 int64 MultipleArrayInputStream::ByteCount() const { |
83 return position_; | 84 return position_; |
84 } | 85 } |
85 | 86 |
86 } // namespace remoting | 87 } // namespace remoting |
OLD | NEW |