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

Unified Diff: remoting/base/multiple_array_input_stream.h

Issue 4017002: HostMessageDispatcher to parse control messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged again Created 10 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/base/multiple_array_input_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/multiple_array_input_stream.h
diff --git a/remoting/base/multiple_array_input_stream.h b/remoting/base/multiple_array_input_stream.h
index 7747da58089ee59919a95fa755bb20cb3a554ab9..a8482481aca67246f011a9ddf98f8f484e5efb59 100644
--- a/remoting/base/multiple_array_input_stream.h
+++ b/remoting/base/multiple_array_input_stream.h
@@ -2,29 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// MultipleArrayInputStream implements ZeroCopyInputStream to be used by
+// protobuf to decode bytes into a protocol buffer message.
+//
+// This input stream is made of multiple IOBuffers received from the network.
+// This object retains the IOBuffers added to it.
+//
+// Internally, we wrap each added IOBuffer in a DrainableIOBuffer. This allows
+// us to track how much data has been consumed from each IOBuffer.
+
#ifndef REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_
#define REMOTING_BASE_MULTIPLE_ARRAY_INPUT_STREAM_H_
#include <vector>
#include "base/basictypes.h"
+#include "base/ref_counted.h"
#include "google/protobuf/io/zero_copy_stream.h"
+namespace net {
+class DrainableIOBuffer;
+class IOBuffer;
+} // namespace net
+
namespace remoting {
-// A MultipleArrayInputStream provides a ZeroCopyInputStream with multiple
-// backing arrays.
class MultipleArrayInputStream :
public google::protobuf::io::ZeroCopyInputStream {
public:
- // Construct a MultipleArrayInputStream with |count| backing arrays.
- // TODO(hclam): Consider adding block size to see if it has a performance
- // gain.
MultipleArrayInputStream();
virtual ~MultipleArrayInputStream();
- // Add a new buffer to the list.
- void AddBuffer(const char* buffer, int size);
+ // Add a buffer to the list. |buffer| is retained by this object.
+ void AddBuffer(net::IOBuffer* buffer, int size);
// google::protobuf::io::ZeroCopyInputStream interface.
virtual bool Next(const void** data, int* size);
@@ -33,11 +43,9 @@ class MultipleArrayInputStream :
virtual int64 ByteCount() const;
private:
- std::vector<const char*> buffers_;
- std::vector<int> buffer_sizes_;
+ std::vector<scoped_refptr<net::DrainableIOBuffer> > buffers_;
size_t current_buffer_;
- int current_buffer_offset_;
int position_;
int last_returned_size_;
« no previous file with comments | « no previous file | remoting/base/multiple_array_input_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698