| 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/proximity_auth/wire_message.h" | 5 #include "components/proximity_auth/wire_message.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 WireMessage::~WireMessage() { | 75 WireMessage::~WireMessage() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 // static | 78 // static |
| 79 scoped_ptr<WireMessage> WireMessage::Deserialize( | 79 scoped_ptr<WireMessage> WireMessage::Deserialize( |
| 80 const std::string& serialized_message, | 80 const std::string& serialized_message, |
| 81 bool* is_incomplete_message) { | 81 bool* is_incomplete_message) { |
| 82 if (!ParseHeader(serialized_message, is_incomplete_message)) | 82 if (!ParseHeader(serialized_message, is_incomplete_message)) |
| 83 return scoped_ptr<WireMessage>(); | 83 return scoped_ptr<WireMessage>(); |
| 84 | 84 |
| 85 scoped_ptr<base::Value> body_value(base::JSONReader::DeprecatedRead( | 85 scoped_ptr<base::Value> body_value = |
| 86 serialized_message.substr(kHeaderLength))); | 86 base::JSONReader::Read(serialized_message.substr(kHeaderLength)); |
| 87 if (!body_value || !body_value->IsType(base::Value::TYPE_DICTIONARY)) { | 87 if (!body_value || !body_value->IsType(base::Value::TYPE_DICTIONARY)) { |
| 88 PA_LOG(WARNING) << "Error: Unable to parse message as JSON."; | 88 PA_LOG(WARNING) << "Error: Unable to parse message as JSON."; |
| 89 return scoped_ptr<WireMessage>(); | 89 return scoped_ptr<WireMessage>(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 base::DictionaryValue* body; | 92 base::DictionaryValue* body; |
| 93 bool success = body_value->GetAsDictionary(&body); | 93 bool success = body_value->GetAsDictionary(&body); |
| 94 DCHECK(success); | 94 DCHECK(success); |
| 95 | 95 |
| 96 // The permit ID is optional. In the Easy Unlock protocol, only the first | 96 // The permit ID is optional. In the Easy Unlock protocol, only the first |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 | 157 |
| 158 WireMessage::WireMessage(const std::string& payload) | 158 WireMessage::WireMessage(const std::string& payload) |
| 159 : WireMessage(payload, std::string()) {} | 159 : WireMessage(payload, std::string()) {} |
| 160 | 160 |
| 161 WireMessage::WireMessage(const std::string& payload, | 161 WireMessage::WireMessage(const std::string& payload, |
| 162 const std::string& permit_id) | 162 const std::string& permit_id) |
| 163 : payload_(payload), permit_id_(permit_id) {} | 163 : payload_(payload), permit_id_(permit_id) {} |
| 164 | 164 |
| 165 } // namespace proximity_auth | 165 } // namespace proximity_auth |
| OLD | NEW |