Update V8 to version 4.7.21.
[chromium-blink-merge.git] / sync / syncable / mutable_entry.h
blobf26842e19cb237bcf421d289c578dd808826eb79
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"
14 namespace syncer {
15 class WriteNode;
17 namespace syncable {
19 enum Create {
20 CREATE
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);
31 public:
32 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id);
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);
42 MutableEntry(WriteTransaction* trans, GetByHandle, int64);
43 MutableEntry(WriteTransaction* trans, GetById, const Id&);
44 MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag);
45 MutableEntry(WriteTransaction* trans, GetTypeRoot, ModelType type);
47 inline WriteTransaction* write_transaction() const {
48 return write_transaction_;
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.
53 void PutLocalExternalId(int64 value);
54 void PutMtime(base::Time value);
55 void PutCtime(base::Time value);
56 void PutParentId(const Id& value);
57 void PutIsDir(bool value);
58 void PutIsDel(bool value);
59 void PutNonUniqueName(const std::string& value);
60 void PutSpecifics(const sync_pb::EntitySpecifics& value);
61 void PutUniquePosition(const UniquePosition& value);
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);
69 void PutAttachmentMetadata(const sync_pb::AttachmentMetadata& value);
71 // Update attachment metadata for |attachment_id| to indicate that this
72 // attachment has been uploaded to the sync server.
73 void MarkAttachmentAsOnServer(
74 const sync_pb::AttachmentIdProto& attachment_id);
76 private:
77 // Kind of redundant. We should reduce the number of pointers
78 // floating around if at all possible. Could we store this in Directory?
79 // Scope: Set on construction, never changed after that.
80 WriteTransaction* const write_transaction_;
82 DISALLOW_COPY_AND_ASSIGN(MutableEntry);
85 // This function sets only the flags needed to get this entry to sync.
86 bool MarkForSyncing(syncable::MutableEntry* e);
88 } // namespace syncable
89 } // namespace syncer
91 #endif // SYNC_SYNCABLE_MUTABLE_ENTRY_H_