OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |