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

Side by Side Diff: remoting/base/multiple_array_input_stream.h

Issue 4779001: Added CompoundBuffer that will be used to store data in the encoding/decoding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/base/compound_buffer_unittest.cc ('k') | remoting/base/multiple_array_input_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // MultipleArrayInputStream implements ZeroCopyInputStream to be used by
6 // protobuf to decode bytes into a protocol buffer message.
7 //
8 // This input stream is made of multiple IOBuffers received from the network.
9 // This object retains the IOBuffers added to it.
10 //
11 // Internally, we wrap each added IOBuffer in a DrainableIOBuffer. This allows
12 // us to track how much data has been consumed from each IOBuffer.
13
14 #ifndef REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_
15 #define REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_
16
17 #include <vector>
18
19 #include "base/basictypes.h"
20 #include "base/ref_counted.h"
21 #include "google/protobuf/io/zero_copy_stream.h"
22
23 namespace net {
24 class DrainableIOBuffer;
25 class IOBuffer;
26 } // namespace net
27
28 namespace remoting {
29
30 class MultipleArrayInputStream :
31 public google::protobuf::io::ZeroCopyInputStream {
32 public:
33 MultipleArrayInputStream();
34 virtual ~MultipleArrayInputStream();
35
36 // Add a buffer to the list. |buffer| is retained by this object.
37 void AddBuffer(net::IOBuffer* buffer, int size);
38
39 // google::protobuf::io::ZeroCopyInputStream interface.
40 virtual bool Next(const void** data, int* size);
41 virtual void BackUp(int count);
42 virtual bool Skip(int count);
43 virtual int64 ByteCount() const;
44
45 private:
46 std::vector<scoped_refptr<net::DrainableIOBuffer> > buffers_;
47
48 size_t current_buffer_;
49 int position_;
50 int last_returned_size_;
51
52 DISALLOW_COPY_AND_ASSIGN(MultipleArrayInputStream);
53 };
54
55 } // namespace remoting
56
57 #endif // REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_
OLDNEW
« no previous file with comments | « remoting/base/compound_buffer_unittest.cc ('k') | remoting/base/multiple_array_input_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698