| Index: components/sync/syncable/syncable_delete_journal.h
|
| diff --git a/components/sync/syncable/syncable_delete_journal.h b/components/sync/syncable/syncable_delete_journal.h
|
| index 218f516b31c154e27e8fa9433e0615043615aa89..8fc4635a04136336f12092eee322bc274381063c 100644
|
| --- a/components/sync/syncable/syncable_delete_journal.h
|
| +++ b/components/sync/syncable/syncable_delete_journal.h
|
| @@ -7,21 +7,31 @@
|
|
|
| #include <stddef.h>
|
|
|
| -#include <set>
|
| +#include <map>
|
|
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| #include "base/synchronization/lock.h"
|
| +#include "components/sync/syncable/entry_kernel.h"
|
| #include "components/sync/syncable/metahandle_set.h"
|
| -#include "components/sync/syncable/syncable-inl.h"
|
|
|
| namespace syncer {
|
| namespace syncable {
|
|
|
| class BaseTransaction;
|
| -struct EntryKernel;
|
|
|
| -typedef std::set<const EntryKernel*, LessField<IdField, ID>> JournalIndex;
|
| +class LessByID {
|
| + public:
|
| + inline bool operator()(const EntryKernel* a, const EntryKernel* b) const {
|
| + return a->ref(ID) < b->ref(ID);
|
| + }
|
| +};
|
| +// This should be |std::set<std::unique_ptr<EntryKernel>, LessByID>|. However,
|
| +// DeleteJournal::TakeSnapshotAndClear needs to remove the unique_ptr from the
|
| +// set, and std::set::extract is only available in C++17. TODO(avi): Switch to
|
| +// using a std::set when Chromium allows C++17 use.
|
| +typedef std::map<const EntryKernel*, std::unique_ptr<EntryKernel>, LessByID>
|
| + JournalIndex;
|
|
|
| // DeleteJournal manages deleted entries that are not in sync directory until
|
| // it's safe to drop them after the deletion is confirmed with native models.
|
| @@ -30,9 +40,8 @@ typedef std::set<const EntryKernel*, LessField<IdField, ID>> JournalIndex;
|
| // method requires a non-null |trans| parameter.
|
| class DeleteJournal {
|
| public:
|
| - // Initialize |delete_journals_| using |intitial_journal|, whose content is
|
| - // destroyed during initialization.
|
| - explicit DeleteJournal(JournalIndex* initial_journal);
|
| + // Initialize |delete_journals_| using |initial_journal|.
|
| + explicit DeleteJournal(std::unique_ptr<JournalIndex> initial_journal);
|
| ~DeleteJournal();
|
|
|
| // For testing only.
|
| @@ -67,7 +76,7 @@ class DeleteJournal {
|
| // |passive_delete_journal_types_| to |journal_entries|. Move handles in
|
| // |delete_journals_to_purge_| to |journals_to_purge|. Called on sync thread.
|
| void TakeSnapshotAndClear(BaseTransaction* trans,
|
| - EntryKernelSet* journal_entries,
|
| + OwnedEntryKernelSet* journal_entries,
|
| MetahandleSet* journals_to_purge);
|
|
|
| // Add |entries| to |delete_journals_| regardless of their SERVER_IS_DEL
|
| @@ -76,7 +85,8 @@ class DeleteJournal {
|
| // * batch add entries of a data type with unrecoverable error to delete
|
| // journal before purging them.
|
| // Called on sync thread.
|
| - void AddJournalBatch(BaseTransaction* trans, const EntryKernelSet& entries);
|
| + void AddJournalBatch(BaseTransaction* trans,
|
| + const OwnedEntryKernelSet& entries);
|
|
|
| // Return true if delete journals of |type| are maintained.
|
| static bool IsDeleteJournalEnabled(ModelType type);
|
|
|