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/write_transaction.h

Issue 11341048: Populate versions on individual nodes in sync model and native bookmark model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « sync/syncable/syncable_unittest.cc ('k') | sync/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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_WRITE_TRANSACTION_H_ 5 #ifndef SYNC_SYNCABLE_WRITE_TRANSACTION_H_
6 #define SYNC_SYNCABLE_WRITE_TRANSACTION_H_ 6 #define SYNC_SYNCABLE_WRITE_TRANSACTION_H_
7 7
8 #include "sync/syncable/base_transaction.h" 8 #include "sync/syncable/base_transaction.h"
9 #include "sync/syncable/entry_kernel.h" 9 #include "sync/syncable/entry_kernel.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 namespace syncable { 12 namespace syncable {
13 13
14 extern const int64 kInvalidTransactionVersion;
15
14 // Locks db in constructor, unlocks in destructor. 16 // Locks db in constructor, unlocks in destructor.
15 class WriteTransaction : public BaseTransaction { 17 class WriteTransaction : public BaseTransaction {
16 public: 18 public:
17 WriteTransaction(const tracked_objects::Location& from_here, 19 WriteTransaction(const tracked_objects::Location& from_here,
18 WriterTag writer, Directory* directory); 20 WriterTag writer, Directory* directory);
19 21
22 // Constructor used for getting back transaction version after making sync
23 // API changes to one model. If model is changed by the transaction,
24 // the new transaction version of the model and modified nodes will be saved
25 // in |transaction_version| upon destruction of the transaction. If model is
26 // not changed, |transaction_version| will be kInvalidTransactionVersion.
27 WriteTransaction(const tracked_objects::Location& from_here,
28 Directory* directory, int64* transaction_version);
29
20 virtual ~WriteTransaction(); 30 virtual ~WriteTransaction();
21 31
22 void SaveOriginal(const EntryKernel* entry); 32 void SaveOriginal(const EntryKernel* entry);
23 33
24 protected: 34 protected:
25 // Overridden by tests. 35 // Overridden by tests.
26 virtual void NotifyTransactionComplete(ModelTypeSet models_with_changes); 36 virtual void NotifyTransactionComplete(ModelTypeSet models_with_changes);
27 37
28 private: 38 private:
29 friend class MutableEntry; 39 friend class MutableEntry;
30 40
31 // Clears |mutations_|. 41 // Clears |mutations_|.
32 ImmutableEntryKernelMutationMap RecordMutations(); 42 ImmutableEntryKernelMutationMap RecordMutations();
33 43
34 void UnlockAndNotify(const ImmutableEntryKernelMutationMap& mutations); 44 void UnlockAndNotify(const ImmutableEntryKernelMutationMap& mutations);
35 45
36 ModelTypeSet NotifyTransactionChangingAndEnding( 46 ModelTypeSet NotifyTransactionChangingAndEnding(
37 const ImmutableEntryKernelMutationMap& mutations); 47 const ImmutableEntryKernelMutationMap& mutations);
38 48
49 // Increment versions of the models whose entries are modified and set the
50 // version on the changed entries.
51 void UpdateTransactionVersion(const std::vector<int64>& entry_changed);
52
39 // Only the original fields are filled in until |RecordMutations()|. 53 // Only the original fields are filled in until |RecordMutations()|.
40 // We use a mutation map instead of a kernel set to avoid copying. 54 // We use a mutation map instead of a kernel set to avoid copying.
41 EntryKernelMutationMap mutations_; 55 EntryKernelMutationMap mutations_;
42 56
57 // Stores new transaction version of changed model and nodes if model is
58 // indeed changed. kInvalidTransactionVersion otherwise. Not owned.
59 int64* transaction_version_;
60
43 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); 61 DISALLOW_COPY_AND_ASSIGN(WriteTransaction);
44 }; 62 };
45 63
46 } // namespace syncable 64 } // namespace syncable
47 } // namespace syncer 65 } // namespace syncer
48 66
49 #endif // SYNC_SYNCABLE_WRITE_TRANSACTION_H_ 67 #endif // SYNC_SYNCABLE_WRITE_TRANSACTION_H_
OLDNEW
« no previous file with comments | « sync/syncable/syncable_unittest.cc ('k') | sync/syncable/write_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698