Chromium Code Reviews| 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 // |new_model_version| stores updated model version if model is changed by | |
| 34 // the transaction, or -1 if not after transaction is closed. This | |
|
tim (not reviewing)
2012/11/08 17:38:49
kInvalidTransactionVersion here too
haitaol1
2012/11/08 19:06:53
Done.
| |
| 35 // constructor is used for model types that support embassy data. | |
| 36 WriteTransaction(const tracked_objects::Location& from_here, | |
| 37 UserShare* share, int64* new_model_version); | |
| 33 virtual ~WriteTransaction(); | 38 virtual ~WriteTransaction(); |
| 34 | 39 |
| 35 // Provide access to the syncable transaction from the API WriteNode. | 40 // Provide access to the syncable transaction from the API WriteNode. |
| 36 virtual syncable::BaseTransaction* GetWrappedTrans() const OVERRIDE; | 41 virtual syncable::BaseTransaction* GetWrappedTrans() const OVERRIDE; |
| 37 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } | 42 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } |
| 38 | 43 |
| 39 protected: | 44 protected: |
| 40 WriteTransaction() {} | 45 WriteTransaction() {} |
| 41 | 46 |
| 42 void SetTransaction(syncable::WriteTransaction* trans) { | 47 void SetTransaction(syncable::WriteTransaction* trans) { |
| 43 transaction_ = trans; | 48 transaction_ = trans; |
| 44 } | 49 } |
| 45 | 50 |
| 46 private: | 51 private: |
| 47 void* operator new(size_t size); // Transaction is meant for stack use only. | 52 void* operator new(size_t size); // Transaction is meant for stack use only. |
| 48 | 53 |
| 49 // The underlying syncable object which this class wraps. | 54 // The underlying syncable object which this class wraps. |
| 50 syncable::WriteTransaction* transaction_; | 55 syncable::WriteTransaction* transaction_; |
| 51 | 56 |
| 52 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 57 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace syncer | 60 } // namespace syncer |
| 56 | 61 |
| 57 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ | 62 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_TRANSACTION_H_ |
| OLD | NEW |