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..f81d4fac7d44e68bb963133be3f73b08a2395b5f 100644 |
--- a/chrome/browser/sync/api/sync_data.cc |
+++ b/chrome/browser/sync/api/sync_data.cc |
@@ -4,8 +4,16 @@ |
#include "chrome/browser/sync/api/sync_data.h" |
+#include <iostream> |
akalin
2011/09/22 01:24:56
iostream -> ostream
James Hawkins
2011/09/22 02:50:29
Done.
|
+#include <sstream> |
+ |
+#include "base/json/json_writer.h" |
+#include "base/memory/scoped_ptr.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" |
void SyncData::ImmutableSyncEntityTraits::InitializeWrapper( |
Wrapper* wrapper) { |
@@ -102,3 +110,29 @@ int64 SyncData::GetRemoteId() const { |
bool SyncData::IsLocal() const { |
return id_ == sync_api::kInvalidId; |
} |
+ |
+std::string SyncData::ToString() const { |
+ int64 id = IsLocal() ? 0 : GetRemoteId(); |
akalin
2011/09/22 01:24:56
prefer something like:
if (IsValid()) {
if (IsL
James Hawkins
2011/09/22 02:50:29
Done.
|
+ const std::string& tag = IsLocal() ? GetTag() : ""; |
+ std::string specifics; |
+ scoped_ptr<DictionaryValue> value( |
+ browser_sync::EntitySpecificsToValue(GetSpecifics())); |
+ base::JSONWriter::Write(value.get(), true, &specifics); |
+ |
+ std::string out; |
+ std::stringstream ss(out, std::stringstream::in); |
+ ss << |
+ "{" << id << |
+ ", " << IsValid() << |
+ ", " << IsLocal() << |
+ ", " << syncable::ModelTypeToString(GetDataType()) << |
+ ", " << tag << |
+ ", " << GetTitle() << |
+ ", " << specifics << |
+ "}"; |
+ return out; |
+} |
+ |
+void PrintTo(const SyncData& sync_data, std::ostream* os) { |
+ *os << sync_data.ToString(); |
+} |