Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Side by Side Diff: components/proximity_auth/wire_message.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // static 82 // static
83 std::unique_ptr<WireMessage> WireMessage::Deserialize( 83 std::unique_ptr<WireMessage> WireMessage::Deserialize(
84 const std::string& serialized_message, 84 const std::string& serialized_message,
85 bool* is_incomplete_message) { 85 bool* is_incomplete_message) {
86 if (!ParseHeader(serialized_message, is_incomplete_message)) 86 if (!ParseHeader(serialized_message, is_incomplete_message))
87 return std::unique_ptr<WireMessage>(); 87 return std::unique_ptr<WireMessage>();
88 88
89 std::unique_ptr<base::Value> body_value = 89 std::unique_ptr<base::Value> body_value =
90 base::JSONReader::Read(serialized_message.substr(kHeaderLength)); 90 base::JSONReader::Read(serialized_message.substr(kHeaderLength));
91 if (!body_value || !body_value->IsType(base::Value::TYPE_DICTIONARY)) { 91 if (!body_value || !body_value->IsType(base::Value::Type::DICTIONARY)) {
92 PA_LOG(WARNING) << "Error: Unable to parse message as JSON."; 92 PA_LOG(WARNING) << "Error: Unable to parse message as JSON.";
93 return std::unique_ptr<WireMessage>(); 93 return std::unique_ptr<WireMessage>();
94 } 94 }
95 95
96 base::DictionaryValue* body; 96 base::DictionaryValue* body;
97 bool success = body_value->GetAsDictionary(&body); 97 bool success = body_value->GetAsDictionary(&body);
98 DCHECK(success); 98 DCHECK(success);
99 99
100 // The permit ID is optional. In the Easy Unlock protocol, only the first 100 // The permit ID is optional. In the Easy Unlock protocol, only the first
101 // message includes this field. 101 // message includes this field.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 WireMessage::WireMessage(const std::string& payload) 165 WireMessage::WireMessage(const std::string& payload)
166 : WireMessage(payload, std::string()) {} 166 : WireMessage(payload, std::string()) {}
167 167
168 WireMessage::WireMessage(const std::string& payload, 168 WireMessage::WireMessage(const std::string& payload,
169 const std::string& permit_id) 169 const std::string& permit_id)
170 : payload_(payload), permit_id_(permit_id) {} 170 : payload_(payload), permit_id_(permit_id) {}
171 171
172 } // namespace proximity_auth 172 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698