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