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.
5 #ifndef SYNC_SYNCABLE_MUTABLE_ENTRY_H_
6 #define SYNC_SYNCABLE_MUTABLE_ENTRY_H_
8 #include "sync/base/sync_export.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/syncable/entry.h"
11 #include "sync/syncable/metahandle_set.h"
12 #include "sync/syncable/model_neutral_mutable_entry.h"
23 class WriteTransaction
;
25 // A mutable meta entry. Changes get committed to the database when the
26 // WriteTransaction is destroyed.
27 class SYNC_EXPORT_PRIVATE MutableEntry
: public ModelNeutralMutableEntry
{
28 void Init(WriteTransaction
* trans
, ModelType model_type
,
29 const Id
& parent_id
, const std::string
& name
);
32 MutableEntry(WriteTransaction
* trans
, CreateNewUpdateItem
, const Id
& id
);
33 MutableEntry(WriteTransaction
* trans
, Create
, ModelType model_type
,
34 const Id
& parent_id
, const std::string
& name
);
35 MutableEntry(WriteTransaction
* trans
, GetByHandle
, int64
);
36 MutableEntry(WriteTransaction
* trans
, GetById
, const Id
&);
37 MutableEntry(WriteTransaction
* trans
, GetByClientTag
, const std::string
& tag
);
38 MutableEntry(WriteTransaction
* trans
, GetTypeRoot
, ModelType type
);
40 inline WriteTransaction
* write_transaction() const {
41 return write_transaction_
;
44 // Model-changing setters. These setters make user-visible changes that will
45 // need to be communicated either to the local model or the sync server.
46 void PutLocalExternalId(int64 value
);
47 void PutMtime(base::Time value
);
48 void PutCtime(base::Time value
);
49 void PutParentId(const Id
& value
);
50 void PutIsDir(bool value
);
51 void PutIsDel(bool value
);
52 void PutNonUniqueName(const std::string
& value
);
53 void PutSpecifics(const sync_pb::EntitySpecifics
& value
);
54 void PutUniquePosition(const UniquePosition
& value
);
56 // Sets the position of this item, and updates the entry kernels of the
57 // adjacent siblings so that list invariants are maintained. Returns false
58 // and fails if |predecessor_id| does not identify a sibling. Pass the root
59 // ID to put the node in first position.
60 bool PutPredecessor(const Id
& predecessor_id
);
62 void PutAttachmentMetadata(
63 const sync_pb::AttachmentMetadata
& attachment_metadata
);
65 // Update attachment metadata, replace all records matching attachment id's
66 // unique id with updated attachment id that contains server info.
67 // Set is_in_server for corresponding records.
68 void UpdateAttachmentIdWithServerInfo(
69 const sync_pb::AttachmentIdProto
& updated_attachment_id
);
72 // Kind of redundant. We should reduce the number of pointers
73 // floating around if at all possible. Could we store this in Directory?
74 // Scope: Set on construction, never changed after that.
75 WriteTransaction
* const write_transaction_
;
77 DISALLOW_COPY_AND_ASSIGN(MutableEntry
);
80 // This function sets only the flags needed to get this entry to sync.
81 bool MarkForSyncing(syncable::MutableEntry
* e
);
83 } // namespace syncable
86 #endif // SYNC_SYNCABLE_MUTABLE_ENTRY_H_