blob: 6f010e6e8787c6740828c2a1de8c890ccf45aa43 [file] [log] [blame]
[email protected]cc7a544c2013-01-02 08:31:511// Copyright 2012 The Chromium Authors. All rights reserved.
[email protected]15732672012-06-20 18:58:262// 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]15732672012-06-20 18:58:267
[email protected]cc7a544c2013-01-02 08:31:518#include "sync/base/sync_export.h"
[email protected]47b0ab72013-01-12 19:25:259#include "sync/internal_api/public/base/model_type.h"
[email protected]15732672012-06-20 18:58:2610#include "sync/syncable/entry.h"
11#include "sync/syncable/metahandle_set.h"
[email protected]4f435f72013-09-24 19:44:1112#include "sync/syncable/model_neutral_mutable_entry.h"
[email protected]15732672012-06-20 18:58:2613
[email protected]65f173552012-06-28 22:43:5814namespace syncer {
[email protected]15732672012-06-20 18:58:2615class WriteNode;
[email protected]15732672012-06-20 18:58:2616
17namespace syncable {
18
[email protected]15732672012-06-20 18:58:2619enum Create {
20 CREATE
21};
22
[email protected]4f435f72013-09-24 19:44:1123class WriteTransaction;
24
[email protected]15732672012-06-20 18:58:2625// A mutable meta entry. Changes get committed to the database when the
26// WriteTransaction is destroyed.
[email protected]4f435f72013-09-24 19:44:1127class SYNC_EXPORT_PRIVATE MutableEntry : public ModelNeutralMutableEntry {
[email protected]47b0ab72013-01-12 19:25:2528 void Init(WriteTransaction* trans, ModelType model_type,
29 const Id& parent_id, const std::string& name);
[email protected]15732672012-06-20 18:58:2630
31 public:
[email protected]4f435f72013-09-24 19:44:1132 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id);
stanisc277354df2015-01-12 19:54:5233 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]15732672012-06-20 18:58:2642 MutableEntry(WriteTransaction* trans, GetByHandle, int64);
43 MutableEntry(WriteTransaction* trans, GetById, const Id&);
44 MutableEntry(WriteTransaction* trans, GetByClientTag, const std::string& tag);
[email protected]65e95b72014-06-03 20:45:2845 MutableEntry(WriteTransaction* trans, GetTypeRoot, ModelType type);
[email protected]15732672012-06-20 18:58:2646
[email protected]74af91052013-09-26 09:42:3647 inline WriteTransaction* write_transaction() const {
48 return write_transaction_;
49 }
50
[email protected]4f435f72013-09-24 19:44:1151 // 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]65824a12013-09-13 20:26:3153 void PutLocalExternalId(int64 value);
54 void PutMtime(base::Time value);
[email protected]65824a12013-09-13 20:26:3155 void PutCtime(base::Time value);
[email protected]65824a12013-09-13 20:26:3156 void PutParentId(const Id& value);
[email protected]65824a12013-09-13 20:26:3157 void PutIsDir(bool value);
[email protected]f0f11f82013-09-17 04:21:3858 void PutIsDel(bool value);
[email protected]65824a12013-09-13 20:26:3159 void PutNonUniqueName(const std::string& value);
[email protected]65824a12013-09-13 20:26:3160 void PutSpecifics(const sync_pb::EntitySpecifics& value);
[email protected]65824a12013-09-13 20:26:3161 void PutUniquePosition(const UniquePosition& value);
[email protected]15732672012-06-20 18:58:2662
[email protected]15732672012-06-20 18:58:2663 // 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]74af91052013-09-26 09:42:3668
[email protected]706d41d2014-05-02 19:00:1169 void PutAttachmentMetadata(
70 const sync_pb::AttachmentMetadata& attachment_metadata);
71
[email protected]8ac09b212014-07-17 06:47:4472 // 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]0ae5be32014-05-20 06:14:5476
[email protected]74af91052013-09-26 09:42:3677 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]15732672012-06-20 18:58:2684};
85
86// This function sets only the flags needed to get this entry to sync.
87bool MarkForSyncing(syncable::MutableEntry* e);
88
[email protected]65f173552012-06-28 22:43:5889} // namespace syncable
[email protected]9cfc7c702012-07-02 22:54:1790} // namespace syncer
[email protected]15732672012-06-20 18:58:2691
92#endif // SYNC_SYNCABLE_MUTABLE_ENTRY_H_