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 #include "components/pairing/proto_decoder.h" | 5 #include "components/pairing/proto_decoder.h" |
6 | 6 |
7 #include "components/pairing/pairing_api.pb.h" | 7 #include "components/pairing/pairing_api.pb.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 ProtoDecoder::IOBufferRefPtr ProtoDecoder::SendHostStatus( | 128 ProtoDecoder::IOBufferRefPtr ProtoDecoder::SendHostStatus( |
129 const pairing_api::HostStatus& message, int* size) { | 129 const pairing_api::HostStatus& message, int* size) { |
130 std::string serialized_proto; | 130 std::string serialized_proto; |
131 if (!message.SerializeToString(&serialized_proto)) { | 131 if (!message.SerializeToString(&serialized_proto)) { |
132 NOTREACHED(); | 132 NOTREACHED(); |
133 } | 133 } |
134 | 134 |
135 return SendMessage(MESSAGE_HOST_STATUS, serialized_proto, size); | 135 return SendMessage(MESSAGE_HOST_STATUS, serialized_proto, size); |
136 } | 136 } |
137 | 137 |
138 ProtoDecoder::IOBufferRefPtr ProtoDecoder::SendHostNetwork( | |
139 const pairing_api::AddNetwork& message, | |
140 int* size) { | |
141 std::string serialized_proto; | |
142 if (!message.SerializeToString(&serialized_proto)) { | |
achuithb
2015/11/05 23:26:12
Don't need {}
xdai1
2015/11/06 23:23:02
Done.
| |
143 NOTREACHED(); | |
144 } | |
145 | |
146 return SendMessage(MESSAGE_ADD_NETWORK, serialized_proto, size); | |
147 } | |
148 | |
138 ProtoDecoder::IOBufferRefPtr ProtoDecoder::SendConfigureHost( | 149 ProtoDecoder::IOBufferRefPtr ProtoDecoder::SendConfigureHost( |
139 const pairing_api::ConfigureHost& message, int* size) { | 150 const pairing_api::ConfigureHost& message, int* size) { |
140 std::string serialized_proto; | 151 std::string serialized_proto; |
141 if (!message.SerializeToString(&serialized_proto)) { | 152 if (!message.SerializeToString(&serialized_proto)) { |
142 NOTREACHED(); | 153 NOTREACHED(); |
143 } | 154 } |
144 | 155 |
145 return SendMessage(MESSAGE_CONFIGURE_HOST, serialized_proto, size); | 156 return SendMessage(MESSAGE_CONFIGURE_HOST, serialized_proto, size); |
146 } | 157 } |
147 | 158 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 memcpy(&io_buffer->data()[offset], &data, sizeof(data)); | 210 memcpy(&io_buffer->data()[offset], &data, sizeof(data)); |
200 offset += sizeof(data); | 211 offset += sizeof(data); |
201 | 212 |
202 // Write the actual message. | 213 // Write the actual message. |
203 memcpy(&io_buffer->data()[offset], message.data(), message.size()); | 214 memcpy(&io_buffer->data()[offset], message.data(), message.size()); |
204 | 215 |
205 return io_buffer; | 216 return io_buffer; |
206 } | 217 } |
207 | 218 |
208 } // namespace pairing_chromeos | 219 } // namespace pairing_chromeos |
OLD | NEW |