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