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

Side by Side Diff: remoting/protocol/message_decoder.h

Issue 6271004: Changed MessageReader so that it doesn't read from the socket if there are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref-counted MessageReader Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/input_sender.cc ('k') | remoting/protocol/message_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_PROTOCOL_MESSAGES_DECODER_H_ 5 #ifndef REMOTING_PROTOCOL_MESSAGES_DECODER_H_
6 #define REMOTING_PROTOCOL_MESSAGES_DECODER_H_ 6 #define REMOTING_PROTOCOL_MESSAGES_DECODER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 10
(...skipping 17 matching lines...) Expand all
28 // message_data in bytes. message_data - content of the message. 28 // message_data in bytes. message_data - content of the message.
29 class MessageDecoder { 29 class MessageDecoder {
30 public: 30 public:
31 MessageDecoder(); 31 MessageDecoder();
32 virtual ~MessageDecoder(); 32 virtual ~MessageDecoder();
33 33
34 // Add next chunk of data. MessageDecoder retains |data| until all 34 // Add next chunk of data. MessageDecoder retains |data| until all
35 // its bytes are consumed. 35 // its bytes are consumed.
36 void AddData(scoped_refptr<net::IOBuffer> data, int data_size); 36 void AddData(scoped_refptr<net::IOBuffer> data, int data_size);
37 37
38 // Get next message from the stream and puts it in 38 // Returns next message from the stream. Ownership of the result is
39 // |message_buffer|. Returns false if there are no complete messages 39 // passed to the caller. Returns NULL if there are no complete
40 // yet. 40 // messages yet, otherwise returns a buffer that contains one
41 bool GetNextMessage(CompoundBuffer* message_buffer); 41 // message.
42 CompoundBuffer* GetNextMessage();
42 43
43 private: 44 private:
44 // Retrieves the read payload size of the current protocol buffer via |size|. 45 // Retrieves the read payload size of the current protocol buffer via |size|.
45 // Returns false and leaves |size| unmodified, if we do not have enough data 46 // Returns false and leaves |size| unmodified, if we do not have enough data
46 // to retrieve the current size. 47 // to retrieve the current size.
47 bool GetPayloadSize(int* size); 48 bool GetPayloadSize(int* size);
48 49
49 CompoundBuffer buffer_; 50 CompoundBuffer buffer_;
50 51
51 // |next_payload_| stores the size of the next payload if known. 52 // |next_payload_| stores the size of the next payload if known.
52 // |next_payload_known_| is true if the size of the next payload is known. 53 // |next_payload_known_| is true if the size of the next payload is known.
53 // After one payload is read this is reset to false. 54 // After one payload is read this is reset to false.
54 int next_payload_; 55 int next_payload_;
55 bool next_payload_known_; 56 bool next_payload_known_;
56 }; 57 };
57 58
58 } // namespace protocol 59 } // namespace protocol
59 } // namespace remoting 60 } // namespace remoting
60 61
61 #endif // REMOTING_PROTOCOL_MESSAGES_DECODER_H_ 62 #endif // REMOTING_PROTOCOL_MESSAGES_DECODER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/input_sender.cc ('k') | remoting/protocol/message_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698