| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // All subclasses of BaseNode must provide a way to initialize themselves by | 73 // All subclasses of BaseNode must provide a way to initialize themselves by |
| 74 // doing an ID lookup. Returns false on failure. An invalid or deleted | 74 // doing an ID lookup. Returns false on failure. An invalid or deleted |
| 75 // ID will result in failure. | 75 // ID will result in failure. |
| 76 virtual InitByLookupResult InitByIdLookup(int64 id) = 0; | 76 virtual InitByLookupResult InitByIdLookup(int64 id) = 0; |
| 77 | 77 |
| 78 // All subclasses of BaseNode must also provide a way to initialize themselves | 78 // All subclasses of BaseNode must also provide a way to initialize themselves |
| 79 // by doing a client tag lookup. Returns false on failure. A deleted node | 79 // by doing a client tag lookup. Returns false on failure. A deleted node |
| 80 // will return FALSE. | 80 // will return FALSE. |
| 81 virtual InitByLookupResult InitByClientTagLookup( | 81 virtual InitByLookupResult InitByClientTagLookup( |
| 82 syncable::ModelType model_type, | 82 syncer::ModelType model_type, |
| 83 const std::string& tag) = 0; | 83 const std::string& tag) = 0; |
| 84 | 84 |
| 85 // Each object is identified by a 64-bit id (internally, the syncable | 85 // Each object is identified by a 64-bit id (internally, the syncable |
| 86 // metahandle). These ids are strictly local handles. They will persist | 86 // metahandle). These ids are strictly local handles. They will persist |
| 87 // on this client, but the same object on a different client may have a | 87 // on this client, but the same object on a different client may have a |
| 88 // different ID value. | 88 // different ID value. |
| 89 virtual int64 GetId() const; | 89 virtual int64 GetId() const; |
| 90 | 90 |
| 91 // Returns the modification time of the object. | 91 // Returns the modification time of the object. |
| 92 const base::Time& GetModificationTime() const; | 92 const base::Time& GetModificationTime() const; |
| 93 | 93 |
| 94 // Nodes are hierarchically arranged into a single-rooted tree. | 94 // Nodes are hierarchically arranged into a single-rooted tree. |
| 95 // InitByRootLookup on ReadNode allows access to the root. GetParentId is | 95 // InitByRootLookup on ReadNode allows access to the root. GetParentId is |
| 96 // how you find a node's parent. | 96 // how you find a node's parent. |
| 97 int64 GetParentId() const; | 97 int64 GetParentId() const; |
| 98 | 98 |
| 99 // Nodes are either folders or not. This corresponds to the IS_DIR property | 99 // Nodes are either folders or not. This corresponds to the IS_DIR property |
| 100 // of syncable::Entry. | 100 // of syncable::Entry. |
| 101 bool GetIsFolder() const; | 101 bool GetIsFolder() const; |
| 102 | 102 |
| 103 // Returns the title of the object. | 103 // Returns the title of the object. |
| 104 // Uniqueness of the title is not enforced on siblings -- it is not an error | 104 // Uniqueness of the title is not enforced on siblings -- it is not an error |
| 105 // for two children to share a title. | 105 // for two children to share a title. |
| 106 std::string GetTitle() const; | 106 std::string GetTitle() const; |
| 107 | 107 |
| 108 // Returns the model type of this object. The model type is set at node | 108 // Returns the model type of this object. The model type is set at node |
| 109 // creation time and is expected never to change. | 109 // creation time and is expected never to change. |
| 110 syncable::ModelType GetModelType() const; | 110 syncer::ModelType GetModelType() const; |
| 111 | 111 |
| 112 // Getter specific to the BOOKMARK datatype. Returns protobuf | 112 // Getter specific to the BOOKMARK datatype. Returns protobuf |
| 113 // data. Can only be called if GetModelType() == BOOKMARK. | 113 // data. Can only be called if GetModelType() == BOOKMARK. |
| 114 const sync_pb::BookmarkSpecifics& GetBookmarkSpecifics() const; | 114 const sync_pb::BookmarkSpecifics& GetBookmarkSpecifics() const; |
| 115 | 115 |
| 116 // Legacy, bookmark-specific getter that wraps GetBookmarkSpecifics() above. | 116 // Legacy, bookmark-specific getter that wraps GetBookmarkSpecifics() above. |
| 117 // Returns the URL of a bookmark object. | 117 // Returns the URL of a bookmark object. |
| 118 // TODO(ncarter): Remove this datatype-specific accessor. | 118 // TODO(ncarter): Remove this datatype-specific accessor. |
| 119 GURL GetURL() const; | 119 GURL GetURL() const; |
| 120 | 120 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 // Dumps all node details into a DictionaryValue and returns it. | 197 // Dumps all node details into a DictionaryValue and returns it. |
| 198 // Transfers ownership of the DictionaryValue to the caller. | 198 // Transfers ownership of the DictionaryValue to the caller. |
| 199 base::DictionaryValue* GetDetailsAsValue() const; | 199 base::DictionaryValue* GetDetailsAsValue() const; |
| 200 | 200 |
| 201 protected: | 201 protected: |
| 202 BaseNode(); | 202 BaseNode(); |
| 203 virtual ~BaseNode(); | 203 virtual ~BaseNode(); |
| 204 // The server has a size limit on client tags, so we generate a fixed length | 204 // The server has a size limit on client tags, so we generate a fixed length |
| 205 // hash locally. This also ensures that ModelTypes have unique namespaces. | 205 // hash locally. This also ensures that ModelTypes have unique namespaces. |
| 206 static std::string GenerateSyncableHash(syncable::ModelType model_type, | 206 static std::string GenerateSyncableHash(syncer::ModelType model_type, |
| 207 const std::string& client_tag); | 207 const std::string& client_tag); |
| 208 | 208 |
| 209 // Determines whether part of the entry is encrypted, and if so attempts to | 209 // Determines whether part of the entry is encrypted, and if so attempts to |
| 210 // decrypt it. Unless decryption is necessary and fails, this will always | 210 // decrypt it. Unless decryption is necessary and fails, this will always |
| 211 // return |true|. If the contents are encrypted, the decrypted data will be | 211 // return |true|. If the contents are encrypted, the decrypted data will be |
| 212 // stored in |unencrypted_data_|. | 212 // stored in |unencrypted_data_|. |
| 213 // This method is invoked once when the BaseNode is initialized. | 213 // This method is invoked once when the BaseNode is initialized. |
| 214 bool DecryptIfNecessary(); | 214 bool DecryptIfNecessary(); |
| 215 | 215 |
| 216 // Returns the unencrypted specifics associated with |entry|. If |entry| was | 216 // Returns the unencrypted specifics associated with |entry|. If |entry| was |
| (...skipping 29 matching lines...) Expand all Loading... |
| 246 | 246 |
| 247 // Same as |unencrypted_data_|, but for legacy password encryption. | 247 // Same as |unencrypted_data_|, but for legacy password encryption. |
| 248 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_; | 248 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_; |
| 249 | 249 |
| 250 DISALLOW_COPY_AND_ASSIGN(BaseNode); | 250 DISALLOW_COPY_AND_ASSIGN(BaseNode); |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 } // namespace syncer | 253 } // namespace syncer |
| 254 | 254 |
| 255 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ | 255 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ |
| OLD | NEW |