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

Side by Side Diff: jingle/glue/utils.cc

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "jingle/glue/utils.h" 5 #include "jingle/glue/utils.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 value.SetDouble("preference", candidate.preference()); 52 value.SetDouble("preference", candidate.preference());
53 value.SetInteger("generation", candidate.generation()); 53 value.SetInteger("generation", candidate.generation());
54 54
55 std::string result; 55 std::string result;
56 base::JSONWriter::Write(&value, &result); 56 base::JSONWriter::Write(&value, &result);
57 return result; 57 return result;
58 } 58 }
59 59
60 bool DeserializeP2PCandidate(const std::string& candidate_str, 60 bool DeserializeP2PCandidate(const std::string& candidate_str,
61 cricket::Candidate* candidate) { 61 cricket::Candidate* candidate) {
62 scoped_ptr<Value> value(base::JSONReader::Read(candidate_str, true)); 62 scoped_ptr<Value> value(
63 base::JSONReader::Read(candidate_str, base::JSON_ALLOW_TRAILING_COMMAS));
63 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 64 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
64 return false; 65 return false;
65 } 66 }
66 67
67 DictionaryValue* dic_value = static_cast<DictionaryValue*>(value.get()); 68 DictionaryValue* dic_value = static_cast<DictionaryValue*>(value.get());
68 69
69 std::string name; 70 std::string name;
70 std::string ip; 71 std::string ip;
71 int port; 72 int port;
72 std::string type; 73 std::string type;
(...skipping 21 matching lines...) Expand all
94 candidate->set_protocol(protocol); 95 candidate->set_protocol(protocol);
95 candidate->set_username(username); 96 candidate->set_username(username);
96 candidate->set_password(password); 97 candidate->set_password(password);
97 candidate->set_preference(static_cast<float>(preference)); 98 candidate->set_preference(static_cast<float>(preference));
98 candidate->set_generation(generation); 99 candidate->set_generation(generation);
99 100
100 return true; 101 return true;
101 } 102 }
102 103
103 } // namespace jingle_glue 104 } // namespace jingle_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698