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