OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_ |
| 6 #define REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/scoped_ptr.h" |
| 10 #include "google/protobuf/io/zero_copy_stream.h" |
| 11 |
| 12 namespace remoting { |
| 13 |
| 14 // A MultipleArrayInputStream provides a ZeroCopyInputStream with multiple |
| 15 // backing arrays. |
| 16 class MultipleArrayInputStream : |
| 17 public google::protobuf::io::ZeroCopyInputStream { |
| 18 public: |
| 19 // Construct a MultipleArrayInputStream with |count| backing arrays. |
| 20 // TODO(hclam): Consider adding block size to see if it has a performance |
| 21 // gain. |
| 22 explicit MultipleArrayInputStream(int count); |
| 23 virtual ~MultipleArrayInputStream(); |
| 24 |
| 25 virtual bool Next(const void** data, int* size); |
| 26 virtual void BackUp(int count); |
| 27 virtual bool Skip(int count); |
| 28 virtual int64 ByteCount() const; |
| 29 |
| 30 // Set the n-th buffer to be |buffer|. |
| 31 void SetBuffer(int n, const uint8* buffer, int size); |
| 32 |
| 33 private: |
| 34 scoped_array<const uint8*> buffers_; |
| 35 scoped_array<int> buffer_sizes_; |
| 36 |
| 37 const int buffer_count_; |
| 38 |
| 39 int current_buffer_; |
| 40 int current_buffer_offset_; |
| 41 int position_; |
| 42 int last_returned_size_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(MultipleArrayInputStream); |
| 45 }; |
| 46 |
| 47 } // namespace remoting |
| 48 |
| 49 #endif // REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_ |
OLD | NEW |