| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "remoting/protocol/message_decoder.h" | 5 #include "remoting/protocol/message_decoder.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 9 #include "remoting/base/compound_buffer.h" | 11 #include "remoting/base/compound_buffer.h" |
| 10 #include "remoting/proto/internal.pb.h" | 12 #include "remoting/proto/internal.pb.h" |
| 11 #include "third_party/webrtc/base/byteorder.h" | 13 #include "third_party/webrtc/base/byteorder.h" |
| 12 | 14 |
| 13 namespace remoting { | 15 namespace remoting { |
| 14 namespace protocol { | 16 namespace protocol { |
| 15 | 17 |
| 16 MessageDecoder::MessageDecoder() | 18 MessageDecoder::MessageDecoder() |
| (...skipping 28 matching lines...) Expand all Loading... |
| 45 message_buffer->CopyFrom(buffer_, 0, next_payload_); | 47 message_buffer->CopyFrom(buffer_, 0, next_payload_); |
| 46 message_buffer->Lock(); | 48 message_buffer->Lock(); |
| 47 buffer_.CropFront(next_payload_); | 49 buffer_.CropFront(next_payload_); |
| 48 next_payload_known_ = false; | 50 next_payload_known_ = false; |
| 49 | 51 |
| 50 return message_buffer; | 52 return message_buffer; |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool MessageDecoder::GetPayloadSize(int* size) { | 55 bool MessageDecoder::GetPayloadSize(int* size) { |
| 54 // The header has a size of 4 bytes. | 56 // The header has a size of 4 bytes. |
| 55 const int kHeaderSize = sizeof(int32); | 57 const int kHeaderSize = sizeof(int32_t); |
| 56 | 58 |
| 57 if (buffer_.total_bytes() < kHeaderSize) | 59 if (buffer_.total_bytes() < kHeaderSize) |
| 58 return false; | 60 return false; |
| 59 | 61 |
| 60 CompoundBuffer header_buffer; | 62 CompoundBuffer header_buffer; |
| 61 char header[kHeaderSize]; | 63 char header[kHeaderSize]; |
| 62 header_buffer.CopyFrom(buffer_, 0, kHeaderSize); | 64 header_buffer.CopyFrom(buffer_, 0, kHeaderSize); |
| 63 header_buffer.CopyTo(header, kHeaderSize); | 65 header_buffer.CopyTo(header, kHeaderSize); |
| 64 *size = rtc::GetBE32(header); | 66 *size = rtc::GetBE32(header); |
| 65 buffer_.CropFront(kHeaderSize); | 67 buffer_.CropFront(kHeaderSize); |
| 66 return true; | 68 return true; |
| 67 } | 69 } |
| 68 | 70 |
| 69 } // namespace protocol | 71 } // namespace protocol |
| 70 } // namespace remoting | 72 } // namespace remoting |
| OLD | NEW |