| OLD | NEW |
| 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 #include "remoting/base/protocol_decoder.h" | 5 #include "remoting/base/protocol_decoder.h" |
| 6 | 6 |
| 7 #include "remoting/base/multiple_array_input_stream.h" | 7 #include "remoting/base/multiple_array_input_stream.h" |
| 8 #include "talk/base/byteorder.h" | 8 #include "talk/base/byteorder.h" |
| 9 | 9 |
| 10 namespace remoting { | 10 namespace remoting { |
| 11 | 11 |
| 12 ProtocolDecoder::ProtocolDecoder() | 12 ProtocolDecoder::ProtocolDecoder() |
| 13 : last_read_position_(0), | 13 : last_read_position_(0), |
| 14 available_bytes_(0), | 14 available_bytes_(0), |
| 15 next_payload_(0), | 15 next_payload_(0), |
| 16 next_payload_known_(false) { | 16 next_payload_known_(false) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 void ProtocolDecoder::ParseClientMessages(scoped_refptr<media::DataBuffer> data, | 19 void ProtocolDecoder::ParseClientMessages(scoped_refptr<media::DataBuffer> data, |
| 20 ClientMessageList* messages) { | 20 ClientMessageList* messages) { |
| 21 ParseMessages<chromotocol_pb::ClientMessage>(data, messages); | 21 ParseMessages<ClientMessage>(data, messages); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void ProtocolDecoder::ParseHostMessages(scoped_refptr<media::DataBuffer> data, | 24 void ProtocolDecoder::ParseHostMessages(scoped_refptr<media::DataBuffer> data, |
| 25 HostMessageList* messages) { | 25 HostMessageList* messages) { |
| 26 ParseMessages<chromotocol_pb::HostMessage>(data, messages); | 26 ParseMessages<HostMessage>(data, messages); |
| 27 } | 27 } |
| 28 | 28 |
| 29 template <typename T> | 29 template <typename T> |
| 30 void ProtocolDecoder::ParseMessages(scoped_refptr<media::DataBuffer> data, | 30 void ProtocolDecoder::ParseMessages(scoped_refptr<media::DataBuffer> data, |
| 31 std::vector<T*>* messages) { | 31 std::vector<T*>* messages) { |
| 32 // If this is the first data in the processing queue, then set the | 32 // If this is the first data in the processing queue, then set the |
| 33 // last read position to 0. | 33 // last read position to 0. |
| 34 if (data_list_.empty()) | 34 if (data_list_.empty()) |
| 35 last_read_position_ = 0; | 35 last_read_position_ = 0; |
| 36 | 36 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 if (header.length() == kHeaderSize) { | 141 if (header.length() == kHeaderSize) { |
| 142 *size = talk_base::GetBE32(header.c_str()); | 142 *size = talk_base::GetBE32(header.c_str()); |
| 143 return true; | 143 return true; |
| 144 } | 144 } |
| 145 NOTREACHED() << "Unable to extract payload size"; | 145 NOTREACHED() << "Unable to extract payload size"; |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace remoting | 149 } // namespace remoting |
| OLD | NEW |