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