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

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

Issue 9590002: JSONWriter cleanup: integrate pretty print into write options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict 7. Created 8 years, 9 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
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | net/base/transport_security_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 value.SetString("ip", candidate.address().IPAsString()); 46 value.SetString("ip", candidate.address().IPAsString());
47 value.SetInteger("port", candidate.address().port()); 47 value.SetInteger("port", candidate.address().port());
48 value.SetString("type", candidate.type()); 48 value.SetString("type", candidate.type());
49 value.SetString("protocol", candidate.protocol()); 49 value.SetString("protocol", candidate.protocol());
50 value.SetString("username", candidate.username()); 50 value.SetString("username", candidate.username());
51 value.SetString("password", candidate.password()); 51 value.SetString("password", candidate.password());
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, false, &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(base::JSONReader::Read(candidate_str, true));
63 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 63 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
64 return false; 64 return false;
65 } 65 }
66 66
(...skipping 27 matching lines...) Expand all
94 candidate->set_protocol(protocol); 94 candidate->set_protocol(protocol);
95 candidate->set_username(username); 95 candidate->set_username(username);
96 candidate->set_password(password); 96 candidate->set_password(password);
97 candidate->set_preference(static_cast<float>(preference)); 97 candidate->set_preference(static_cast<float>(preference));
98 candidate->set_generation(generation); 98 candidate->set_generation(generation);
99 99
100 return true; 100 return true;
101 } 101 }
102 102
103 } // namespace jingle_glue 103 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | net/base/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698