diff options
author | gangwu <gangwu@chromium.org> | 2015-08-07 13:58:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 20:58:55 +0000 |
commit | 81f85526af97a9e160aa839c9460b535694a0e04 (patch) | |
tree | 82c8394e13a3749d279848d406acb39444a7864b /sync/syncable | |
parent | 46a37de67fddcbab4d9adc7b5ade79f582af8b93 (diff) | |
download | chromium_src-81f85526af97a9e160aa839c9460b535694a0e04.zip chromium_src-81f85526af97a9e160aa839c9460b535694a0e04.tar.gz chromium_src-81f85526af97a9e160aa839c9460b535694a0e04.tar.bz2 |
Add more info for invalid position check.
BUG=332371
Review URL: https://codereview.chromium.org/1258863007
Cr-Commit-Position: refs/heads/master@{#342437}
Diffstat (limited to 'sync/syncable')
-rw-r--r-- | sync/syncable/directory.cc | 2 | ||||
-rw-r--r-- | sync/syncable/entry.cc | 56 | ||||
-rw-r--r-- | sync/syncable/entry_kernel.cc | 51 | ||||
-rw-r--r-- | sync/syncable/entry_kernel.h | 10 |
4 files changed, 61 insertions, 58 deletions
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc index 9d959e6..3b735e9 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 e9d4ec1..ca249e5 100644 --- a/sync/syncable/entry.cc +++ b/sync/syncable/entry.cc @@ -6,13 +6,8 @@ #include <iomanip> -#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<Int64Field>(i)) << ", "; - } - for ( ; i < TIME_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << GetTimeDebugString(kernel->ref(static_cast<TimeField>(i))) << ", "; - } - for ( ; i < ID_FIELDS_END; ++i) { - os << g_metas_columns[i].name << ": " - << kernel->ref(static_cast<IdField>(i)) << ", "; - } - os << "Flags: "; - for ( ; i < BIT_FIELDS_END; ++i) { - if (kernel->ref(static_cast<BitField>(i))) - os << g_metas_columns[i].name << ", "; - } - for ( ; i < STRING_FIELDS_END; ++i) { - const std::string& field = kernel->ref(static_cast<StringField>(i)); - os << g_metas_columns[i].name << ": " << field << ", "; - } - for ( ; i < PROTO_FIELDS_END; ++i) { - std::string escaped_str = base::EscapeBytesAsInvalidJSONString( - kernel->ref(static_cast<ProtoField>(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<UniquePositionField>(i)).ToDebugString() - << ", "; - } - for ( ; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { - std::string escaped_str = base::EscapeBytesAsInvalidJSONString( - kernel->ref(static_cast<AttachmentMetadataField>(i)) - .SerializeAsString(), - false); - os << g_metas_columns[i].name << ": " << escaped_str << ", "; - } - os << "TempFlags: "; - for ( ; i < BIT_TEMPS_END; ++i) { - if (kernel->ref(static_cast<BitTemp>(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 d73acaf..8fb611f 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<EntryKernel*>(&entry_kernel); + for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast<Int64Field>(i)) << ", "; + } + for (; i < TIME_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << GetTimeDebugString(kernel->ref(static_cast<TimeField>(i))) << ", "; + } + for (; i < ID_FIELDS_END; ++i) { + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast<IdField>(i)) << ", "; + } + os << "Flags: "; + for (; i < BIT_FIELDS_END; ++i) { + if (kernel->ref(static_cast<BitField>(i))) + os << g_metas_columns[i].name << ", "; + } + for (; i < STRING_FIELDS_END; ++i) { + const std::string& field = kernel->ref(static_cast<StringField>(i)); + os << g_metas_columns[i].name << ": " << field << ", "; + } + for (; i < PROTO_FIELDS_END; ++i) { + std::string escaped_str = base::EscapeBytesAsInvalidJSONString( + kernel->ref(static_cast<ProtoField>(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<UniquePositionField>(i)).ToDebugString() + << ", "; + } + for (; i < ATTACHMENT_METADATA_FIELDS_END; ++i) { + std::string escaped_str = base::EscapeBytesAsInvalidJSONString( + kernel->ref(static_cast<AttachmentMetadataField>(i)) + .SerializeAsString(), + false); + os << g_metas_columns[i].name << ": " << escaped_str << ", "; + } + os << "TempFlags: "; + for (; i < BIT_TEMPS_END; ++i) { + if (kernel->ref(static_cast<BitTemp>(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 746d644..c1fc5e5 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_COUNT> bit_fields; std::bitset<BIT_TEMPS_COUNT> 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 |