| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/syncable/entry.h" | 5 #include "sync/syncable/entry.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
| 10 #include "sync/syncable/base_transaction.h" | 10 #include "sync/syncable/base_transaction.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 entry_info->SetBoolean("isRoot", IsRoot()); | 57 entry_info->SetBoolean("isRoot", IsRoot()); |
| 58 } | 58 } |
| 59 return entry_info; | 59 return entry_info; |
| 60 } | 60 } |
| 61 | 61 |
| 62 const string& Entry::Get(StringField field) const { | 62 const string& Entry::Get(StringField field) const { |
| 63 DCHECK(kernel_); | 63 DCHECK(kernel_); |
| 64 return kernel_->ref(field); | 64 return kernel_->ref(field); |
| 65 } | 65 } |
| 66 | 66 |
| 67 syncer::ModelType Entry::GetServerModelType() const { | 67 ModelType Entry::GetServerModelType() const { |
| 68 ModelType specifics_type = kernel_->GetServerModelType(); | 68 ModelType specifics_type = kernel_->GetServerModelType(); |
| 69 if (specifics_type != UNSPECIFIED) | 69 if (specifics_type != UNSPECIFIED) |
| 70 return specifics_type; | 70 return specifics_type; |
| 71 | 71 |
| 72 // Otherwise, we don't have a server type yet. That should only happen | 72 // Otherwise, we don't have a server type yet. That should only happen |
| 73 // if the item is an uncommitted locally created item. | 73 // if the item is an uncommitted locally created item. |
| 74 // It's possible we'll need to relax these checks in the future; they're | 74 // It's possible we'll need to relax these checks in the future; they're |
| 75 // just here for now as a safety measure. | 75 // just here for now as a safety measure. |
| 76 DCHECK(Get(IS_UNSYNCED)); | 76 DCHECK(Get(IS_UNSYNCED)); |
| 77 DCHECK_EQ(Get(SERVER_VERSION), 0); | 77 DCHECK_EQ(Get(SERVER_VERSION), 0); |
| 78 DCHECK(Get(SERVER_IS_DEL)); | 78 DCHECK(Get(SERVER_IS_DEL)); |
| 79 // Note: can't enforce !Get(ID).ServerKnows() here because that could | 79 // Note: can't enforce !Get(ID).ServerKnows() here because that could |
| 80 // actually happen if we hit AttemptReuniteLostCommitResponses. | 80 // actually happen if we hit AttemptReuniteLostCommitResponses. |
| 81 return UNSPECIFIED; | 81 return UNSPECIFIED; |
| 82 } | 82 } |
| 83 | 83 |
| 84 syncer::ModelType Entry::GetModelType() const { | 84 ModelType Entry::GetModelType() const { |
| 85 ModelType specifics_type = GetModelTypeFromSpecifics(Get(SPECIFICS)); | 85 ModelType specifics_type = GetModelTypeFromSpecifics(Get(SPECIFICS)); |
| 86 if (specifics_type != UNSPECIFIED) | 86 if (specifics_type != UNSPECIFIED) |
| 87 return specifics_type; | 87 return specifics_type; |
| 88 if (IsRoot()) | 88 if (IsRoot()) |
| 89 return TOP_LEVEL_FOLDER; | 89 return TOP_LEVEL_FOLDER; |
| 90 // Loose check for server-created top-level folders that aren't | 90 // Loose check for server-created top-level folders that aren't |
| 91 // bound to a particular model type. | 91 // bound to a particular model type. |
| 92 if (!Get(UNIQUE_SERVER_TAG).empty() && Get(IS_DIR)) | 92 if (!Get(UNIQUE_SERVER_TAG).empty() && Get(IS_DIR)) |
| 93 return TOP_LEVEL_FOLDER; | 93 return TOP_LEVEL_FOLDER; |
| 94 | 94 |
| 95 return UNSPECIFIED; | 95 return UNSPECIFIED; |
| 96 } | 96 } |
| 97 | 97 |
| 98 std::ostream& operator<<(std::ostream& s, const Blob& blob) { | 98 std::ostream& operator<<(std::ostream& s, const Blob& blob) { |
| 99 for (Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) | 99 for (Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) |
| 100 s << std::hex << std::setw(2) | 100 s << std::hex << std::setw(2) |
| 101 << std::setfill('0') << static_cast<unsigned int>(*i); | 101 << std::setfill('0') << static_cast<unsigned int>(*i); |
| 102 return s << std::dec; | 102 return s << std::dec; |
| 103 } | 103 } |
| 104 | 104 |
| 105 std::ostream& operator<<(std::ostream& os, const Entry& entry) { | 105 std::ostream& operator<<(std::ostream& os, const Entry& entry) { |
| 106 int i; | 106 int i; |
| 107 EntryKernel* const kernel = entry.kernel_; | 107 EntryKernel* const kernel = entry.kernel_; |
| 108 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { | 108 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { |
| 109 os << g_metas_columns[i].name << ": " | 109 os << g_metas_columns[i].name << ": " |
| 110 << kernel->ref(static_cast<Int64Field>(i)) << ", "; | 110 << kernel->ref(static_cast<Int64Field>(i)) << ", "; |
| 111 } | 111 } |
| 112 for ( ; i < TIME_FIELDS_END; ++i) { | 112 for ( ; i < TIME_FIELDS_END; ++i) { |
| 113 os << g_metas_columns[i].name << ": " | 113 os << g_metas_columns[i].name << ": " |
| 114 << syncer::GetTimeDebugString( | 114 << GetTimeDebugString(kernel->ref(static_cast<TimeField>(i))) << ", "; |
| 115 kernel->ref(static_cast<TimeField>(i))) << ", "; | |
| 116 } | 115 } |
| 117 for ( ; i < ID_FIELDS_END; ++i) { | 116 for ( ; i < ID_FIELDS_END; ++i) { |
| 118 os << g_metas_columns[i].name << ": " | 117 os << g_metas_columns[i].name << ": " |
| 119 << kernel->ref(static_cast<IdField>(i)) << ", "; | 118 << kernel->ref(static_cast<IdField>(i)) << ", "; |
| 120 } | 119 } |
| 121 os << "Flags: "; | 120 os << "Flags: "; |
| 122 for ( ; i < BIT_FIELDS_END; ++i) { | 121 for ( ; i < BIT_FIELDS_END; ++i) { |
| 123 if (kernel->ref(static_cast<BitField>(i))) | 122 if (kernel->ref(static_cast<BitField>(i))) |
| 124 os << g_metas_columns[i].name << ", "; | 123 os << g_metas_columns[i].name << ", "; |
| 125 } | 124 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 136 os << "TempFlags: "; | 135 os << "TempFlags: "; |
| 137 for ( ; i < BIT_TEMPS_END; ++i) { | 136 for ( ; i < BIT_TEMPS_END; ++i) { |
| 138 if (kernel->ref(static_cast<BitTemp>(i))) | 137 if (kernel->ref(static_cast<BitTemp>(i))) |
| 139 os << "#" << i - BIT_TEMPS_BEGIN << ", "; | 138 os << "#" << i - BIT_TEMPS_BEGIN << ", "; |
| 140 } | 139 } |
| 141 return os; | 140 return os; |
| 142 } | 141 } |
| 143 | 142 |
| 144 } // namespace syncable | 143 } // namespace syncable |
| 145 } // namespace syncer | 144 } // namespace syncer |
| OLD | NEW |