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

Side by Side Diff: sync/syncable/syncable_write_transaction.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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
« no previous file with comments | « sync/syncable/syncable_util_unittest.cc ('k') | sync/syncable/syncable_write_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SYNC_SYNCABLE_SYNCABLE_WRITE_TRANSACTION_H_
6 #define SYNC_SYNCABLE_SYNCABLE_WRITE_TRANSACTION_H_
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/syncable/entry_kernel.h"
15 #include "sync/syncable/syncable_base_write_transaction.h"
16
17 namespace syncer {
18 namespace syncable {
19
20 SYNC_EXPORT extern const int64_t kInvalidTransactionVersion;
21
22 // Locks db in constructor, unlocks in destructor.
23 class SYNC_EXPORT WriteTransaction : public BaseWriteTransaction {
24 public:
25 WriteTransaction(const tracked_objects::Location& from_here,
26 WriterTag writer, Directory* directory);
27
28 // Constructor used for getting back transaction version after making sync
29 // API changes to one model. If model is changed by the transaction,
30 // the new transaction version of the model and modified nodes will be saved
31 // in |transaction_version| upon destruction of the transaction. If model is
32 // not changed, |transaction_version| will be kInvalidTransactionVersion.
33 WriteTransaction(const tracked_objects::Location& from_here,
34 Directory* directory,
35 int64_t* transaction_version);
36
37 ~WriteTransaction() override;
38
39 void TrackChangesTo(const EntryKernel* entry) override;
40
41 protected:
42 // Overridden by tests.
43 virtual void NotifyTransactionComplete(ModelTypeSet models_with_changes);
44
45 private:
46 friend class MutableEntry;
47
48 // Clears |mutations_|.
49 ImmutableEntryKernelMutationMap RecordMutations();
50
51 void UnlockAndNotify(const ImmutableEntryKernelMutationMap& mutations);
52
53 ModelTypeSet NotifyTransactionChangingAndEnding(
54 const ImmutableEntryKernelMutationMap& mutations);
55
56 // Increment versions of the models whose entries are modified and set the
57 // version on the changed entries.
58 void UpdateTransactionVersion(const std::vector<int64_t>& entry_changed);
59
60 // Only the original fields are filled in until |RecordMutations()|.
61 // We use a mutation map instead of a kernel set to avoid copying.
62 EntryKernelMutationMap mutations_;
63
64 // Stores new transaction version of changed model and nodes if model is
65 // indeed changed. kInvalidTransactionVersion otherwise. Not owned.
66 int64_t* transaction_version_;
67
68 DISALLOW_COPY_AND_ASSIGN(WriteTransaction);
69 };
70
71 } // namespace syncable
72 } // namespace syncer
73
74 #endif // SYNC_SYNCABLE_SYNCABLE_WRITE_TRANSACTION_H_
OLDNEW
« no previous file with comments | « sync/syncable/syncable_util_unittest.cc ('k') | sync/syncable/syncable_write_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698