| OLD | NEW |
| (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_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_ | |
| 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "sync/base/sync_export.h" | |
| 10 #include "sync/internal_api/public/base/model_type.h" | |
| 11 #include "sync/internal_api/public/user_share.h" | |
| 12 #include "sync/util/cryptographer.h" | |
| 13 | |
| 14 namespace syncer { | |
| 15 | |
| 16 namespace syncable { | |
| 17 class BaseTransaction; | |
| 18 class Directory; | |
| 19 } | |
| 20 | |
| 21 // Sync API's BaseTransaction, ReadTransaction, and WriteTransaction allow for | |
| 22 // batching of several read and/or write operations. The read and write | |
| 23 // operations are performed by creating ReadNode and WriteNode instances using | |
| 24 // the transaction. These transaction classes wrap identically named classes in | |
| 25 // syncable, and are used in a similar way. Unlike syncable::BaseTransaction, | |
| 26 // whose construction requires an explicit syncable::Directory, a sync | |
| 27 // API BaseTransaction is created from a UserShare object. | |
| 28 // | |
| 29 // Note, these transactions are not atomic. Individual operations can | |
| 30 // fail. There is no built-in rollback or undo mechanism. | |
| 31 class SYNC_EXPORT BaseTransaction { | |
| 32 public: | |
| 33 // Provide access to the underlying syncable objects from BaseNode. | |
| 34 virtual syncable::BaseTransaction* GetWrappedTrans() const = 0; | |
| 35 Cryptographer* GetCryptographer() const; | |
| 36 ModelTypeSet GetEncryptedTypes() const; | |
| 37 | |
| 38 syncable::Directory* GetDirectory() const { | |
| 39 if (!user_share_) { | |
| 40 return NULL; | |
| 41 } else { | |
| 42 return user_share_->directory.get(); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 UserShare* GetUserShare() const { | |
| 47 return user_share_; | |
| 48 } | |
| 49 | |
| 50 protected: | |
| 51 explicit BaseTransaction(UserShare* share); | |
| 52 virtual ~BaseTransaction(); | |
| 53 | |
| 54 BaseTransaction() : user_share_(NULL) { } | |
| 55 | |
| 56 private: | |
| 57 UserShare* user_share_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(BaseTransaction); | |
| 60 }; | |
| 61 | |
| 62 } // namespace syncer | |
| 63 | |
| 64 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_TRANSACTION_H_ | |
| OLD | NEW |