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

Unified Diff: remoting/protocol/message_decoder.cc

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/message_decoder.h ('k') | remoting/protocol/message_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/message_decoder.cc
diff --git a/remoting/protocol/message_decoder.cc b/remoting/protocol/message_decoder.cc
index 1200120c8f74f936609757952c58833b50528922..2e31bbcb8981764f5ef310c8c19369595bfac0a5 100644
--- a/remoting/protocol/message_decoder.cc
+++ b/remoting/protocol/message_decoder.cc
@@ -6,7 +6,7 @@
#include "base/logging.h"
#include "net/base/io_buffer.h"
-#include "remoting/base/multiple_array_input_stream.h"
+#include "remoting/base/compound_buffer.h"
#include "remoting/proto/internal.pb.h"
#include "third_party/libjingle/source/talk/base/byteorder.h"
@@ -27,7 +27,7 @@ void MessageDecoder::AddBuffer(scoped_refptr<net::IOBuffer> data,
available_bytes_ += data_size;
}
-MultipleArrayInputStream* MessageDecoder::CreateInputStreamFromData() {
+CompoundBuffer* MessageDecoder::CreateCompoundBufferFromData() {
// Determine the payload size. If we already know it then skip this part.
// We may not have enough data to determine the payload size so use a
// utility function to find out.
@@ -47,17 +47,15 @@ MultipleArrayInputStream* MessageDecoder::CreateInputStreamFromData() {
// The following loop gather buffers in |buffer_list_| that sum up to
// |next_payload_| bytes. These buffers are added to |stream|.
- // Create a MultipleArrayInputStream for parsing.
- // TODO(hclam): Avoid creating this object everytime.
- MultipleArrayInputStream* stream = new MultipleArrayInputStream();
+ // Create a CompoundBuffer for parsing.
+ CompoundBuffer* result = new CompoundBuffer();
while (next_payload_ > 0 && !buffer_list_.empty()) {
scoped_refptr<net::DrainableIOBuffer> buffer = buffer_list_.front();
int read_bytes = std::min(buffer->BytesRemaining(), next_payload_);
- // This call creates a new instance of DrainableIOBuffer internally.
// This will reference the same base pointer but maintain it's own
// version of data pointer.
- stream->AddBuffer(buffer, read_bytes);
+ result->Append(buffer, read_bytes);
// Adjust counters.
buffer->DidConsume(read_bytes);
@@ -70,7 +68,8 @@ MultipleArrayInputStream* MessageDecoder::CreateInputStreamFromData() {
}
DCHECK_EQ(0, next_payload_);
DCHECK_LE(0, available_bytes_);
- return stream;
+ result->Lock();
+ return result;
}
static int GetHeaderSize(const std::string& header) {
« no previous file with comments | « remoting/protocol/message_decoder.h ('k') | remoting/protocol/message_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698