| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 template <Int64Field field_index> | 114 template <Int64Field field_index> |
| 115 class HashField { | 115 class HashField { |
| 116 public: | 116 public: |
| 117 inline size_t operator()(const syncable::EntryKernel* a) const { | 117 inline size_t operator()(const syncable::EntryKernel* a) const { |
| 118 return hasher_(a->ref(field_index)); | 118 return hasher_(a->ref(field_index)); |
| 119 } | 119 } |
| 120 base::hash_set<int64> hasher_; | 120 base::hash_set<int64> hasher_; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // TODO(chron): Remove this function. | 123 // TODO(chron): Remove this function. |
| 124 int ComparePathNames(const PathString& a, const PathString& b) { | 124 int ComparePathNames(const string& a, const string& b) { |
| 125 const size_t val_size = sizeof(PathString::value_type); | 125 const size_t val_size = sizeof(string::value_type); |
| 126 return ComparePathNames16(NULL, a.size() * val_size, a.data(), | 126 return ComparePathNames16(NULL, a.size() * val_size, a.data(), |
| 127 b.size() * val_size, b.data()); | 127 b.size() * val_size, b.data()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 class LessParentIdAndHandle { | 130 class LessParentIdAndHandle { |
| 131 public: | 131 public: |
| 132 bool operator() (const syncable::EntryKernel* a, | 132 bool operator() (const syncable::EntryKernel* a, |
| 133 const syncable::EntryKernel* b) const { | 133 const syncable::EntryKernel* b) const { |
| 134 if (a->ref(PARENT_ID) != b->ref(PARENT_ID)) { | 134 if (a->ref(PARENT_ID) != b->ref(PARENT_ID)) { |
| 135 return a->ref(PARENT_ID) < b->ref(PARENT_ID); | 135 return a->ref(PARENT_ID) < b->ref(PARENT_ID); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Meta handles are immutable per entry so this is ideal. | 138 // Meta handles are immutable per entry so this is ideal. |
| 139 return a->ref(META_HANDLE) < b->ref(META_HANDLE); | 139 return a->ref(META_HANDLE) < b->ref(META_HANDLE); |
| 140 } | 140 } |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 // TODO(chron): Remove this function. | 143 // TODO(chron): Remove this function. |
| 144 bool LessPathNames::operator() (const PathString& a, | 144 bool LessPathNames::operator() (const string& a, const string& b) const { |
| 145 const PathString& b) const { | |
| 146 return ComparePathNames(a, b) < 0; | 145 return ComparePathNames(a, b) < 0; |
| 147 } | 146 } |
| 148 | 147 |
| 149 /////////////////////////////////////////////////////////////////////////// | 148 /////////////////////////////////////////////////////////////////////////// |
| 150 // Directory | 149 // Directory |
| 151 | 150 |
| 152 static const DirectoryChangeEvent kShutdownChangesEvent = | 151 static const DirectoryChangeEvent kShutdownChangesEvent = |
| 153 { DirectoryChangeEvent::SHUTDOWN, 0, 0 }; | 152 { DirectoryChangeEvent::SHUTDOWN, 0, 0 }; |
| 154 | 153 |
| 155 Directory::Kernel::Kernel(const FilePath& db_path, | 154 Directory::Kernel::Kernel(const FilePath& db_path, |
| 156 const PathString& name, | 155 const string& name, |
| 157 const KernelLoadInfo& info) | 156 const KernelLoadInfo& info) |
| 158 : db_path(db_path), | 157 : db_path(db_path), |
| 159 refcount(1), | 158 refcount(1), |
| 160 name_(name), | 159 name_(name), |
| 161 metahandles_index(new Directory::MetahandlesIndex), | 160 metahandles_index(new Directory::MetahandlesIndex), |
| 162 ids_index(new Directory::IdsIndex), | 161 ids_index(new Directory::IdsIndex), |
| 163 parent_id_child_index(new Directory::ParentIdChildIndex), | 162 parent_id_child_index(new Directory::ParentIdChildIndex), |
| 164 extended_attributes(new ExtendedAttributes), | 163 extended_attributes(new ExtendedAttributes), |
| 165 unapplied_update_metahandles(new MetahandleSet), | 164 unapplied_update_metahandles(new MetahandleSet), |
| 166 unsynced_metahandles(new MetahandleSet), | 165 unsynced_metahandles(new MetahandleSet), |
| 167 channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), | 166 channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), |
| 168 changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)), | 167 changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)), |
| 169 last_sync_timestamp_(info.kernel_info.last_sync_timestamp), | 168 last_sync_timestamp_(info.kernel_info.last_sync_timestamp), |
| 170 initial_sync_ended_(info.kernel_info.initial_sync_ended), | 169 initial_sync_ended_(info.kernel_info.initial_sync_ended), |
| 171 store_birthday_(info.kernel_info.store_birthday), | 170 store_birthday_(info.kernel_info.store_birthday), |
| 172 cache_guid_(info.cache_guid), | 171 cache_guid_(info.cache_guid), |
| 173 next_metahandle(info.max_metahandle + 1), | 172 next_metahandle(info.max_metahandle + 1), |
| 174 next_id(info.kernel_info.next_id) { | 173 next_id(info.kernel_info.next_id) { |
| 175 info_status_ = Directory::KERNEL_SHARE_INFO_VALID; | 174 info_status_ = Directory::KERNEL_SHARE_INFO_VALID; |
| 176 } | 175 } |
| 177 | 176 |
| 178 inline void DeleteEntry(EntryKernel* kernel) { | 177 inline void DeleteEntry(EntryKernel* kernel) { |
| 179 delete kernel; | 178 delete kernel; |
| 180 } | 179 } |
| 181 | 180 |
| 182 void Directory::Kernel::AddRef() { | 181 void Directory::Kernel::AddRef() { |
| 183 base::subtle::NoBarrier_AtomicIncrement(&refcount, 1); | 182 base::subtle::NoBarrier_AtomicIncrement(&refcount, 1); |
| 184 } | 183 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 201 delete metahandles_index; | 200 delete metahandles_index; |
| 202 } | 201 } |
| 203 | 202 |
| 204 Directory::Directory() : kernel_(NULL), store_(NULL) { | 203 Directory::Directory() : kernel_(NULL), store_(NULL) { |
| 205 } | 204 } |
| 206 | 205 |
| 207 Directory::~Directory() { | 206 Directory::~Directory() { |
| 208 Close(); | 207 Close(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 DirOpenResult Directory::Open(const FilePath& file_path, | 210 DirOpenResult Directory::Open(const FilePath& file_path, const string& name) { |
| 212 const PathString& name) { | |
| 213 const DirOpenResult result = OpenImpl(file_path, name); | 211 const DirOpenResult result = OpenImpl(file_path, name); |
| 214 if (OPENED != result) | 212 if (OPENED != result) |
| 215 Close(); | 213 Close(); |
| 216 return result; | 214 return result; |
| 217 } | 215 } |
| 218 | 216 |
| 219 void Directory::InitializeIndices() { | 217 void Directory::InitializeIndices() { |
| 220 MetahandlesIndex::iterator it = kernel_->metahandles_index->begin(); | 218 MetahandlesIndex::iterator it = kernel_->metahandles_index->begin(); |
| 221 for (; it != kernel_->metahandles_index->end(); ++it) { | 219 for (; it != kernel_->metahandles_index->end(); ++it) { |
| 222 EntryKernel* entry = *it; | 220 EntryKernel* entry = *it; |
| 223 if (!entry->ref(IS_DEL)) | 221 if (!entry->ref(IS_DEL)) |
| 224 kernel_->parent_id_child_index->insert(entry); | 222 kernel_->parent_id_child_index->insert(entry); |
| 225 kernel_->ids_index->insert(entry); | 223 kernel_->ids_index->insert(entry); |
| 226 if (entry->ref(IS_UNSYNCED)) | 224 if (entry->ref(IS_UNSYNCED)) |
| 227 kernel_->unsynced_metahandles->insert(entry->ref(META_HANDLE)); | 225 kernel_->unsynced_metahandles->insert(entry->ref(META_HANDLE)); |
| 228 if (entry->ref(IS_UNAPPLIED_UPDATE)) | 226 if (entry->ref(IS_UNAPPLIED_UPDATE)) |
| 229 kernel_->unapplied_update_metahandles->insert(entry->ref(META_HANDLE)); | 227 kernel_->unapplied_update_metahandles->insert(entry->ref(META_HANDLE)); |
| 230 } | 228 } |
| 231 } | 229 } |
| 232 | 230 |
| 233 DirectoryBackingStore* Directory::CreateBackingStore( | 231 DirectoryBackingStore* Directory::CreateBackingStore( |
| 234 const PathString& dir_name, const FilePath& backing_filepath) { | 232 const string& dir_name, const FilePath& backing_filepath) { |
| 235 return new DirectoryBackingStore(dir_name, backing_filepath); | 233 return new DirectoryBackingStore(dir_name, backing_filepath); |
| 236 } | 234 } |
| 237 | 235 |
| 238 DirOpenResult Directory::OpenImpl(const FilePath& file_path, | 236 DirOpenResult Directory::OpenImpl(const FilePath& file_path, |
| 239 const PathString& name) { | 237 const string& name) { |
| 240 DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_); | 238 DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_); |
| 241 FilePath db_path(file_path); | 239 FilePath db_path(file_path); |
| 242 file_util::AbsolutePath(&db_path); | 240 file_util::AbsolutePath(&db_path); |
| 243 store_ = CreateBackingStore(name, db_path); | 241 store_ = CreateBackingStore(name, db_path); |
| 244 | 242 |
| 245 KernelLoadInfo info; | 243 KernelLoadInfo info; |
| 246 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) | 244 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) |
| 247 // swap these later. | 245 // swap these later. |
| 248 MetahandlesIndex metas_bucket; | 246 MetahandlesIndex metas_bucket; |
| 249 ExtendedAttributes xattrs_bucket; | 247 ExtendedAttributes xattrs_bucket; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // First look up in memory | 280 // First look up in memory |
| 283 kernel_->needle.ref(ID) = id; | 281 kernel_->needle.ref(ID) = id; |
| 284 IdsIndex::iterator id_found = kernel_->ids_index->find(&kernel_->needle); | 282 IdsIndex::iterator id_found = kernel_->ids_index->find(&kernel_->needle); |
| 285 if (id_found != kernel_->ids_index->end()) { | 283 if (id_found != kernel_->ids_index->end()) { |
| 286 // Found it in memory. Easy. | 284 // Found it in memory. Easy. |
| 287 return *id_found; | 285 return *id_found; |
| 288 } | 286 } |
| 289 return NULL; | 287 return NULL; |
| 290 } | 288 } |
| 291 | 289 |
| 292 EntryKernel* Directory::GetEntryByTag(const PathString& tag) { | 290 EntryKernel* Directory::GetEntryByTag(const string& tag) { |
| 293 ScopedKernelLock lock(this); | 291 ScopedKernelLock lock(this); |
| 294 DCHECK(kernel_); | 292 DCHECK(kernel_); |
| 295 // We don't currently keep a separate index for the tags. Since tags | 293 // We don't currently keep a separate index for the tags. Since tags |
| 296 // only exist for server created items that are the first items | 294 // only exist for server created items that are the first items |
| 297 // to be created in a store, they should have small metahandles. | 295 // to be created in a store, they should have small metahandles. |
| 298 // So, we just iterate over the items in sorted metahandle order, | 296 // So, we just iterate over the items in sorted metahandle order, |
| 299 // looking for a match. | 297 // looking for a match. |
| 300 MetahandlesIndex& set = *kernel_->metahandles_index; | 298 MetahandlesIndex& set = *kernel_->metahandles_index; |
| 301 for (MetahandlesIndex::iterator i = set.begin(); i != set.end(); ++i) { | 299 for (MetahandlesIndex::iterator i = set.begin(); i != set.end(); ++i) { |
| 302 if ((*i)->ref(SINGLETON_TAG) == tag) { | 300 if ((*i)->ref(SINGLETON_TAG) == tag) { |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 } | 978 } |
| 981 | 979 |
| 982 /////////////////////////////////////////////////////////////////////////// | 980 /////////////////////////////////////////////////////////////////////////// |
| 983 // Entry | 981 // Entry |
| 984 | 982 |
| 985 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) | 983 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) |
| 986 : basetrans_(trans) { | 984 : basetrans_(trans) { |
| 987 kernel_ = trans->directory()->GetEntryById(id); | 985 kernel_ = trans->directory()->GetEntryById(id); |
| 988 } | 986 } |
| 989 | 987 |
| 990 Entry::Entry(BaseTransaction* trans, GetByTag, const PathString& tag) | 988 Entry::Entry(BaseTransaction* trans, GetByTag, const string& tag) |
| 991 : basetrans_(trans) { | 989 : basetrans_(trans) { |
| 992 kernel_ = trans->directory()->GetEntryByTag(tag); | 990 kernel_ = trans->directory()->GetEntryByTag(tag); |
| 993 } | 991 } |
| 994 | 992 |
| 995 Entry::Entry(BaseTransaction* trans, GetByHandle, int64 metahandle) | 993 Entry::Entry(BaseTransaction* trans, GetByHandle, int64 metahandle) |
| 996 : basetrans_(trans) { | 994 : basetrans_(trans) { |
| 997 kernel_ = trans->directory()->GetEntryByHandle(metahandle); | 995 kernel_ = trans->directory()->GetEntryByHandle(metahandle); |
| 998 } | 996 } |
| 999 | 997 |
| 1000 Directory* Entry::dir() const { | 998 Directory* Entry::dir() const { |
| 1001 return basetrans_->directory(); | 999 return basetrans_->directory(); |
| 1002 } | 1000 } |
| 1003 | 1001 |
| 1004 PathString Entry::Get(StringField field) const { | 1002 const string& Entry::Get(StringField field) const { |
| 1005 DCHECK(kernel_); | 1003 DCHECK(kernel_); |
| 1006 return kernel_->ref(field); | 1004 return kernel_->ref(field); |
| 1007 } | 1005 } |
| 1008 | 1006 |
| 1009 void Entry::GetAllExtendedAttributes(BaseTransaction* trans, | 1007 void Entry::GetAllExtendedAttributes(BaseTransaction* trans, |
| 1010 std::set<ExtendedAttribute> *result) { | 1008 std::set<ExtendedAttribute> *result) { |
| 1011 dir()->GetAllExtendedAttributes(trans, kernel_->ref(META_HANDLE), result); | 1009 dir()->GetAllExtendedAttributes(trans, kernel_->ref(META_HANDLE), result); |
| 1012 } | 1010 } |
| 1013 | 1011 |
| 1014 void Entry::GetExtendedAttributesList(BaseTransaction* trans, | 1012 void Entry::GetExtendedAttributesList(BaseTransaction* trans, |
| 1015 AttributeKeySet* result) { | 1013 AttributeKeySet* result) { |
| 1016 dir()->GetExtendedAttributesList(trans, kernel_->ref(META_HANDLE), result); | 1014 dir()->GetExtendedAttributesList(trans, kernel_->ref(META_HANDLE), result); |
| 1017 } | 1015 } |
| 1018 | 1016 |
| 1019 void Entry::DeleteAllExtendedAttributes(WriteTransaction *trans) { | 1017 void Entry::DeleteAllExtendedAttributes(WriteTransaction *trans) { |
| 1020 dir()->DeleteAllExtendedAttributes(trans, kernel_->ref(META_HANDLE)); | 1018 dir()->DeleteAllExtendedAttributes(trans, kernel_->ref(META_HANDLE)); |
| 1021 } | 1019 } |
| 1022 | 1020 |
| 1023 /////////////////////////////////////////////////////////////////////////// | 1021 /////////////////////////////////////////////////////////////////////////// |
| 1024 // MutableEntry | 1022 // MutableEntry |
| 1025 | 1023 |
| 1026 MutableEntry::MutableEntry(WriteTransaction* trans, Create, | 1024 MutableEntry::MutableEntry(WriteTransaction* trans, Create, |
| 1027 const Id& parent_id, const PathString& name) | 1025 const Id& parent_id, const string& name) |
| 1028 : Entry(trans), | 1026 : Entry(trans), |
| 1029 write_transaction_(trans) { | 1027 write_transaction_(trans) { |
| 1030 Init(trans, parent_id, name); | 1028 Init(trans, parent_id, name); |
| 1031 } | 1029 } |
| 1032 | 1030 |
| 1033 | 1031 |
| 1034 void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, | 1032 void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, |
| 1035 const PathString& name) { | 1033 const string& name) { |
| 1036 kernel_ = new EntryKernel; | 1034 kernel_ = new EntryKernel; |
| 1037 ZeroFields(kernel_, BEGIN_FIELDS); | 1035 ZeroFields(kernel_, BEGIN_FIELDS); |
| 1038 kernel_->ref(ID) = trans->directory_->NextId(); | 1036 kernel_->ref(ID) = trans->directory_->NextId(); |
| 1039 kernel_->dirty[ID] = true; | 1037 kernel_->dirty[ID] = true; |
| 1040 kernel_->ref(META_HANDLE) = trans->directory_->NextMetahandle(); | 1038 kernel_->ref(META_HANDLE) = trans->directory_->NextMetahandle(); |
| 1041 kernel_->dirty[META_HANDLE] = true; | 1039 kernel_->dirty[META_HANDLE] = true; |
| 1042 kernel_->ref(PARENT_ID) = parent_id; | 1040 kernel_->ref(PARENT_ID) = parent_id; |
| 1043 kernel_->dirty[PARENT_ID] = true; | 1041 kernel_->dirty[PARENT_ID] = true; |
| 1044 kernel_->ref(NON_UNIQUE_NAME) = name; | 1042 kernel_->ref(NON_UNIQUE_NAME) = name; |
| 1045 kernel_->dirty[NON_UNIQUE_NAME] = true; | 1043 kernel_->dirty[NON_UNIQUE_NAME] = true; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 | 1134 |
| 1137 bool MutableEntry::Put(BaseVersion field, int64 value) { | 1135 bool MutableEntry::Put(BaseVersion field, int64 value) { |
| 1138 DCHECK(kernel_); | 1136 DCHECK(kernel_); |
| 1139 if (kernel_->ref(field) != value) { | 1137 if (kernel_->ref(field) != value) { |
| 1140 kernel_->ref(field) = value; | 1138 kernel_->ref(field) = value; |
| 1141 kernel_->dirty[static_cast<int>(field)] = true; | 1139 kernel_->dirty[static_cast<int>(field)] = true; |
| 1142 } | 1140 } |
| 1143 return true; | 1141 return true; |
| 1144 } | 1142 } |
| 1145 | 1143 |
| 1146 bool MutableEntry::Put(StringField field, const PathString& value) { | 1144 bool MutableEntry::Put(StringField field, const string& value) { |
| 1147 return PutImpl(field, value); | 1145 return PutImpl(field, value); |
| 1148 } | 1146 } |
| 1149 | 1147 |
| 1150 bool MutableEntry::PutImpl(StringField field, const PathString& value) { | 1148 bool MutableEntry::PutImpl(StringField field, const string& value) { |
| 1151 DCHECK(kernel_); | 1149 DCHECK(kernel_); |
| 1152 if (kernel_->ref(field) != value) { | 1150 if (kernel_->ref(field) != value) { |
| 1153 kernel_->ref(field) = value; | 1151 kernel_->ref(field) = value; |
| 1154 kernel_->dirty[static_cast<int>(field)] = true; | 1152 kernel_->dirty[static_cast<int>(field)] = true; |
| 1155 } | 1153 } |
| 1156 return true; | 1154 return true; |
| 1157 } | 1155 } |
| 1158 | 1156 |
| 1159 bool MutableEntry::Put(IndexedBitField field, bool value) { | 1157 bool MutableEntry::Put(IndexedBitField field, bool value) { |
| 1160 DCHECK(kernel_); | 1158 DCHECK(kernel_); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 if (entry_id == ancestor_id) | 1340 if (entry_id == ancestor_id) |
| 1343 return false; | 1341 return false; |
| 1344 Entry new_parent(trans, GET_BY_ID, ancestor_id); | 1342 Entry new_parent(trans, GET_BY_ID, ancestor_id); |
| 1345 CHECK(new_parent.good()); | 1343 CHECK(new_parent.good()); |
| 1346 ancestor_id = new_parent.Get(PARENT_ID); | 1344 ancestor_id = new_parent.Get(PARENT_ID); |
| 1347 } | 1345 } |
| 1348 return true; | 1346 return true; |
| 1349 } | 1347 } |
| 1350 | 1348 |
| 1351 const Blob* GetExtendedAttributeValue(const Entry& e, | 1349 const Blob* GetExtendedAttributeValue(const Entry& e, |
| 1352 const PathString& attribute_name) { | 1350 const string& attribute_name) { |
| 1353 ExtendedAttributeKey key(e.Get(META_HANDLE), attribute_name); | 1351 ExtendedAttributeKey key(e.Get(META_HANDLE), attribute_name); |
| 1354 ExtendedAttribute extended_attribute(e.trans(), GET_BY_HANDLE, key); | 1352 ExtendedAttribute extended_attribute(e.trans(), GET_BY_HANDLE, key); |
| 1355 if (extended_attribute.good() && !extended_attribute.is_deleted()) | 1353 if (extended_attribute.good() && !extended_attribute.is_deleted()) |
| 1356 return &extended_attribute.value(); | 1354 return &extended_attribute.value(); |
| 1357 return NULL; | 1355 return NULL; |
| 1358 } | 1356 } |
| 1359 | 1357 |
| 1360 // This function sets only the flags needed to get this entry to sync. | 1358 // This function sets only the flags needed to get this entry to sync. |
| 1361 void MarkForSyncing(syncable::MutableEntry* e) { | 1359 void MarkForSyncing(syncable::MutableEntry* e) { |
| 1362 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); | 1360 DCHECK_NE(static_cast<MutableEntry*>(NULL), e); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 for ( ; i < ID_FIELDS_END; ++i) { | 1412 for ( ; i < ID_FIELDS_END; ++i) { |
| 1415 s << g_metas_columns[i].name << colon | 1413 s << g_metas_columns[i].name << colon |
| 1416 << kernel->ref(static_cast<IdField>(i)) << separator; | 1414 << kernel->ref(static_cast<IdField>(i)) << separator; |
| 1417 } | 1415 } |
| 1418 s << "Flags: "; | 1416 s << "Flags: "; |
| 1419 for ( ; i < BIT_FIELDS_END; ++i) { | 1417 for ( ; i < BIT_FIELDS_END; ++i) { |
| 1420 if (kernel->ref(static_cast<BitField>(i))) | 1418 if (kernel->ref(static_cast<BitField>(i))) |
| 1421 s << g_metas_columns[i].name << separator; | 1419 s << g_metas_columns[i].name << separator; |
| 1422 } | 1420 } |
| 1423 for ( ; i < STRING_FIELDS_END; ++i) { | 1421 for ( ; i < STRING_FIELDS_END; ++i) { |
| 1424 const PathString& field = kernel->ref(static_cast<StringField>(i)); | 1422 const string& field = kernel->ref(static_cast<StringField>(i)); |
| 1425 s << g_metas_columns[i].name << colon << field << separator; | 1423 s << g_metas_columns[i].name << colon << field << separator; |
| 1426 } | 1424 } |
| 1427 for ( ; i < BLOB_FIELDS_END; ++i) { | 1425 for ( ; i < BLOB_FIELDS_END; ++i) { |
| 1428 s << g_metas_columns[i].name << colon | 1426 s << g_metas_columns[i].name << colon |
| 1429 << kernel->ref(static_cast<BlobField>(i)) << separator; | 1427 << kernel->ref(static_cast<BlobField>(i)) << separator; |
| 1430 } | 1428 } |
| 1431 s << "TempFlags: "; | 1429 s << "TempFlags: "; |
| 1432 for ( ; i < BIT_TEMPS_END; ++i) { | 1430 for ( ; i < BIT_TEMPS_END; ++i) { |
| 1433 if (kernel->ref(static_cast<BitTemp>(i))) | 1431 if (kernel->ref(static_cast<BitTemp>(i))) |
| 1434 s << "#" << i - BIT_TEMPS_BEGIN << separator; | 1432 s << "#" << i - BIT_TEMPS_BEGIN << separator; |
| 1435 } | 1433 } |
| 1436 return stream; | 1434 return stream; |
| 1437 } | 1435 } |
| 1438 | 1436 |
| 1439 std::ostream& operator<<(std::ostream& s, const syncable::Blob& blob) { | 1437 std::ostream& operator<<(std::ostream& s, const syncable::Blob& blob) { |
| 1440 for (syncable::Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) | 1438 for (syncable::Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) |
| 1441 s << std::hex << std::setw(2) | 1439 s << std::hex << std::setw(2) |
| 1442 << std::setfill('0') << static_cast<unsigned int>(*i); | 1440 << std::setfill('0') << static_cast<unsigned int>(*i); |
| 1443 return s << std::dec; | 1441 return s << std::dec; |
| 1444 } | 1442 } |
| 1445 | 1443 |
| 1446 FastDump& operator<<(FastDump& dump, const syncable::Blob& blob) { | 1444 FastDump& operator<<(FastDump& dump, const syncable::Blob& blob) { |
| 1447 if (blob.empty()) | 1445 if (blob.empty()) |
| 1448 return dump; | 1446 return dump; |
| 1449 string buffer(HexEncode(&blob[0], blob.size())); | 1447 string buffer(HexEncode(&blob[0], blob.size())); |
| 1450 dump.out_->sputn(buffer.c_str(), buffer.size()); | 1448 dump.out_->sputn(buffer.c_str(), buffer.size()); |
| 1451 return dump; | 1449 return dump; |
| 1452 } | 1450 } |
| OLD | NEW |