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

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

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 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>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ModelType model_type) { 69 ModelType model_type) {
70 const sync_pb::DataTypeProgressMarker& progress_marker = 70 const sync_pb::DataTypeProgressMarker& progress_marker =
71 download_progress[model_type]; 71 download_progress[model_type];
72 return progress_marker.token().empty(); 72 return progress_marker.token().empty();
73 } 73 }
74 74
75 Directory::SaveChangesSnapshot::SaveChangesSnapshot() 75 Directory::SaveChangesSnapshot::SaveChangesSnapshot()
76 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) {} 76 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) {}
77 77
78 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() { 78 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {
79 STLDeleteElements(&dirty_metas); 79 base::STLDeleteElements(&dirty_metas);
80 STLDeleteElements(&delete_journals); 80 base::STLDeleteElements(&delete_journals);
81 } 81 }
82 82
83 bool Directory::SaveChangesSnapshot::HasUnsavedMetahandleChanges() const { 83 bool Directory::SaveChangesSnapshot::HasUnsavedMetahandleChanges() const {
84 return !dirty_metas.empty() || !metahandles_to_purge.empty() || 84 return !dirty_metas.empty() || !metahandles_to_purge.empty() ||
85 !delete_journals.empty() || !delete_journals_to_purge.empty(); 85 !delete_journals.empty() || !delete_journals_to_purge.empty();
86 } 86 }
87 87
88 Directory::Kernel::Kernel( 88 Directory::Kernel::Kernel(
89 const std::string& name, 89 const std::string& name,
90 const KernelLoadInfo& info, 90 const KernelLoadInfo& info,
91 DirectoryChangeDelegate* delegate, 91 DirectoryChangeDelegate* delegate,
92 const WeakHandle<TransactionObserver>& transaction_observer) 92 const WeakHandle<TransactionObserver>& transaction_observer)
93 : next_write_transaction_id(0), 93 : next_write_transaction_id(0),
94 name(name), 94 name(name),
95 info_status(Directory::KERNEL_SHARE_INFO_VALID), 95 info_status(Directory::KERNEL_SHARE_INFO_VALID),
96 persisted_info(info.kernel_info), 96 persisted_info(info.kernel_info),
97 cache_guid(info.cache_guid), 97 cache_guid(info.cache_guid),
98 next_metahandle(info.max_metahandle + 1), 98 next_metahandle(info.max_metahandle + 1),
99 delegate(delegate), 99 delegate(delegate),
100 transaction_observer(transaction_observer) { 100 transaction_observer(transaction_observer) {
101 DCHECK(delegate); 101 DCHECK(delegate);
102 DCHECK(transaction_observer.IsInitialized()); 102 DCHECK(transaction_observer.IsInitialized());
103 } 103 }
104 104
105 Directory::Kernel::~Kernel() { 105 Directory::Kernel::~Kernel() {
106 STLDeleteContainerPairSecondPointers(metahandles_map.begin(), 106 base::STLDeleteContainerPairSecondPointers(metahandles_map.begin(),
107 metahandles_map.end()); 107 metahandles_map.end());
108 } 108 }
109 109
110 Directory::Directory( 110 Directory::Directory(
111 DirectoryBackingStore* store, 111 DirectoryBackingStore* store,
112 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, 112 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
113 const base::Closure& report_unrecoverable_error_function, 113 const base::Closure& report_unrecoverable_error_function,
114 NigoriHandler* nigori_handler, 114 NigoriHandler* nigori_handler,
115 Cryptographer* cryptographer) 115 Cryptographer* cryptographer)
116 : kernel_(NULL), 116 : kernel_(NULL),
117 store_(store), 117 store_(store),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const string& name, 180 const string& name,
181 DirectoryChangeDelegate* delegate, 181 DirectoryChangeDelegate* delegate,
182 const WeakHandle<TransactionObserver>& transaction_observer) { 182 const WeakHandle<TransactionObserver>& transaction_observer) {
183 KernelLoadInfo info; 183 KernelLoadInfo info;
184 // Temporary indices before kernel_ initialized in case Load fails. We 0(1) 184 // Temporary indices before kernel_ initialized in case Load fails. We 0(1)
185 // swap these later. 185 // swap these later.
186 Directory::MetahandlesMap tmp_handles_map; 186 Directory::MetahandlesMap tmp_handles_map;
187 187
188 // Avoids mem leaks on failure. Harmlessly deletes the empty hash map after 188 // Avoids mem leaks on failure. Harmlessly deletes the empty hash map after
189 // the swap in the success case. 189 // the swap in the success case.
190 STLValueDeleter<MetahandlesMap> deleter(&tmp_handles_map); 190 base::STLValueDeleter<MetahandlesMap> deleter(&tmp_handles_map);
191 191
192 JournalIndex delete_journals; 192 JournalIndex delete_journals;
193 MetahandleSet metahandles_to_purge; 193 MetahandleSet metahandles_to_purge;
194 194
195 DirOpenResult result = store_->Load(&tmp_handles_map, &delete_journals, 195 DirOpenResult result = store_->Load(&tmp_handles_map, &delete_journals,
196 &metahandles_to_purge, &info); 196 &metahandles_to_purge, &info);
197 if (OPENED != result) 197 if (OPENED != result)
198 return result; 198 return result;
199 199
200 DCHECK(!kernel_); 200 DCHECK(!kernel_);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 ModelTypeSet types_to_unapply) { 732 ModelTypeSet types_to_unapply) {
733 disabled_types.RemoveAll(ProxyTypes()); 733 disabled_types.RemoveAll(ProxyTypes());
734 734
735 if (disabled_types.Empty()) 735 if (disabled_types.Empty())
736 return true; 736 return true;
737 737
738 { 738 {
739 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); 739 WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this);
740 740
741 EntryKernelSet entries_to_journal; 741 EntryKernelSet entries_to_journal;
742 STLElementDeleter<EntryKernelSet> journal_deleter(&entries_to_journal); 742 base::STLElementDeleter<EntryKernelSet> journal_deleter(
743 &entries_to_journal);
743 744
744 { 745 {
745 ScopedKernelLock lock(this); 746 ScopedKernelLock lock(this);
746 747
747 bool found_progress = false; 748 bool found_progress = false;
748 for (ModelTypeSet::Iterator iter = disabled_types.First(); iter.Good(); 749 for (ModelTypeSet::Iterator iter = disabled_types.First(); iter.Good();
749 iter.Inc()) { 750 iter.Inc()) {
750 if (!kernel_->persisted_info.HasEmptyDownloadProgress(iter.Get())) 751 if (!kernel_->persisted_info.HasEmptyDownloadProgress(iter.Get()))
751 found_progress = true; 752 found_progress = true;
752 } 753 }
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 Directory::Kernel* Directory::kernel() { 1543 Directory::Kernel* Directory::kernel() {
1543 return kernel_; 1544 return kernel_;
1544 } 1545 }
1545 1546
1546 const Directory::Kernel* Directory::kernel() const { 1547 const Directory::Kernel* Directory::kernel() const {
1547 return kernel_; 1548 return kernel_;
1548 } 1549 }
1549 1550
1550 } // namespace syncable 1551 } // namespace syncable
1551 } // namespace syncer 1552 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698