diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc index 9d959e64193a95..3b735e9eccfd72 100644 --- a/sync/syncable/directory.cc +++ b/sync/syncable/directory.cc @@ -1470,7 +1470,7 @@ void Directory::PutPredecessor(EntryKernel* e, EntryKernel* predecessor) { // without valid positions. See TODO above. // Using a release CHECK here because the following UniquePosition::Between // call crashes anyway when the position string is empty (see crbug/332371). - CHECK(successor->ref(UNIQUE_POSITION).IsValid()); + CHECK(successor->ref(UNIQUE_POSITION).IsValid()) << *successor; // Finally, the normal case: inserting between two elements. UniquePosition pos = UniquePosition::Between( diff --git a/sync/syncable/entry.cc b/sync/syncable/entry.cc index e9d4ec14ede386..ca249e5dc978a1 100644 --- a/sync/syncable/entry.cc +++ b/sync/syncable/entry.cc @@ -6,13 +6,8 @@ #include -#include "base/json/string_escape.h" -#include "base/strings/string_util.h" #include "sync/syncable/directory.h" #include "sync/syncable/syncable_base_transaction.h" -#include "sync/syncable/syncable_columns.h" - -using std::string; namespace syncer { namespace syncable { @@ -22,7 +17,7 @@ Entry::Entry(BaseTransaction* trans, GetById, const Id& id) kernel_ = trans->directory()->GetEntryById(id); } -Entry::Entry(BaseTransaction* trans, GetByClientTag, const string& tag) +Entry::Entry(BaseTransaction* trans, GetByClientTag, const std::string& tag) : basetrans_(trans) { kernel_ = trans->directory()->GetEntryByClientTag(tag); } @@ -38,7 +33,7 @@ Entry::Entry(BaseTransaction* trans, GetByHandle, int64 metahandle) kernel_ = trans->directory()->GetEntryByHandle(metahandle); } -Entry::Entry(BaseTransaction* trans, GetByServerTag, const string& tag) +Entry::Entry(BaseTransaction* trans, GetByServerTag, const std::string& tag) : basetrans_(trans) { kernel_ = trans->directory()->GetEntryByServerTag(tag); } @@ -135,52 +130,7 @@ bool Entry::ShouldMaintainHierarchy() const { } std::ostream& operator<<(std::ostream& os, const Entry& entry) { - int i; - EntryKernel* const kernel = entry.kernel_; - for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << kernel->ref(static_cast(i)) << ", "; - } - for ( ; i < TIME_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << GetTimeDebugString(kernel->ref(static_cast(i))) << ", "; - } - for ( ; i < ID_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << kernel->ref(static_cast(i)) << ", "; - } - os << "Flags: "; - for ( ; i < BIT_FIELDS_END; ++i) { - if (kernel->ref(static_cast(i))) - os << g_metas_columns[i].name << ", "; - } - for ( ; i < STRING_FIELDS_END; ++i) { - const std::string& field = kernel->ref(static_cast(i)); - os << g_metas_columns[i].name << ": " << field << ", "; - } - for ( ; i < PROTO_FIELDS_END; ++i) { - std::string escaped_str = base::EscapeBytesAsInvalidJSONString( - kernel->ref(static_cast(i)).SerializeAsString(), - false); - os << g_metas_columns[i].name << ": " << escaped_str << ", "; - } - for ( ; i < UNIQUE_POSITION_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << kernel->ref(static_cast(i)).ToDebugString() - << ", "; - } - for ( ; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { - std::string escaped_str = base::EscapeBytesAsInvalidJSONString( - kernel->ref(static_cast(i)) - .SerializeAsString(), - false); - os << g_metas_columns[i].name << ": " << escaped_str << ", "; - } - os << "TempFlags: "; - for ( ; i < BIT_TEMPS_END; ++i) { - if (kernel->ref(static_cast(i))) - os << "#" << i - BIT_TEMPS_BEGIN << ", "; - } + os << *(entry.kernel_); return os; } diff --git a/sync/syncable/entry_kernel.cc b/sync/syncable/entry_kernel.cc index d73acafd850f76..8fb611f23b400c 100644 --- a/sync/syncable/entry_kernel.cc +++ b/sync/syncable/entry_kernel.cc @@ -4,8 +4,10 @@ #include "sync/syncable/entry_kernel.h" +#include "base/json/string_escape.h" #include "base/strings/string_number_conversions.h" #include "sync/protocol/proto_value_conversions.h" +#include "sync/syncable/syncable_columns.h" #include "sync/syncable/syncable_enum_conversions.h" #include "sync/util/cryptographer.h" @@ -236,5 +238,54 @@ base::DictionaryValue* EntryKernelMutationToValue( return dict; } +std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel) { + int i; + EntryKernel* const kernel = const_cast(&entry_kernel); + for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast(i)) << ", "; + } + for (; i < TIME_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << GetTimeDebugString(kernel->ref(static_cast(i))) << ", "; + } + for (; i < ID_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast(i)) << ", "; + } + os << "Flags: "; + for (; i < BIT_FIELDS_END; ++i) { + if (kernel->ref(static_cast(i))) + os << g_metas_columns[i].name << ", "; + } + for (; i < STRING_FIELDS_END; ++i) { + const std::string& field = kernel->ref(static_cast(i)); + os << g_metas_columns[i].name << ": " << field << ", "; + } + for (; i < PROTO_FIELDS_END; ++i) { + std::string escaped_str = base::EscapeBytesAsInvalidJSONString( + kernel->ref(static_cast(i)).SerializeAsString(), false); + os << g_metas_columns[i].name << ": " << escaped_str << ", "; + } + for (; i < UNIQUE_POSITION_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast(i)).ToDebugString() + << ", "; + } + for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { + std::string escaped_str = base::EscapeBytesAsInvalidJSONString( + kernel->ref(static_cast(i)) + .SerializeAsString(), + false); + os << g_metas_columns[i].name << ": " << escaped_str << ", "; + } + os << "TempFlags: "; + for (; i < BIT_TEMPS_END; ++i) { + if (kernel->ref(static_cast(i))) + os << "#" << i - BIT_TEMPS_BEGIN << ", "; + } + return os; +} + } // namespace syncer } // namespace syncable diff --git a/sync/syncable/entry_kernel.h b/sync/syncable/entry_kernel.h index 746d644d1825ea..c1fc5e548a1452 100644 --- a/sync/syncable/entry_kernel.h +++ b/sync/syncable/entry_kernel.h @@ -124,8 +124,8 @@ enum StringField { // A tag string which identifies this node as a particular top-level // permanent object. The tag can be thought of as a unique key that // identifies a singleton instance. - UNIQUE_SERVER_TAG, // Tagged by the server - UNIQUE_CLIENT_TAG, // Tagged by the client + UNIQUE_SERVER_TAG, // Tagged by the server + UNIQUE_CLIENT_TAG, // Tagged by the client UNIQUE_BOOKMARK_TAG, // Client tags for bookmark items STRING_FIELDS_END, }; @@ -191,8 +191,6 @@ enum { BIT_TEMPS_COUNT = BIT_TEMPS_END - BIT_TEMPS_BEGIN }; - - struct SYNC_EXPORT_PRIVATE EntryKernel { private: std::string string_fields[STRING_FIELDS_COUNT]; @@ -206,6 +204,8 @@ struct SYNC_EXPORT_PRIVATE EntryKernel { std::bitset bit_fields; std::bitset bit_temps; + friend std::ostream& operator<<(std::ostream& s, const EntryKernel& e); + public: EntryKernel(); ~EntryKernel(); @@ -405,6 +405,8 @@ base::DictionaryValue* EntryKernelMutationToValue( base::ListValue* EntryKernelMutationMapToValue( const EntryKernelMutationMap& mutations); +std::ostream& operator<<(std::ostream& os, const EntryKernel& entry_kernel); + } // namespace syncable } // namespace syncer