| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ | 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ |
| 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ | 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/sync/internal_api/base_transaction.h" | 10 #include "chrome/browser/sync/internal_api/base_transaction.h" |
| 10 | 11 |
| 11 namespace syncable { | 12 namespace syncable { |
| 12 class BaseTransaction; | 13 class BaseTransaction; |
| 13 class WriteTransaction; | 14 class WriteTransaction; |
| 14 } // namespace syncable | 15 } // namespace syncable |
| 15 | 16 |
| 16 namespace tracked_objects { | 17 namespace tracked_objects { |
| 17 class Location; | 18 class Location; |
| 18 } // namespace tracked_objects | 19 } // namespace tracked_objects |
| 19 | 20 |
| 20 namespace sync_api { | 21 namespace sync_api { |
| 21 | 22 |
| 22 // Sync API's WriteTransaction is a read/write BaseTransaction. It wraps | 23 // Sync API's WriteTransaction is a read/write BaseTransaction. It wraps |
| 23 // a syncable::WriteTransaction. | 24 // a syncable::WriteTransaction. |
| 24 // | 25 // |
| 25 // 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 |
| 26 // WriteTransaction. | 27 // WriteTransaction. |
| 27 class WriteTransaction : public BaseTransaction { | 28 class WriteTransaction : public BaseTransaction { |
| 28 public: | 29 public: |
| 29 // Start a new read/write transaction. | 30 // Start a new read/write transaction. |
| 30 WriteTransaction(const tracked_objects::Location& from_here, | 31 WriteTransaction(const tracked_objects::Location& from_here, |
| 31 UserShare* share); | 32 UserShare* share); |
| 32 virtual ~WriteTransaction(); | 33 virtual ~WriteTransaction(); |
| 33 | 34 |
| 34 // Provide access to the syncable.h transaction from the API WriteNode. | 35 // Provide access to the syncable.h transaction from the API WriteNode. |
| 35 virtual syncable::BaseTransaction* GetWrappedTrans() const; | 36 virtual syncable::BaseTransaction* GetWrappedTrans() const OVERRIDE; |
| 36 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } | 37 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } |
| 37 | 38 |
| 38 protected: | 39 protected: |
| 39 WriteTransaction() {} | 40 WriteTransaction() {} |
| 40 | 41 |
| 41 void SetTransaction(syncable::WriteTransaction* trans) { | 42 void SetTransaction(syncable::WriteTransaction* trans) { |
| 42 transaction_ = trans; | 43 transaction_ = trans; |
| 43 } | 44 } |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 void* operator new(size_t size); // Transaction is meant for stack use only. | 47 void* operator new(size_t size); // Transaction is meant for stack use only. |
| 47 | 48 |
| 48 // The underlying syncable object which this class wraps. | 49 // The underlying syncable object which this class wraps. |
| 49 syncable::WriteTransaction* transaction_; | 50 syncable::WriteTransaction* transaction_; |
| 50 | 51 |
| 51 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 52 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 } // namespace sync_api | 55 } // namespace sync_api |
| 55 | 56 |
| 56 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ | 57 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_TRANSACTION_H_ |
| OLD | NEW |