| 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 SYNC_INTERNAL_API_PUBLIC_READ_NODE_H_ | |
| 6 #define SYNC_INTERNAL_API_PUBLIC_READ_NODE_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 "sync/base/sync_export.h" | |
| 16 #include "sync/internal_api/public/base/model_type.h" | |
| 17 #include "sync/internal_api/public/base_node.h" | |
| 18 | |
| 19 namespace syncer { | |
| 20 | |
| 21 // ReadNode wraps a syncable::Entry to provide the functionality of a | |
| 22 // read-only BaseNode. | |
| 23 class SYNC_EXPORT ReadNode : public BaseNode { | |
| 24 public: | |
| 25 // Create an unpopulated ReadNode on the given transaction. Call some flavor | |
| 26 // of Init to populate the ReadNode with a database entry. | |
| 27 explicit ReadNode(const BaseTransaction* transaction); | |
| 28 ~ReadNode() override; | |
| 29 | |
| 30 // A client must use one (and only one) of the following Init variants to | |
| 31 // populate the node. | |
| 32 | |
| 33 // BaseNode implementation. | |
| 34 InitByLookupResult InitByIdLookup(int64_t id) override; | |
| 35 InitByLookupResult InitByClientTagLookup(ModelType model_type, | |
| 36 const std::string& tag) override; | |
| 37 | |
| 38 // There is always a root node, so this can't fail. The root node is | |
| 39 // never mutable, so root lookup is only possible on a ReadNode. | |
| 40 void InitByRootLookup(); | |
| 41 | |
| 42 // Returns the type root node, if it exists. This is usually created by the | |
| 43 // server during first sync. Eventually, we plan to remove support for it | |
| 44 // from the protocol and have the client create the node instead. | |
| 45 InitByLookupResult InitTypeRoot(ModelType type); | |
| 46 | |
| 47 // Returns a server-created and unique-server-tagged item. | |
| 48 // | |
| 49 // This functionality is only useful for bookmarks because only bookmarks | |
| 50 // have server-tagged items. All other server-tagged items are type root | |
| 51 // nodes, which should be looked up with InitTypeRoot(). | |
| 52 InitByLookupResult InitByTagLookupForBookmarks(const std::string& tag); | |
| 53 | |
| 54 // Returns transaction version of the last transaction where this node has | |
| 55 // been modified. | |
| 56 int64_t GetTransactionVersion() const; | |
| 57 | |
| 58 // Implementation of BaseNode's abstract virtual accessors. | |
| 59 const syncable::Entry* GetEntry() const override; | |
| 60 const BaseTransaction* GetTransaction() const override; | |
| 61 | |
| 62 protected: | |
| 63 ReadNode(); | |
| 64 | |
| 65 private: | |
| 66 void* operator new(size_t size); // Node is meant for stack use only. | |
| 67 | |
| 68 // The underlying syncable object which this class wraps. | |
| 69 syncable::Entry* entry_; | |
| 70 | |
| 71 // The sync API transaction that is the parent of this node. | |
| 72 const BaseTransaction* transaction_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(ReadNode); | |
| 75 }; | |
| 76 | |
| 77 } // namespace syncer | |
| 78 | |
| 79 #endif // SYNC_INTERNAL_API_PUBLIC_READ_NODE_H_ | |
| OLD | NEW |