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 "sync/api/sync_data.h" | 5 #include "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 bool SyncData::IsLocal() const { | 114 bool SyncData::IsLocal() const { |
115 return id_ == kInvalidId; | 115 return id_ == kInvalidId; |
116 } | 116 } |
117 | 117 |
118 std::string SyncData::ToString() const { | 118 std::string SyncData::ToString() const { |
119 if (!IsValid()) | 119 if (!IsValid()) |
120 return "<Invalid SyncData>"; | 120 return "<Invalid SyncData>"; |
121 | 121 |
122 std::string type = ModelTypeToString(GetDataType()); | 122 std::string type = ModelTypeToString(GetDataType()); |
123 std::string specifics; | 123 std::string specifics; |
124 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(GetSpecifics())); | 124 scoped_ptr<base::DictionaryValue> value( |
| 125 EntitySpecificsToValue(GetSpecifics())); |
125 base::JSONWriter::WriteWithOptions(value.get(), | 126 base::JSONWriter::WriteWithOptions(value.get(), |
126 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 127 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
127 &specifics); | 128 &specifics); |
128 | 129 |
129 if (IsLocal()) { | 130 if (IsLocal()) { |
130 return "{ isLocal: true, type: " + type + ", tag: " + GetTag() + | 131 return "{ isLocal: true, type: " + type + ", tag: " + GetTag() + |
131 ", title: " + GetTitle() + ", specifics: " + specifics + "}"; | 132 ", title: " + GetTitle() + ", specifics: " + specifics + "}"; |
132 } | 133 } |
133 | 134 |
134 std::string id = base::Int64ToString(GetRemoteId()); | 135 std::string id = base::Int64ToString(GetRemoteId()); |
135 return "{ isLocal: false, type: " + type + ", specifics: " + specifics + | 136 return "{ isLocal: false, type: " + type + ", specifics: " + specifics + |
136 ", id: " + id + "}"; | 137 ", id: " + id + "}"; |
137 } | 138 } |
138 | 139 |
139 void PrintTo(const SyncData& sync_data, std::ostream* os) { | 140 void PrintTo(const SyncData& sync_data, std::ostream* os) { |
140 *os << sync_data.ToString(); | 141 *os << sync_data.ToString(); |
141 } | 142 } |
142 | 143 |
143 } // namespace syncer | 144 } // namespace syncer |
OLD | NEW |