Chromium Code Reviews| Index: chrome/browser/sync/api/sync_data.cc |
| diff --git a/chrome/browser/sync/api/sync_data.cc b/chrome/browser/sync/api/sync_data.cc |
| index 1c2d4967423cc72cb69288fdb3a7fe96d807d96e..5561d5144797629380978491919708e082a50db3 100644 |
| --- a/chrome/browser/sync/api/sync_data.cc |
| +++ b/chrome/browser/sync/api/sync_data.cc |
| @@ -4,8 +4,17 @@ |
| #include "chrome/browser/sync/api/sync_data.h" |
| +#include <ostream> |
| + |
| +#include "base/json/json_writer.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "base/values.h" |
| #include "chrome/browser/sync/internal_api/base_node.h" |
| +#include "chrome/browser/sync/protocol/proto_value_conversions.h" |
| #include "chrome/browser/sync/protocol/sync.pb.h" |
| +#include "chrome/browser/sync/syncable/model_type.h" |
| +#include "ui/base/text/bytes_formatting.h" |
| void SyncData::ImmutableSyncEntityTraits::InitializeWrapper( |
| Wrapper* wrapper) { |
| @@ -102,3 +111,26 @@ int64 SyncData::GetRemoteId() const { |
| bool SyncData::IsLocal() const { |
| return id_ == sync_api::kInvalidId; |
| } |
| + |
| +std::string SyncData::ToString() const { |
| + if (!IsValid()) |
| + return "<Invalid SyncData>"; |
| + |
| + std::string type = syncable::ModelTypeToString(GetDataType()); |
| + std::string specifics; |
| + scoped_ptr<DictionaryValue> value( |
| + browser_sync::EntitySpecificsToValue(GetSpecifics())); |
| + base::JSONWriter::Write(value.get(), true, &specifics); |
| + |
| + if (IsLocal()) { |
| + std::string tag = IsLocal() ? GetTag() : ""; |
|
akalin
2011/09/22 02:59:44
std::string tag = GetTag();
Or just inline it to
James Hawkins
2011/09/22 21:01:58
Done.
|
| + return "{" + type + ", " + tag + ", " + GetTitle() + ", " + specifics + "}"; |
|
akalin
2011/09/22 02:59:44
return "{ isLocal: true, type: " + type + ", tag:
James Hawkins
2011/09/22 21:01:58
Done.
|
| + } |
| + |
| + std::string id = UTF16ToUTF8(ui::FormatBytes(GetRemoteId())); |
|
akalin
2011/09/22 02:59:44
eh? Just do base::Int64ToString(GetRemoteId()) (#
James Hawkins
2011/09/22 21:01:58
Done.
|
| + return "{" + type + ", " + specifics + ", " + id + "}"; |
|
akalin
2011/09/22 02:59:44
return "{ isLocal: false, type: " + ... + ", speci
James Hawkins
2011/09/22 21:01:58
Done.
|
| +} |
| + |
| +void PrintTo(const SyncData& sync_data, std::ostream* os) { |
| + *os << sync_data.ToString(); |
| +} |