OLD | NEW |
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 #ifndef SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ | 5 #ifndef COMPONENTS_SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ |
6 #define SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ | 6 #define COMPONENTS_SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "sync/base/sync_export.h" | 15 #include "components/sync/base/sync_export.h" |
16 #include "sync/syncable/metahandle_set.h" | 16 #include "components/sync/syncable/metahandle_set.h" |
17 #include "sync/syncable/syncable-inl.h" | 17 #include "components/sync/syncable/syncable-inl.h" |
18 | 18 |
19 namespace syncer { | 19 namespace syncer { |
20 namespace syncable { | 20 namespace syncable { |
21 | 21 |
22 class BaseTransaction; | 22 class BaseTransaction; |
23 struct EntryKernel; | 23 struct EntryKernel; |
24 | 24 |
25 typedef std::set<const EntryKernel*, LessField<IdField, ID> > JournalIndex; | 25 typedef std::set<const EntryKernel*, LessField<IdField, ID>> JournalIndex; |
26 | 26 |
27 // DeleteJournal manages deleted entries that are not in sync directory until | 27 // DeleteJournal manages deleted entries that are not in sync directory until |
28 // it's safe to drop them after the deletion is confirmed with native models. | 28 // it's safe to drop them after the deletion is confirmed with native models. |
29 // DeleteJournal is thread-safe and can be accessed on any thread. Has to hold | 29 // DeleteJournal is thread-safe and can be accessed on any thread. Has to hold |
30 // a valid transaction object when calling methods of DeleteJournal, thus each | 30 // a valid transaction object when calling methods of DeleteJournal, thus each |
31 // method requires a non-null |trans| parameter. | 31 // method requires a non-null |trans| parameter. |
32 class SYNC_EXPORT DeleteJournal { | 32 class SYNC_EXPORT DeleteJournal { |
33 public: | 33 public: |
34 // Initialize |delete_journals_| using |intitial_journal|, whose content is | 34 // Initialize |delete_journals_| using |intitial_journal|, whose content is |
35 // destroyed during initialization. | 35 // destroyed during initialization. |
(...skipping 10 matching lines...) Expand all Loading... |
46 const EntryKernel& entry); | 46 const EntryKernel& entry); |
47 | 47 |
48 // Return entries of specified type in |delete_journals_|. This should be | 48 // Return entries of specified type in |delete_journals_|. This should be |
49 // called ONCE in model association. |deleted_entries| can be used to | 49 // called ONCE in model association. |deleted_entries| can be used to |
50 // detect deleted sync data that's not persisted in native model to | 50 // detect deleted sync data that's not persisted in native model to |
51 // prevent back-from-dead problem. |deleted_entries| are only valid during | 51 // prevent back-from-dead problem. |deleted_entries| are only valid during |
52 // lifetime of |trans|. |type| is added to |passive_delete_journal_types_| to | 52 // lifetime of |trans|. |type| is added to |passive_delete_journal_types_| to |
53 // enable periodically saving/clearing of delete journals of |type| because | 53 // enable periodically saving/clearing of delete journals of |type| because |
54 // new journals added later are not needed until next model association. | 54 // new journals added later are not needed until next model association. |
55 // Can be called on any thread. | 55 // Can be called on any thread. |
56 void GetDeleteJournals(BaseTransaction* trans, ModelType type, | 56 void GetDeleteJournals(BaseTransaction* trans, |
| 57 ModelType type, |
57 EntryKernelSet* deleted_entries); | 58 EntryKernelSet* deleted_entries); |
58 | 59 |
59 // Purge entries of specified type in |delete_journals_| if their handles are | 60 // Purge entries of specified type in |delete_journals_| if their handles are |
60 // in |to_purge|. This should be called after model association and | 61 // in |to_purge|. This should be called after model association and |
61 // |to_purge| should contain handles of the entries whose deletions are | 62 // |to_purge| should contain handles of the entries whose deletions are |
62 // confirmed in native model. Can be called on any thread. | 63 // confirmed in native model. Can be called on any thread. |
63 void PurgeDeleteJournals(BaseTransaction* trans, | 64 void PurgeDeleteJournals(BaseTransaction* trans, |
64 const MetahandleSet& to_purge); | 65 const MetahandleSet& to_purge); |
65 | 66 |
66 // Move entries in |delete_journals_| whose types are in | 67 // Move entries in |delete_journals_| whose types are in |
(...skipping 30 matching lines...) Expand all Loading... |
97 // Delete journals of these types can be cleared from memory after being | 98 // Delete journals of these types can be cleared from memory after being |
98 // saved to database. | 99 // saved to database. |
99 ModelTypeSet passive_delete_journal_types_; | 100 ModelTypeSet passive_delete_journal_types_; |
100 | 101 |
101 DISALLOW_COPY_AND_ASSIGN(DeleteJournal); | 102 DISALLOW_COPY_AND_ASSIGN(DeleteJournal); |
102 }; | 103 }; |
103 | 104 |
104 } // namespace syncable | 105 } // namespace syncable |
105 } // namespace syncer | 106 } // namespace syncer |
106 | 107 |
107 #endif // SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ | 108 #endif // COMPONENTS_SYNC_SYNCABLE_SYNCABLE_DELETE_JOURNAL_H_ |
OLD | NEW |