OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/host/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 uint32_t length; | 270 uint32_t length; |
271 int read_result = output_read_file_.ReadAtCurrentPos( | 271 int read_result = output_read_file_.ReadAtCurrentPos( |
272 reinterpret_cast<char*>(&length), sizeof(length)); | 272 reinterpret_cast<char*>(&length), sizeof(length)); |
273 if (read_result != sizeof(length)) { | 273 if (read_result != sizeof(length)) { |
274 // The output pipe has been closed, return an empty message. | 274 // The output pipe has been closed, return an empty message. |
275 return nullptr; | 275 return nullptr; |
276 } | 276 } |
277 | 277 |
278 std::string message_json(length, '\0'); | 278 std::string message_json(length, '\0'); |
279 read_result = output_read_file_.ReadAtCurrentPos( | 279 read_result = output_read_file_.ReadAtCurrentPos( |
280 string_as_array(&message_json), length); | 280 base::string_as_array(&message_json), length); |
281 if (read_result != static_cast<int>(length)) { | 281 if (read_result != static_cast<int>(length)) { |
282 LOG(ERROR) << "Message size (" << read_result | 282 LOG(ERROR) << "Message size (" << read_result |
283 << ") doesn't match the header (" << length << ")."; | 283 << ") doesn't match the header (" << length << ")."; |
284 return nullptr; | 284 return nullptr; |
285 } | 285 } |
286 | 286 |
287 std::unique_ptr<base::Value> message = base::JSONReader::Read(message_json); | 287 std::unique_ptr<base::Value> message = base::JSONReader::Read(message_json); |
288 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { | 288 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { |
289 LOG(ERROR) << "Malformed message:" << message_json; | 289 LOG(ERROR) << "Malformed message:" << message_json; |
290 return nullptr; | 290 return nullptr; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 549 } |
550 | 550 |
551 // Verify rejection if type is unrecognized. | 551 // Verify rejection if type is unrecognized. |
552 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { | 552 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { |
553 base::DictionaryValue message; | 553 base::DictionaryValue message; |
554 message.SetString("type", "xxx"); | 554 message.SetString("type", "xxx"); |
555 TestBadRequest(message, true); | 555 TestBadRequest(message, true); |
556 } | 556 } |
557 | 557 |
558 } // namespace remoting | 558 } // namespace remoting |
OLD | NEW |