| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 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 CHROME_BROWSER_SYNC_INTERNAL_API_READ_NODE_H_ | |
| 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_READ_NODE_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "chrome/browser/sync/internal_api/base_node.h" | |
| 14 #include "sync/syncable/model_type.h" | |
| 15 | |
| 16 namespace sync_api { | |
| 17 | |
| 18 // ReadNode wraps a syncable::Entry to provide the functionality of a | |
| 19 // read-only BaseNode. | |
| 20 class ReadNode : public BaseNode { | |
| 21 public: | |
| 22 // Create an unpopulated ReadNode on the given transaction. Call some flavor | |
| 23 // of Init to populate the ReadNode with a database entry. | |
| 24 explicit ReadNode(const BaseTransaction* transaction); | |
| 25 virtual ~ReadNode(); | |
| 26 | |
| 27 // A client must use one (and only one) of the following Init variants to | |
| 28 // populate the node. | |
| 29 | |
| 30 // BaseNode implementation. | |
| 31 virtual bool InitByIdLookup(int64 id) OVERRIDE; | |
| 32 virtual bool InitByClientTagLookup(syncable::ModelType model_type, | |
| 33 const std::string& tag) OVERRIDE; | |
| 34 | |
| 35 // There is always a root node, so this can't fail. The root node is | |
| 36 // never mutable, so root lookup is only possible on a ReadNode. | |
| 37 void InitByRootLookup(); | |
| 38 | |
| 39 // Each server-created permanent node is tagged with a unique string. | |
| 40 // Look up the node with the particular tag. If it does not exist, | |
| 41 // return false. | |
| 42 bool InitByTagLookup(const std::string& tag); | |
| 43 | |
| 44 // Implementation of BaseNode's abstract virtual accessors. | |
| 45 virtual const syncable::Entry* GetEntry() const OVERRIDE; | |
| 46 virtual const BaseTransaction* GetTransaction() const OVERRIDE; | |
| 47 | |
| 48 protected: | |
| 49 ReadNode(); | |
| 50 | |
| 51 private: | |
| 52 void* operator new(size_t size); // Node is meant for stack use only. | |
| 53 | |
| 54 // The underlying syncable object which this class wraps. | |
| 55 syncable::Entry* entry_; | |
| 56 | |
| 57 // The sync API transaction that is the parent of this node. | |
| 58 const BaseTransaction* transaction_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(ReadNode); | |
| 61 }; | |
| 62 | |
| 63 } // namespace sync_api | |
| 64 | |
| 65 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_READ_NODE_H_ | |
| OLD | NEW |