[email protected] | cc7a544c | 2013-01-02 08:31:51 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 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_SYNCABLE_MUTABLE_ENTRY_H_ |
| 6 | #define SYNC_SYNCABLE_MUTABLE_ENTRY_H_ |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 7 | |
[email protected] | cc7a544c | 2013-01-02 08:31:51 | [diff] [blame] | 8 | #include "sync/base/sync_export.h" |
[email protected] | 47b0ab7 | 2013-01-12 19:25:25 | [diff] [blame] | 9 | #include "sync/internal_api/public/base/model_type.h" |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 10 | #include "sync/syncable/entry.h" |
| 11 | #include "sync/syncable/metahandle_set.h" |
[email protected] | 4f435f7 | 2013-09-24 19:44:11 | [diff] [blame] | 12 | #include "sync/syncable/model_neutral_mutable_entry.h" |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 13 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 14 | namespace syncer { |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 15 | class WriteNode; |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 16 | |
| 17 | namespace syncable { |
| 18 | |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 19 | enum Create { |
| 20 | CREATE |
| 21 | }; |
| 22 | |
[email protected] | 4f435f7 | 2013-09-24 19:44:11 | [diff] [blame] | 23 | class WriteTransaction; |
| 24 | |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 25 | // A mutable meta entry. Changes get committed to the database when the |
| 26 | // WriteTransaction is destroyed. |
[email protected] | 4f435f7 | 2013-09-24 19:44:11 | [diff] [blame] | 27 | class SYNC_EXPORT_PRIVATE MutableEntry : public ModelNeutralMutableEntry { |
[email protected] | 47b0ab7 | 2013-01-12 19:25:25 | [diff] [blame] | 28 | void Init(WriteTransaction* trans, ModelType model_type, |
| 29 | const Id& parent_id, const std::string& name); |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 30 | |
| 31 | public: |
[email protected] | 4f435f7 | 2013-09-24 19:44:11 | [diff] [blame] | 32 | MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id); |
stanisc | 277354df | 2015-01-12 19:54:52 | [diff] [blame] | 33 | MutableEntry(WriteTransaction* trans, |
| 34 | Create, |
| 35 | ModelType model_type, |
| 36 | const std::string& name); |
| 37 | MutableEntry(WriteTransaction* trans, |
| 38 | Create, |
| 39 | ModelType model_type, |
| 40 | const Id& parent_id, |
| 41 | const std::string& name); |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 42 | MutableEntry(WriteTransaction* trans, GetByHandle, int64); |
| 43 | MutableEntry(WriteTransaction* trans, GetById, const Id&); |
| 44 | MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag); |
[email protected] | 65e95b7 | 2014-06-03 20:45:28 | [diff] [blame] | 45 | MutableEntry(WriteTransaction* trans, GetTypeRoot, ModelType type); |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 46 | |
[email protected] | 74af9105 | 2013-09-26 09:42:36 | [diff] [blame] | 47 | inline WriteTransaction* write_transaction() const { |
| 48 | return write_transaction_; |
| 49 | } |
| 50 | |
[email protected] | 4f435f7 | 2013-09-24 19:44:11 | [diff] [blame] | 51 | // Model-changing setters. These setters make user-visible changes that will |
| 52 | // need to be communicated either to the local model or the sync server. |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 53 | void PutLocalExternalId(int64 value); |
| 54 | void PutMtime(base::Time value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 55 | void PutCtime(base::Time value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 56 | void PutParentId(const Id& value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 57 | void PutIsDir(bool value); |
[email protected] | f0f11f8 | 2013-09-17 04:21:38 | [diff] [blame] | 58 | void PutIsDel(bool value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 59 | void PutNonUniqueName(const std::string& value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 60 | void PutSpecifics(const sync_pb::EntitySpecifics& value); |
[email protected] | 65824a1 | 2013-09-13 20:26:31 | [diff] [blame] | 61 | void PutUniquePosition(const UniquePosition& value); |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 62 | |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 63 | // Sets the position of this item, and updates the entry kernels of the |
| 64 | // adjacent siblings so that list invariants are maintained. Returns false |
| 65 | // and fails if |predecessor_id| does not identify a sibling. Pass the root |
| 66 | // ID to put the node in first position. |
| 67 | bool PutPredecessor(const Id& predecessor_id); |
[email protected] | 74af9105 | 2013-09-26 09:42:36 | [diff] [blame] | 68 | |
[email protected] | 706d41d | 2014-05-02 19:00:11 | [diff] [blame] | 69 | void PutAttachmentMetadata( |
| 70 | const sync_pb::AttachmentMetadata& attachment_metadata); |
| 71 | |
[email protected] | 8ac09b21 | 2014-07-17 06:47:44 | [diff] [blame] | 72 | // Update attachment metadata for |attachment_id| to indicate that this |
| 73 | // attachment has been uploaded to the sync server. |
| 74 | void MarkAttachmentAsOnServer( |
| 75 | const sync_pb::AttachmentIdProto& attachment_id); |
[email protected] | 0ae5be3 | 2014-05-20 06:14:54 | [diff] [blame] | 76 | |
[email protected] | 74af9105 | 2013-09-26 09:42:36 | [diff] [blame] | 77 | private: |
| 78 | // Kind of redundant. We should reduce the number of pointers |
| 79 | // floating around if at all possible. Could we store this in Directory? |
| 80 | // Scope: Set on construction, never changed after that. |
| 81 | WriteTransaction* const write_transaction_; |
| 82 | |
| 83 | DISALLOW_COPY_AND_ASSIGN(MutableEntry); |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | // This function sets only the flags needed to get this entry to sync. |
| 87 | bool MarkForSyncing(syncable::MutableEntry* e); |
| 88 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 89 | } // namespace syncable |
[email protected] | 9cfc7c70 | 2012-07-02 22:54:17 | [diff] [blame] | 90 | } // namespace syncer |
[email protected] | 1573267 | 2012-06-20 18:58:26 | [diff] [blame] | 91 | |
| 92 | #endif // SYNC_SYNCABLE_MUTABLE_ENTRY_H_ |