| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "extensions/common/api/cast_channel.h" | 11 #include "extensions/common/api/cast_channel.h" |
| 10 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 11 | 13 |
| 12 namespace extensions { | 14 namespace extensions { |
| 13 namespace core_api { | 15 namespace core_api { |
| 14 namespace cast_channel { | 16 namespace cast_channel { |
| 15 class CastMessage; | 17 class CastMessage; |
| 16 | 18 |
| 17 // Class for constructing and parsing CastMessage packet data. | 19 // Class for constructing and parsing CastMessage packet data. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 // Reads bytes from |input_buffer_| and returns a new CastMessage if one | 37 // Reads bytes from |input_buffer_| and returns a new CastMessage if one |
| 36 // is fully read. | 38 // is fully read. |
| 37 // | 39 // |
| 38 // |num_bytes| The number of bytes received by a read operation. | 40 // |num_bytes| The number of bytes received by a read operation. |
| 39 // Value must be <= BytesRequested(). | 41 // Value must be <= BytesRequested(). |
| 40 // |message_length| Size of the deserialized message object, in bytes. For | 42 // |message_length| Size of the deserialized message object, in bytes. For |
| 41 // logging purposes. Set to zero if no message was parsed. | 43 // logging purposes. Set to zero if no message was parsed. |
| 42 // |error| The result of the ingest operation. Set to CHANNEL_ERROR_NONE | 44 // |error| The result of the ingest operation. Set to CHANNEL_ERROR_NONE |
| 43 // if no error occurred. | 45 // if no error occurred. |
| 44 // Returns A pointer to a parsed CastMessage if a message was received | 46 // Returns A pointer to a parsed CastMessage if a message was received |
| 45 // in its entirety, NULL otherwise. | 47 // in its entirety, nullptr otherwise. |
| 46 scoped_ptr<CastMessage> Ingest(size_t num_bytes, | 48 scoped_ptr<CastMessage> Ingest(size_t num_bytes, |
| 47 size_t* message_length, | 49 size_t* message_length, |
| 48 ChannelError* error); | 50 ChannelError* error); |
| 49 | 51 |
| 50 // Message header struct. If fields are added, be sure to update | 52 // Message header struct. If fields are added, be sure to update |
| 51 // header_size(). Public to allow use of *_size() methods in unit tests. | 53 // header_size(). Public to allow use of *_size() methods in unit tests. |
| 52 struct MessageHeader { | 54 struct MessageHeader { |
| 53 MessageHeader(); | 55 MessageHeader(); |
| 54 // Sets the message size. | 56 // Sets the message size. |
| 55 void SetMessageSize(size_t message_size); | 57 void SetMessageSize(size_t message_size); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 90 |
| 89 // Disables Ingest functionality is the parser receives invalid data. | 91 // Disables Ingest functionality is the parser receives invalid data. |
| 90 bool error_; | 92 bool error_; |
| 91 | 93 |
| 92 DISALLOW_COPY_AND_ASSIGN(MessageFramer); | 94 DISALLOW_COPY_AND_ASSIGN(MessageFramer); |
| 93 }; | 95 }; |
| 94 } // namespace cast_channel | 96 } // namespace cast_channel |
| 95 } // namespace core_api | 97 } // namespace core_api |
| 96 } // namespace extensions | 98 } // namespace extensions |
| 97 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ | 99 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_ |
| OLD | NEW |