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

Unified Diff: remoting/protocol/message_decoder.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/jingle_connection_to_host.cc ('k') | remoting/protocol/message_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/message_decoder.h
diff --git a/remoting/protocol/message_decoder.h b/remoting/protocol/message_decoder.h
index 207dee5b37820d754c4a8979f7f07218f125f494..ea7aceeb09e13693c3f2a118c42fbb6dcb56783c 100644
--- a/remoting/protocol/message_decoder.h
+++ b/remoting/protocol/message_decoder.h
@@ -10,8 +10,9 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
-#include "google/protobuf/message_lite.h"
-#include "remoting/base/multiple_array_input_stream.h"
+#include "net/base/io_buffer.h"
+#include "remoting/base/compound_buffer.h"
+#include "third_party/protobuf/src/google/protobuf/message_lite.h"
namespace net {
class DrainableIOBuffer;
@@ -27,9 +28,9 @@ class ClientEventMessage;
class HostControlMessage;
class HostEventMessage;
-// MessageDecoder uses MultipleArrayInputStream to decode bytes into
-// protocol buffer messages. This can be used to decode bytes received from
-// the network.
+// MessageDecoder uses CompoundBuffer to decode bytes into protocol
+// buffer messages. This can be used to decode bytes received from the
+// network.
//
// It provides ParseMessages() which accepts an IOBuffer. If enough bytes
// are collected to produce protocol buffer messages then the bytes will be
@@ -72,21 +73,21 @@ class MessageDecoder {
// Parse one message from |buffer_list_|. Return true if sucessful.
template <class MessageType>
bool ParseOneMessage(MessageType** message) {
- scoped_ptr<MultipleArrayInputStream> stream(CreateInputStreamFromData());
- if (!stream.get())
+ scoped_ptr<CompoundBuffer> buffer(CreateCompoundBufferFromData());
+ if (!buffer.get())
return false;
+ CompoundBufferInputStream stream(buffer.get());
*message = new MessageType();
- bool ret = (*message)->ParseFromZeroCopyStream(stream.get());
- if (!ret) {
+ bool ret = (*message)->ParseFromZeroCopyStream(&stream);
+ if (!ret)
delete *message;
- }
return ret;
}
void AddBuffer(scoped_refptr<net::IOBuffer> data, int data_size);
- MultipleArrayInputStream* CreateInputStreamFromData();
+ CompoundBuffer* CreateCompoundBufferFromData();
// Retrieves the read payload size of the current protocol buffer via |size|.
// Returns false and leaves |size| unmodified, if we do not have enough data
« no previous file with comments | « remoting/protocol/jingle_connection_to_host.cc ('k') | remoting/protocol/message_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698