Chromium Code Reviews| Index: remoting/protocol/message_decoder.h |
| diff --git a/remoting/protocol/message_decoder.h b/remoting/protocol/message_decoder.h |
| index 207dee5b37820d754c4a8979f7f07218f125f494..98236b438b8785ba54a956d6d1b50d5012a085d6 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 "net/base/io_buffer.h" |
|
awong
2010/11/16 00:04:58
ordering
Sergey Ulanov
2010/11/16 01:25:09
Done.
|
| #include "google/protobuf/message_lite.h" |
|
awong
2010/11/16 00:04:58
Should this be from third_party/protobuf/src?
Sergey Ulanov
2010/11/16 01:25:09
Done. Also changed util.h
|
| -#include "remoting/base/multiple_array_input_stream.h" |
| +#include "remoting/base/compound_buffer.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 |