OLD | NEW |
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_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "sync/internal_api/public/base_transaction.h" | 10 #include "sync/internal_api/public/base_transaction.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Sync API's WriteTransaction is a read/write BaseTransaction. It wraps | 23 // Sync API's WriteTransaction is a read/write BaseTransaction. It wraps |
24 // a syncable::WriteTransaction. | 24 // a syncable::WriteTransaction. |
25 // | 25 // |
26 // NOTE: Only a single model type can be mutated for a given | 26 // NOTE: Only a single model type can be mutated for a given |
27 // WriteTransaction. | 27 // WriteTransaction. |
28 class WriteTransaction : public BaseTransaction { | 28 class WriteTransaction : public BaseTransaction { |
29 public: | 29 public: |
30 // Start a new read/write transaction. | 30 // Start a new read/write transaction. |
31 WriteTransaction(const tracked_objects::Location& from_here, | 31 WriteTransaction(const tracked_objects::Location& from_here, |
32 UserShare* share); | 32 UserShare* share); |
| 33 // |transaction_version| stores updated model and nodes version if model |
| 34 // is changed by the transaction, or syncer::syncable::kInvalidTransaction |
| 35 // if not after transaction is closed. This constructor is used for model |
| 36 // types that support embassy data. |
| 37 WriteTransaction(const tracked_objects::Location& from_here, |
| 38 UserShare* share, int64* transaction_version); |
33 virtual ~WriteTransaction(); | 39 virtual ~WriteTransaction(); |
34 | 40 |
35 // Provide access to the syncable transaction from the API WriteNode. | 41 // Provide access to the syncable transaction from the API WriteNode. |
36 virtual syncable::BaseTransaction* GetWrappedTrans() const OVERRIDE; | 42 virtual syncable::BaseTransaction* GetWrappedTrans() const OVERRIDE; |
37 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } | 43 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } |
38 | 44 |
39 protected: | 45 protected: |
40 WriteTransaction() {} | 46 WriteTransaction() {} |
41 | 47 |
42 void SetTransaction(syncable::WriteTransaction* trans) { | 48 void SetTransaction(syncable::WriteTransaction* trans) { |
43 transaction_ = trans; | 49 transaction_ = trans; |
44 } | 50 } |
45 | 51 |
46 private: | 52 private: |
47 void* operator new(size_t size); // Transaction is meant for stack use only. | 53 void* operator new(size_t size); // Transaction is meant for stack use only. |
48 | 54 |
49 // The underlying syncable object which this class wraps. | 55 // The underlying syncable object which this class wraps. |
50 syncable::WriteTransaction* transaction_; | 56 syncable::WriteTransaction* transaction_; |
51 | 57 |
52 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 58 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
53 }; | 59 }; |
54 | 60 |
55 } // namespace syncer | 61 } // namespace syncer |
56 | 62 |
57 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ | 63 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ |
OLD | NEW |