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

Unified Diff: chrome/browser/sync/api/sync_data.cc

Issue 7978044: Sync/Valgrind: Add gmock printers for SyncChange, SyncData, SyncError. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes 3. Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/api/sync_data.h ('k') | chrome/browser/sync/api/sync_error.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c5c6982dcfab625dc19e77db3670f7afefb79e19 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/string_number_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"
akalin 2011/09/22 21:12:42 no need for this include
void SyncData::ImmutableSyncEntityTraits::InitializeWrapper(
Wrapper* wrapper) {
@@ -102,3 +111,27 @@ 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()) {
+ return "{ isLocal: true, type: " + type + ", tag: " + GetTag() +
+ ", title: " + GetTitle() + ", specifics: " + specifics + "}";
+ }
+
+ std::string id = base:Int64ToString(GetRemoteId());
+ return "{ isLocal: false, type: " + type + ", specifics: " + specifics +
+ ", ID: " + id + "}";
akalin 2011/09/22 21:12:42 prefer 'id' (Javascript/JSON-style casing)
+}
+
+void PrintTo(const SyncData& sync_data, std::ostream* os) {
+ *os << sync_data.ToString();
+}
« no previous file with comments | « chrome/browser/sync/api/sync_data.h ('k') | chrome/browser/sync/api/sync_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698