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_WRITE_TRANSACTION_H_ | 5 #ifndef COMPONENTS_SYNC_CORE_WRITE_TRANSACTION_H_ |
6 #define COMPONENTS_SYNC_CORE_WRITE_TRANSACTION_H_ | 6 #define COMPONENTS_SYNC_CORE_WRITE_TRANSACTION_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 // a syncable::WriteTransaction. | 30 // a syncable::WriteTransaction. |
31 // | 31 // |
32 // NOTE: Only a single model type can be mutated for a given | 32 // NOTE: Only a single model type can be mutated for a given |
33 // WriteTransaction. | 33 // WriteTransaction. |
34 class WriteTransaction : public BaseTransaction { | 34 class WriteTransaction : public BaseTransaction { |
35 public: | 35 public: |
36 // Start a new read/write transaction. | 36 // Start a new read/write transaction. |
37 WriteTransaction(const tracked_objects::Location& from_here, | 37 WriteTransaction(const tracked_objects::Location& from_here, |
38 UserShare* share); | 38 UserShare* share); |
39 // |transaction_version| stores updated model and nodes version if model | 39 // |transaction_version| stores updated model and nodes version if model |
40 // is changed by the transaction, or syncer::syncable::kInvalidTransaction | 40 // is changed by the transaction, or syncable::kInvalidTransaction |
41 // if not after transaction is closed. This constructor is used for model | 41 // if not after transaction is closed. This constructor is used for model |
42 // types that support embassy data. | 42 // types that support embassy data. |
43 WriteTransaction(const tracked_objects::Location& from_here, | 43 WriteTransaction(const tracked_objects::Location& from_here, |
44 UserShare* share, | 44 UserShare* share, |
45 int64_t* transaction_version); | 45 int64_t* transaction_version); |
46 ~WriteTransaction() override; | 46 ~WriteTransaction() override; |
47 | 47 |
48 // Provide access to the syncable transaction from the API WriteNode. | 48 // Provide access to the syncable transaction from the API WriteNode. |
49 syncable::BaseTransaction* GetWrappedTrans() const override; | 49 syncable::BaseTransaction* GetWrappedTrans() const override; |
50 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } | 50 syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; } |
51 | 51 |
52 // Set's a |type|'s local context. |refresh_status| controls whether | 52 // Set's a |type|'s local context. |refresh_status| controls whether |
53 // a datatype refresh is performed (clearing the progress marker token and | 53 // a datatype refresh is performed (clearing the progress marker token and |
54 // setting the version of all synced entities to 1). | 54 // setting the version of all synced entities to 1). |
55 void SetDataTypeContext( | 55 void SetDataTypeContext( |
56 ModelType type, | 56 ModelType type, |
57 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, | 57 SyncChangeProcessor::ContextRefreshStatus refresh_status, |
58 const std::string& context); | 58 const std::string& context); |
59 | 59 |
60 // Update all entries that refer to |attachment_id| indicating that | 60 // Update all entries that refer to |attachment_id| indicating that |
61 // |attachment_id| has been uploaded to the sync server. | 61 // |attachment_id| has been uploaded to the sync server. |
62 void UpdateEntriesMarkAttachmentAsOnServer(const AttachmentId& attachment_id); | 62 void UpdateEntriesMarkAttachmentAsOnServer(const AttachmentId& attachment_id); |
63 | 63 |
64 protected: | 64 protected: |
65 WriteTransaction() {} | 65 WriteTransaction() {} |
66 | 66 |
67 void SetTransaction(syncable::WriteTransaction* trans) { | 67 void SetTransaction(syncable::WriteTransaction* trans) { |
68 transaction_ = trans; | 68 transaction_ = trans; |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 void* operator new(size_t size); // Transaction is meant for stack use only. | 72 void* operator new(size_t size); // Transaction is meant for stack use only. |
73 | 73 |
74 // The underlying syncable object which this class wraps. | 74 // The underlying syncable object which this class wraps. |
75 syncable::WriteTransaction* transaction_; | 75 syncable::WriteTransaction* transaction_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); | 77 DISALLOW_COPY_AND_ASSIGN(WriteTransaction); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace syncer | 80 } // namespace syncer |
81 | 81 |
82 #endif // COMPONENTS_SYNC_CORE_WRITE_TRANSACTION_H_ | 82 #endif // COMPONENTS_SYNC_CORE_WRITE_TRANSACTION_H_ |
OLD | NEW |