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

Side by Side Diff: components/sync/syncable/directory.cc

Issue 2287783002: Remove stl_util's STLValueDeleter. (Closed)
Patch Set: rebase Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/sync/syncable/directory.h" 5 #include "components/sync/syncable/directory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <iterator> 11 #include <iterator>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/base64.h" 14 #include "base/base64.h"
15 #include "base/guid.h" 15 #include "base/guid.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
20 #include "components/sync/base/attachment_id_proto.h" 21 #include "components/sync/base/attachment_id_proto.h"
21 #include "components/sync/base/unique_position.h" 22 #include "components/sync/base/unique_position.h"
22 #include "components/sync/base/unrecoverable_error_handler.h" 23 #include "components/sync/base/unrecoverable_error_handler.h"
23 #include "components/sync/syncable/entry.h" 24 #include "components/sync/syncable/entry.h"
24 #include "components/sync/syncable/entry_kernel.h" 25 #include "components/sync/syncable/entry_kernel.h"
25 #include "components/sync/syncable/in_memory_directory_backing_store.h" 26 #include "components/sync/syncable/in_memory_directory_backing_store.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 info_status(Directory::KERNEL_SHARE_INFO_VALID), 96 info_status(Directory::KERNEL_SHARE_INFO_VALID),
96 persisted_info(info.kernel_info), 97 persisted_info(info.kernel_info),
97 cache_guid(info.cache_guid), 98 cache_guid(info.cache_guid),
98 next_metahandle(info.max_metahandle + 1), 99 next_metahandle(info.max_metahandle + 1),
99 delegate(delegate), 100 delegate(delegate),
100 transaction_observer(transaction_observer) { 101 transaction_observer(transaction_observer) {
101 DCHECK(delegate); 102 DCHECK(delegate);
102 DCHECK(transaction_observer.IsInitialized()); 103 DCHECK(transaction_observer.IsInitialized());
103 } 104 }
104 105
105 Directory::Kernel::~Kernel() { 106 Directory::Kernel::~Kernel() {}
106 base::STLDeleteContainerPairSecondPointers(metahandles_map.begin(),
107 metahandles_map.end());
108 }
109 107
110 Directory::Directory( 108 Directory::Directory(
111 DirectoryBackingStore* store, 109 DirectoryBackingStore* store,
112 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, 110 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
113 const base::Closure& report_unrecoverable_error_function, 111 const base::Closure& report_unrecoverable_error_function,
114 NigoriHandler* nigori_handler, 112 NigoriHandler* nigori_handler,
115 Cryptographer* cryptographer) 113 Cryptographer* cryptographer)
116 : kernel_(NULL), 114 : kernel_(NULL),
117 store_(store), 115 store_(store),
118 unrecoverable_error_handler_(unrecoverable_error_handler), 116 unrecoverable_error_handler_(unrecoverable_error_handler),
(...skipping 17 matching lines...) Expand all
136 const DirOpenResult result = OpenImpl(name, delegate, transaction_observer); 134 const DirOpenResult result = OpenImpl(name, delegate, transaction_observer);
137 135
138 if (OPENED != result) 136 if (OPENED != result)
139 Close(); 137 Close();
140 return result; 138 return result;
141 } 139 }
142 140
143 void Directory::InitializeIndices(MetahandlesMap* handles_map) { 141 void Directory::InitializeIndices(MetahandlesMap* handles_map) {
144 ScopedKernelLock lock(this); 142 ScopedKernelLock lock(this);
145 kernel_->metahandles_map.swap(*handles_map); 143 kernel_->metahandles_map.swap(*handles_map);
146 for (MetahandlesMap::const_iterator it = kernel_->metahandles_map.begin(); 144 for (auto it = kernel_->metahandles_map.begin();
147 it != kernel_->metahandles_map.end(); ++it) { 145 it != kernel_->metahandles_map.end(); ++it) {
148 EntryKernel* entry = it->second; 146 EntryKernel* entry = it->second.get();
149 if (ParentChildIndex::ShouldInclude(entry)) 147 if (ParentChildIndex::ShouldInclude(entry))
150 kernel_->parent_child_index.Insert(entry); 148 kernel_->parent_child_index.Insert(entry);
151 const int64_t metahandle = entry->ref(META_HANDLE); 149 const int64_t metahandle = entry->ref(META_HANDLE);
152 if (entry->ref(IS_UNSYNCED)) 150 if (entry->ref(IS_UNSYNCED))
153 kernel_->unsynced_metahandles.insert(metahandle); 151 kernel_->unsynced_metahandles.insert(metahandle);
154 if (entry->ref(IS_UNAPPLIED_UPDATE)) { 152 if (entry->ref(IS_UNAPPLIED_UPDATE)) {
155 const ModelType type = entry->GetServerModelType(); 153 const ModelType type = entry->GetServerModelType();
156 kernel_->unapplied_update_metahandles[type].insert(metahandle); 154 kernel_->unapplied_update_metahandles[type].insert(metahandle);
157 } 155 }
158 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) { 156 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) {
(...skipping 19 matching lines...) Expand all
178 176
179 DirOpenResult Directory::OpenImpl( 177 DirOpenResult Directory::OpenImpl(
180 const string& name, 178 const string& name,
181 DirectoryChangeDelegate* delegate, 179 DirectoryChangeDelegate* delegate,
182 const WeakHandle<TransactionObserver>& transaction_observer) { 180 const WeakHandle<TransactionObserver>& transaction_observer) {
183 KernelLoadInfo info; 181 KernelLoadInfo info;
184 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) 182 // Temporary indices before kernel_ initialized in case Load fails. We 0(1)
185 // swap these later. 183 // swap these later.
186 Directory::MetahandlesMap tmp_handles_map; 184 Directory::MetahandlesMap tmp_handles_map;
187 185
188 // Avoids mem leaks on failure. Harmlessly deletes the empty hash map after
189 // the swap in the success case.
190 base::STLValueDeleter<MetahandlesMap> deleter(&tmp_handles_map);
191
192 JournalIndex delete_journals; 186 JournalIndex delete_journals;
193 MetahandleSet metahandles_to_purge; 187 MetahandleSet metahandles_to_purge;
194 188
195 DirOpenResult result = store_->Load(&tmp_handles_map, &delete_journals, 189 DirOpenResult result = store_->Load(&tmp_handles_map, &delete_journals,
196 &metahandles_to_purge, &info); 190 &metahandles_to_purge, &info);
197 if (OPENED != result) 191 if (OPENED != result)
198 return result; 192 return result;
199 193
200 DCHECK(!kernel_); 194 DCHECK(!kernel_);
201 kernel_ = new Kernel(name, info, delegate, transaction_observer); 195 kernel_ = new Kernel(name, info, delegate, transaction_observer);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 ScopedKernelLock lock(this); 274 ScopedKernelLock lock(this);
281 return GetEntryByHandle(lock, metahandle); 275 return GetEntryByHandle(lock, metahandle);
282 } 276 }
283 277
284 EntryKernel* Directory::GetEntryByHandle(const ScopedKernelLock& lock, 278 EntryKernel* Directory::GetEntryByHandle(const ScopedKernelLock& lock,
285 int64_t metahandle) { 279 int64_t metahandle) {
286 // Look up in memory 280 // Look up in memory
287 MetahandlesMap::iterator found = kernel_->metahandles_map.find(metahandle); 281 MetahandlesMap::iterator found = kernel_->metahandles_map.find(metahandle);
288 if (found != kernel_->metahandles_map.end()) { 282 if (found != kernel_->metahandles_map.end()) {
289 // Found it in memory. Easy. 283 // Found it in memory. Easy.
290 return found->second; 284 return found->second.get();
291 } 285 }
292 return NULL; 286 return NULL;
293 } 287 }
294 288
295 bool Directory::GetChildHandlesById(BaseTransaction* trans, 289 bool Directory::GetChildHandlesById(BaseTransaction* trans,
296 const Id& parent_id, 290 const Id& parent_id,
297 Directory::Metahandles* result) { 291 Directory::Metahandles* result) {
298 if (!SyncAssert(this == trans->directory(), FROM_HERE, 292 if (!SyncAssert(this == trans->directory(), FROM_HERE,
299 "Directories don't match", trans)) 293 "Directories don't match", trans))
300 return false; 294 return false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 354
361 bool Directory::InsertEntry(const ScopedKernelLock& lock, 355 bool Directory::InsertEntry(const ScopedKernelLock& lock,
362 BaseWriteTransaction* trans, 356 BaseWriteTransaction* trans,
363 EntryKernel* entry) { 357 EntryKernel* entry) {
364 if (!SyncAssert(NULL != entry, FROM_HERE, "Entry is null", trans)) 358 if (!SyncAssert(NULL != entry, FROM_HERE, "Entry is null", trans))
365 return false; 359 return false;
366 360
367 static const char error[] = "Entry already in memory index."; 361 static const char error[] = "Entry already in memory index.";
368 362
369 if (!SyncAssert(kernel_->metahandles_map 363 if (!SyncAssert(kernel_->metahandles_map
370 .insert(std::make_pair(entry->ref(META_HANDLE), entry)) 364 .insert(std::make_pair(entry->ref(META_HANDLE),
365 base::WrapUnique(entry)))
371 .second, 366 .second,
372 FROM_HERE, error, trans)) { 367 FROM_HERE, error, trans)) {
373 return false; 368 return false;
374 } 369 }
375 if (!SyncAssert( 370 if (!SyncAssert(
376 kernel_->ids_map.insert(std::make_pair(entry->ref(ID).value(), entry)) 371 kernel_->ids_map.insert(std::make_pair(entry->ref(ID).value(), entry))
377 .second, 372 .second,
378 FROM_HERE, error, trans)) { 373 FROM_HERE, error, trans)) {
379 return false; 374 return false;
380 } 375 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 587
593 // Need a write transaction as we are about to permanently purge entries. 588 // Need a write transaction as we are about to permanently purge entries.
594 WriteTransaction trans(FROM_HERE, VACUUM_AFTER_SAVE, this); 589 WriteTransaction trans(FROM_HERE, VACUUM_AFTER_SAVE, this);
595 ScopedKernelLock lock(this); 590 ScopedKernelLock lock(this);
596 // Now drop everything we can out of memory. 591 // Now drop everything we can out of memory.
597 for (EntryKernelSet::const_iterator i = snapshot.dirty_metas.begin(); 592 for (EntryKernelSet::const_iterator i = snapshot.dirty_metas.begin();
598 i != snapshot.dirty_metas.end(); ++i) { 593 i != snapshot.dirty_metas.end(); ++i) {
599 MetahandlesMap::iterator found = 594 MetahandlesMap::iterator found =
600 kernel_->metahandles_map.find((*i)->ref(META_HANDLE)); 595 kernel_->metahandles_map.find((*i)->ref(META_HANDLE));
601 EntryKernel* entry = 596 EntryKernel* entry =
602 (found == kernel_->metahandles_map.end() ? NULL : found->second); 597 (found == kernel_->metahandles_map.end() ? NULL : found->second.get());
603 if (entry && SafeToPurgeFromMemory(&trans, entry)) { 598 if (entry && SafeToPurgeFromMemory(&trans, entry)) {
604 // We now drop deleted metahandles that are up to date on both the client 599 // We now drop deleted metahandles that are up to date on both the client
605 // and the server. 600 // and the server.
601 std::unique_ptr<EntryKernel> unique_entry = std::move(found->second);
602
606 size_t num_erased = 0; 603 size_t num_erased = 0;
607 num_erased = kernel_->metahandles_map.erase(entry->ref(META_HANDLE)); 604 num_erased = kernel_->metahandles_map.erase(entry->ref(META_HANDLE));
608 DCHECK_EQ(1u, num_erased); 605 DCHECK_EQ(1u, num_erased);
609 num_erased = kernel_->ids_map.erase(entry->ref(ID).value()); 606 num_erased = kernel_->ids_map.erase(entry->ref(ID).value());
610 DCHECK_EQ(1u, num_erased); 607 DCHECK_EQ(1u, num_erased);
611 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) { 608 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) {
612 num_erased = 609 num_erased =
613 kernel_->server_tags_map.erase(entry->ref(UNIQUE_SERVER_TAG)); 610 kernel_->server_tags_map.erase(entry->ref(UNIQUE_SERVER_TAG));
614 DCHECK_EQ(1u, num_erased); 611 DCHECK_EQ(1u, num_erased);
615 } 612 }
616 if (!entry->ref(UNIQUE_CLIENT_TAG).empty()) { 613 if (!entry->ref(UNIQUE_CLIENT_TAG).empty()) {
617 num_erased = 614 num_erased =
618 kernel_->client_tags_map.erase(entry->ref(UNIQUE_CLIENT_TAG)); 615 kernel_->client_tags_map.erase(entry->ref(UNIQUE_CLIENT_TAG));
619 DCHECK_EQ(1u, num_erased); 616 DCHECK_EQ(1u, num_erased);
620 } 617 }
621 if (!SyncAssert(!kernel_->parent_child_index.Contains(entry), FROM_HERE, 618 if (!SyncAssert(!kernel_->parent_child_index.Contains(entry), FROM_HERE,
622 "Deleted entry still present", (&trans))) 619 "Deleted entry still present", (&trans)))
623 return false; 620 return false;
624 RemoveFromAttachmentIndex(lock, entry->ref(META_HANDLE), 621 RemoveFromAttachmentIndex(lock, entry->ref(META_HANDLE),
625 entry->ref(ATTACHMENT_METADATA)); 622 entry->ref(ATTACHMENT_METADATA));
626
627 delete entry;
628 } 623 }
629 if (trans.unrecoverable_error_set()) 624 if (trans.unrecoverable_error_set())
630 return false; 625 return false;
631 } 626 }
632 return true; 627 return true;
633 } 628 }
634 629
635 void Directory::UnapplyEntry(EntryKernel* entry) { 630 void Directory::UnapplyEntry(EntryKernel* entry) {
636 int64_t handle = entry->ref(META_HANDLE); 631 int64_t handle = entry->ref(META_HANDLE);
637 ModelType server_type = 632 ModelType server_type =
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 void Directory::DeleteEntry(const ScopedKernelLock& lock, 686 void Directory::DeleteEntry(const ScopedKernelLock& lock,
692 bool save_to_journal, 687 bool save_to_journal,
693 EntryKernel* entry, 688 EntryKernel* entry,
694 EntryKernelSet* entries_to_journal) { 689 EntryKernelSet* entries_to_journal) {
695 int64_t handle = entry->ref(META_HANDLE); 690 int64_t handle = entry->ref(META_HANDLE);
696 ModelType server_type = 691 ModelType server_type =
697 GetModelTypeFromSpecifics(entry->ref(SERVER_SPECIFICS)); 692 GetModelTypeFromSpecifics(entry->ref(SERVER_SPECIFICS));
698 693
699 kernel_->metahandles_to_purge.insert(handle); 694 kernel_->metahandles_to_purge.insert(handle);
700 695
696 std::unique_ptr<EntryKernel> entry_ptr =
697 std::move(kernel_->metahandles_map[handle]);
698
701 size_t num_erased = 0; 699 size_t num_erased = 0;
702 num_erased = kernel_->metahandles_map.erase(entry->ref(META_HANDLE)); 700 num_erased = kernel_->metahandles_map.erase(handle);
703 DCHECK_EQ(1u, num_erased); 701 DCHECK_EQ(1u, num_erased);
704 num_erased = kernel_->ids_map.erase(entry->ref(ID).value()); 702 num_erased = kernel_->ids_map.erase(entry->ref(ID).value());
705 DCHECK_EQ(1u, num_erased); 703 DCHECK_EQ(1u, num_erased);
706 num_erased = kernel_->unsynced_metahandles.erase(handle); 704 num_erased = kernel_->unsynced_metahandles.erase(handle);
707 DCHECK_EQ(entry->ref(IS_UNSYNCED), num_erased > 0); 705 DCHECK_EQ(entry->ref(IS_UNSYNCED), num_erased > 0);
708 num_erased = kernel_->unapplied_update_metahandles[server_type].erase(handle); 706 num_erased = kernel_->unapplied_update_metahandles[server_type].erase(handle);
709 DCHECK_EQ(entry->ref(IS_UNAPPLIED_UPDATE), num_erased > 0); 707 DCHECK_EQ(entry->ref(IS_UNAPPLIED_UPDATE), num_erased > 0);
710 if (kernel_->parent_child_index.Contains(entry)) 708 if (kernel_->parent_child_index.Contains(entry))
711 kernel_->parent_child_index.Remove(entry); 709 kernel_->parent_child_index.Remove(entry);
712 710
713 if (!entry->ref(UNIQUE_CLIENT_TAG).empty()) { 711 if (!entry->ref(UNIQUE_CLIENT_TAG).empty()) {
714 num_erased = kernel_->client_tags_map.erase(entry->ref(UNIQUE_CLIENT_TAG)); 712 num_erased = kernel_->client_tags_map.erase(entry->ref(UNIQUE_CLIENT_TAG));
715 DCHECK_EQ(1u, num_erased); 713 DCHECK_EQ(1u, num_erased);
716 } 714 }
717 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) { 715 if (!entry->ref(UNIQUE_SERVER_TAG).empty()) {
718 num_erased = kernel_->server_tags_map.erase(entry->ref(UNIQUE_SERVER_TAG)); 716 num_erased = kernel_->server_tags_map.erase(entry->ref(UNIQUE_SERVER_TAG));
719 DCHECK_EQ(1u, num_erased); 717 DCHECK_EQ(1u, num_erased);
720 } 718 }
721 RemoveFromAttachmentIndex(lock, handle, entry->ref(ATTACHMENT_METADATA)); 719 RemoveFromAttachmentIndex(lock, handle, entry->ref(ATTACHMENT_METADATA));
722 720
723 if (save_to_journal) { 721 if (save_to_journal) {
724 entries_to_journal->insert(entry); 722 entries_to_journal->insert(entry_ptr.release());
725 } else {
726 delete entry;
727 } 723 }
728 } 724 }
729 725
730 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet disabled_types, 726 bool Directory::PurgeEntriesWithTypeIn(ModelTypeSet disabled_types,
731 ModelTypeSet types_to_journal, 727 ModelTypeSet types_to_journal,
732 ModelTypeSet types_to_unapply) { 728 ModelTypeSet types_to_unapply) {
733 disabled_types.RemoveAll(ProxyTypes()); 729 disabled_types.RemoveAll(ProxyTypes());
734 730
735 if (disabled_types.Empty()) 731 if (disabled_types.Empty())
736 return true; 732 return true;
(...skipping 15 matching lines...) Expand all
752 found_progress = true; 748 found_progress = true;
753 } 749 }
754 750
755 // If none of the disabled types have progress markers, there's nothing to 751 // If none of the disabled types have progress markers, there's nothing to
756 // purge. 752 // purge.
757 if (!found_progress) 753 if (!found_progress)
758 return true; 754 return true;
759 755
760 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); 756 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
761 it != kernel_->metahandles_map.end();) { 757 it != kernel_->metahandles_map.end();) {
762 EntryKernel* entry = it->second; 758 EntryKernel* entry = it->second.get();
763 const sync_pb::EntitySpecifics& local_specifics = entry->ref(SPECIFICS); 759 const sync_pb::EntitySpecifics& local_specifics = entry->ref(SPECIFICS);
764 const sync_pb::EntitySpecifics& server_specifics = 760 const sync_pb::EntitySpecifics& server_specifics =
765 entry->ref(SERVER_SPECIFICS); 761 entry->ref(SERVER_SPECIFICS);
766 ModelType local_type = GetModelTypeFromSpecifics(local_specifics); 762 ModelType local_type = GetModelTypeFromSpecifics(local_specifics);
767 ModelType server_type = GetModelTypeFromSpecifics(server_specifics); 763 ModelType server_type = GetModelTypeFromSpecifics(server_specifics);
768 764
769 // Increment the iterator before (potentially) calling DeleteEntry, 765 // Increment the iterator before (potentially) calling DeleteEntry,
770 // otherwise our iterator may be invalidated. 766 // otherwise our iterator may be invalidated.
771 ++it; 767 ++it;
772 768
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 GetMetaHandlesOfType(lock, trans, type, result); 1077 GetMetaHandlesOfType(lock, trans, type, result);
1082 } 1078 }
1083 1079
1084 void Directory::GetMetaHandlesOfType(const ScopedKernelLock& lock, 1080 void Directory::GetMetaHandlesOfType(const ScopedKernelLock& lock,
1085 BaseTransaction* trans, 1081 BaseTransaction* trans,
1086 ModelType type, 1082 ModelType type,
1087 std::vector<int64_t>* result) { 1083 std::vector<int64_t>* result) {
1088 result->clear(); 1084 result->clear();
1089 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); 1085 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
1090 it != kernel_->metahandles_map.end(); ++it) { 1086 it != kernel_->metahandles_map.end(); ++it) {
1091 EntryKernel* entry = it->second; 1087 EntryKernel* entry = it->second.get();
1092 const ModelType entry_type = 1088 const ModelType entry_type =
1093 GetModelTypeFromSpecifics(entry->ref(SPECIFICS)); 1089 GetModelTypeFromSpecifics(entry->ref(SPECIFICS));
1094 if (entry_type == type) 1090 if (entry_type == type)
1095 result->push_back(it->first); 1091 result->push_back(it->first);
1096 } 1092 }
1097 } 1093 }
1098 1094
1099 void Directory::CollectMetaHandleCounts( 1095 void Directory::CollectMetaHandleCounts(
1100 std::vector<int>* num_entries_by_type, 1096 std::vector<int>* num_entries_by_type,
1101 std::vector<int>* num_to_delete_entries_by_type) { 1097 std::vector<int>* num_to_delete_entries_by_type) {
1102 syncable::ReadTransaction trans(FROM_HERE, this); 1098 syncable::ReadTransaction trans(FROM_HERE, this);
1103 ScopedKernelLock lock(this); 1099 ScopedKernelLock lock(this);
1104 1100
1105 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); 1101 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
1106 it != kernel_->metahandles_map.end(); ++it) { 1102 it != kernel_->metahandles_map.end(); ++it) {
1107 EntryKernel* entry = it->second; 1103 EntryKernel* entry = it->second.get();
1108 const ModelType type = GetModelTypeFromSpecifics(entry->ref(SPECIFICS)); 1104 const ModelType type = GetModelTypeFromSpecifics(entry->ref(SPECIFICS));
1109 (*num_entries_by_type)[type]++; 1105 (*num_entries_by_type)[type]++;
1110 if (entry->ref(IS_DEL)) 1106 if (entry->ref(IS_DEL))
1111 (*num_to_delete_entries_by_type)[type]++; 1107 (*num_to_delete_entries_by_type)[type]++;
1112 } 1108 }
1113 } 1109 }
1114 1110
1115 std::unique_ptr<base::ListValue> Directory::GetNodeDetailsForType( 1111 std::unique_ptr<base::ListValue> Directory::GetNodeDetailsForType(
1116 BaseTransaction* trans, 1112 BaseTransaction* trans,
1117 ModelType type) { 1113 ModelType type) {
1118 std::unique_ptr<base::ListValue> nodes(new base::ListValue()); 1114 std::unique_ptr<base::ListValue> nodes(new base::ListValue());
1119 1115
1120 ScopedKernelLock lock(this); 1116 ScopedKernelLock lock(this);
1121 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin(); 1117 for (MetahandlesMap::iterator it = kernel_->metahandles_map.begin();
1122 it != kernel_->metahandles_map.end(); ++it) { 1118 it != kernel_->metahandles_map.end(); ++it) {
1123 if (GetModelTypeFromSpecifics(it->second->ref(SPECIFICS)) != type) { 1119 if (GetModelTypeFromSpecifics(it->second->ref(SPECIFICS)) != type) {
1124 continue; 1120 continue;
1125 } 1121 }
1126 1122
1127 EntryKernel* kernel = it->second; 1123 EntryKernel* kernel = it->second.get();
1128 std::unique_ptr<base::DictionaryValue> node( 1124 std::unique_ptr<base::DictionaryValue> node(
1129 kernel->ToValue(GetCryptographer(trans))); 1125 kernel->ToValue(GetCryptographer(trans)));
1130 1126
1131 // Add the position index if appropriate. This must be done here (and not 1127 // Add the position index if appropriate. This must be done here (and not
1132 // in EntryKernel) because the EntryKernel does not have access to its 1128 // in EntryKernel) because the EntryKernel does not have access to its
1133 // siblings. 1129 // siblings.
1134 if (kernel->ShouldMaintainPosition() && !kernel->ref(IS_DEL)) { 1130 if (kernel->ShouldMaintainPosition() && !kernel->ref(IS_DEL)) {
1135 node->SetInteger("positionIndex", GetPositionIndex(trans, kernel)); 1131 node->SetInteger("positionIndex", GetPositionIndex(trans, kernel));
1136 } 1132 }
1137 1133
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 Directory::Kernel* Directory::kernel() { 1539 Directory::Kernel* Directory::kernel() {
1544 return kernel_; 1540 return kernel_;
1545 } 1541 }
1546 1542
1547 const Directory::Kernel* Directory::kernel() const { 1543 const Directory::Kernel* Directory::kernel() const {
1548 return kernel_; 1544 return kernel_;
1549 } 1545 }
1550 1546
1551 } // namespace syncable 1547 } // namespace syncable
1552 } // namespace syncer 1548 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/directory.h ('k') | components/sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698