| 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 COMPONENTS_PAIRING_PROTO_DECODER_H_ | 5 #ifndef COMPONENTS_PAIRING_PROTO_DECODER_H_ |
| 6 #define COMPONENTS_PAIRING_PROTO_DECODER_H_ | 6 #define COMPONENTS_PAIRING_PROTO_DECODER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 explicit ProtoDecoder(Observer* observer); | 61 explicit ProtoDecoder(Observer* observer); |
| 62 ~ProtoDecoder(); | 62 ~ProtoDecoder(); |
| 63 | 63 |
| 64 // Decodes the data from an io_buffer, and sends out events for any complete | 64 // Decodes the data from an io_buffer, and sends out events for any complete |
| 65 // messages. | 65 // messages. |
| 66 bool DecodeIOBuffer(int size, IOBufferRefPtr io_buffer); | 66 bool DecodeIOBuffer(int size, IOBufferRefPtr io_buffer); |
| 67 | 67 |
| 68 // Convenience functions for serializing messages into an IOBuffer. | 68 // Convenience functions for serializing messages into an IOBuffer. |
| 69 static IOBufferRefPtr SendHostStatus(const pairing_api::HostStatus& message, | 69 static IOBufferRefPtr SendHostStatus(const pairing_api::HostStatus& message, |
| 70 int* size); | 70 int* size); |
| 71 static IOBufferRefPtr SendHostNetwork(const pairing_api::AddNetwork& message, |
| 72 int* size); |
| 71 static IOBufferRefPtr SendConfigureHost( | 73 static IOBufferRefPtr SendConfigureHost( |
| 72 const pairing_api::ConfigureHost& message, int* size); | 74 const pairing_api::ConfigureHost& message, int* size); |
| 73 static IOBufferRefPtr SendPairDevices(const pairing_api::PairDevices& message, | 75 static IOBufferRefPtr SendPairDevices(const pairing_api::PairDevices& message, |
| 74 int* size); | 76 int* size); |
| 75 static IOBufferRefPtr SendCompleteSetup( | 77 static IOBufferRefPtr SendCompleteSetup( |
| 76 const pairing_api::CompleteSetup& message, int* size); | 78 const pairing_api::CompleteSetup& message, int* size); |
| 77 static IOBufferRefPtr SendError(const pairing_api::Error& message, int* size); | 79 static IOBufferRefPtr SendError(const pairing_api::Error& message, int* size); |
| 78 | 80 |
| 79 private: | 81 private: |
| 80 static IOBufferRefPtr SendMessage(uint8_t message_type, | 82 static IOBufferRefPtr SendMessage(uint8_t message_type, |
| 81 const std::string& message, | 83 const std::string& message, |
| 82 int* size); | 84 int* size); |
| 83 | 85 |
| 84 Observer* observer_; | 86 Observer* observer_; |
| 85 MessageBuffer message_buffer_; | 87 MessageBuffer message_buffer_; |
| 86 int next_message_type_; | 88 int next_message_type_; |
| 87 int next_message_size_; | 89 int next_message_size_; |
| 88 | 90 |
| 89 DISALLOW_COPY_AND_ASSIGN(ProtoDecoder); | 91 DISALLOW_COPY_AND_ASSIGN(ProtoDecoder); |
| 90 }; | 92 }; |
| 91 | 93 |
| 92 } // namespace pairing_chromeos | 94 } // namespace pairing_chromeos |
| 93 | 95 |
| 94 #endif // COMPONENTS_PAIRING_PROTO_DECODER_H_ | 96 #endif // COMPONENTS_PAIRING_PROTO_DECODER_H_ |
| OLD | NEW |