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 CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ |
6 #define CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ | 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // A valid BaseNode will never have an ID of zero. | 49 // A valid BaseNode will never have an ID of zero. |
50 static const int64 kInvalidId = 0; | 50 static const int64 kInvalidId = 0; |
51 | 51 |
52 // BaseNode wraps syncable::Entry, and corresponds to a single object's state. | 52 // BaseNode wraps syncable::Entry, and corresponds to a single object's state. |
53 // This, like syncable::Entry, is intended for use on the stack. A valid | 53 // This, like syncable::Entry, is intended for use on the stack. A valid |
54 // transaction is necessary to create a BaseNode or any of its children. | 54 // transaction is necessary to create a BaseNode or any of its children. |
55 // Unlike syncable::Entry, a sync API BaseNode is identified primarily by its | 55 // Unlike syncable::Entry, a sync API BaseNode is identified primarily by its |
56 // int64 metahandle, which we call an ID here. | 56 // int64 metahandle, which we call an ID here. |
57 class BaseNode { | 57 class BaseNode { |
58 public: | 58 public: |
| 59 // Enumerates the possible outcomes of trying to initialize a sync node. |
| 60 enum InitByLookupResult { |
| 61 INIT_OK, |
| 62 // Could not find an entry matching the lookup criteria. |
| 63 INIT_FAILED_ENTRY_NOT_GOOD, |
| 64 // Found an entry, but it is already deleted. |
| 65 INIT_FAILED_ENTRY_IS_DEL, |
| 66 // Found an entry, but was unable to decrypt. |
| 67 INIT_FAILED_DECRYPT_IF_NECESSARY, |
| 68 // A precondition was not met for calling init, such as legal input |
| 69 // arguments. |
| 70 INIT_FAILED_PRECONDITION, |
| 71 }; |
| 72 |
59 // 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 |
60 // 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 |
61 // ID will result in failure. | 75 // ID will result in failure. |
62 virtual bool InitByIdLookup(int64 id) = 0; | 76 virtual InitByLookupResult InitByIdLookup(int64 id) = 0; |
63 | 77 |
64 // 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 |
65 // 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 |
66 // will return FALSE. | 80 // will return FALSE. |
67 virtual bool InitByClientTagLookup(syncable::ModelType model_type, | 81 virtual InitByLookupResult InitByClientTagLookup( |
| 82 syncable::ModelType model_type, |
68 const std::string& tag) = 0; | 83 const std::string& tag) = 0; |
69 | 84 |
70 // 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 |
71 // metahandle). These ids are strictly local handles. They will persist | 86 // metahandle). These ids are strictly local handles. They will persist |
72 // 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 |
73 // different ID value. | 88 // different ID value. |
74 virtual int64 GetId() const; | 89 virtual int64 GetId() const; |
75 | 90 |
76 // Returns the modification time of the object. | 91 // Returns the modification time of the object. |
77 const base::Time& GetModificationTime() const; | 92 const base::Time& GetModificationTime() const; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 246 |
232 // Same as |unencrypted_data_|, but for legacy password encryption. | 247 // Same as |unencrypted_data_|, but for legacy password encryption. |
233 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_; | 248 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_; |
234 | 249 |
235 DISALLOW_COPY_AND_ASSIGN(BaseNode); | 250 DISALLOW_COPY_AND_ASSIGN(BaseNode); |
236 }; | 251 }; |
237 | 252 |
238 } // namespace sync_api | 253 } // namespace sync_api |
239 | 254 |
240 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ | 255 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_BASE_NODE_H_ |
OLD | NEW |