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

Side by Side Diff: chrome/browser/sync/api/sync_data.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
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 "chrome/browser/sync/api/sync_data.h" 5 #include "chrome/browser/sync/api/sync_data.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 std::string SyncData::ToString() const { 116 std::string SyncData::ToString() const {
117 if (!IsValid()) 117 if (!IsValid())
118 return "<Invalid SyncData>"; 118 return "<Invalid SyncData>";
119 119
120 std::string type = syncable::ModelTypeToString(GetDataType()); 120 std::string type = syncable::ModelTypeToString(GetDataType());
121 std::string specifics; 121 std::string specifics;
122 scoped_ptr<DictionaryValue> value( 122 scoped_ptr<DictionaryValue> value(
123 browser_sync::EntitySpecificsToValue(GetSpecifics())); 123 browser_sync::EntitySpecificsToValue(GetSpecifics()));
124 base::JSONWriter::Write(value.get(), true, &specifics); 124 base::JSONWriter::WriteWithOptions(value.get(),
125 base::JSONWriter::OPTIONS_PRETTY_PRINT,
126 &specifics);
125 127
126 if (IsLocal()) { 128 if (IsLocal()) {
127 return "{ isLocal: true, type: " + type + ", tag: " + GetTag() + 129 return "{ isLocal: true, type: " + type + ", tag: " + GetTag() +
128 ", title: " + GetTitle() + ", specifics: " + specifics + "}"; 130 ", title: " + GetTitle() + ", specifics: " + specifics + "}";
129 } 131 }
130 132
131 std::string id = base::Int64ToString(GetRemoteId()); 133 std::string id = base::Int64ToString(GetRemoteId());
132 return "{ isLocal: false, type: " + type + ", specifics: " + specifics + 134 return "{ isLocal: false, type: " + type + ", specifics: " + specifics +
133 ", id: " + id + "}"; 135 ", id: " + id + "}";
134 } 136 }
135 137
136 void PrintTo(const SyncData& sync_data, std::ostream* os) { 138 void PrintTo(const SyncData& sync_data, std::ostream* os) {
137 *os << sync_data.ToString(); 139 *os << sync_data.ToString();
138 } 140 }
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_input_extension_manager.cc ('k') | chrome/browser/sync/notifier/p2p_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698