| 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 // This file defines the "sync API", an interface to the syncer | 5 // This file defines the "sync API", an interface to the syncer |
| 6 // backend that exposes (1) the core functionality of maintaining a consistent | 6 // backend that exposes (1) the core functionality of maintaining a consistent |
| 7 // local snapshot of a hierarchical object set; (2) a means to transactionally | 7 // local snapshot of a hierarchical object set; (2) a means to transactionally |
| 8 // access and modify those objects; (3) a means to control client/server | 8 // access and modify those objects; (3) a means to control client/server |
| 9 // synchronization tasks, namely: pushing local object modifications to a | 9 // synchronization tasks, namely: pushing local object modifications to a |
| 10 // server, pulling nonlocal object modifications from a server to this client, | 10 // server, pulling nonlocal object modifications from a server to this client, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 virtual int64 GetSuccessorId() const; | 268 virtual int64 GetSuccessorId() const; |
| 269 | 269 |
| 270 // Return the ID of the first child of this node. If this node has no | 270 // Return the ID of the first child of this node. If this node has no |
| 271 // children, return 0. | 271 // children, return 0. |
| 272 virtual int64 GetFirstChildId() const; | 272 virtual int64 GetFirstChildId() const; |
| 273 | 273 |
| 274 // These virtual accessors provide access to data members of derived classes. | 274 // These virtual accessors provide access to data members of derived classes. |
| 275 virtual const syncable::Entry* GetEntry() const = 0; | 275 virtual const syncable::Entry* GetEntry() const = 0; |
| 276 virtual const BaseTransaction* GetTransaction() const = 0; | 276 virtual const BaseTransaction* GetTransaction() const = 0; |
| 277 | 277 |
| 278 // Dumps all node info into a DictionaryValue and returns it. | 278 // Dumps a summary of node info into a DictionaryValue and returns it. |
| 279 // Transfers ownership of the DictionaryValue to the caller. | 279 // Transfers ownership of the DictionaryValue to the caller. |
| 280 DictionaryValue* ToValue() const; | 280 DictionaryValue* GetSummaryAsValue() const; |
| 281 |
| 282 // Dumps all node details into a DictionaryValue and returns it. |
| 283 // Transfers ownership of the DictionaryValue to the caller. |
| 284 DictionaryValue* GetDetailsAsValue() const; |
| 281 | 285 |
| 282 // Does a case in-sensitive search for a given string, which must be | 286 // Does a case in-sensitive search for a given string, which must be |
| 283 // lower case. | 287 // lower case. |
| 284 bool ContainsString(const std::string& lowercase_query) const; | 288 bool ContainsString(const std::string& lowercase_query) const; |
| 285 | 289 |
| 286 protected: | 290 protected: |
| 287 BaseNode(); | 291 BaseNode(); |
| 288 virtual ~BaseNode(); | 292 virtual ~BaseNode(); |
| 289 // The server has a size limit on client tags, so we generate a fixed length | 293 // The server has a size limit on client tags, so we generate a fixed length |
| 290 // hash locally. This also ensures that ModelTypes have unique namespaces. | 294 // hash locally. This also ensures that ModelTypes have unique namespaces. |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 968 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
| 965 // having received OnInitializationCompleted. | 969 // having received OnInitializationCompleted. |
| 966 void AddObserver(Observer* observer); | 970 void AddObserver(Observer* observer); |
| 967 | 971 |
| 968 // Remove the given observer. Make sure to call this if the | 972 // Remove the given observer. Make sure to call this if the |
| 969 // Observer is being destroyed so the SyncManager doesn't | 973 // Observer is being destroyed so the SyncManager doesn't |
| 970 // potentially dereference garbage. | 974 // potentially dereference garbage. |
| 971 void RemoveObserver(Observer* observer); | 975 void RemoveObserver(Observer* observer); |
| 972 | 976 |
| 973 // Returns a pointer to the JsBackend (which is owned by the sync | 977 // Returns a pointer to the JsBackend (which is owned by the sync |
| 974 // manager). Never returns NULL. The following events are sent by | 978 // manager). Never returns NULL. jsDocs for raised events are below: |
| 975 // the returned backend: | 979 |
| 980 /** |
| 981 * @param {{ enabled: boolean }} details enabled is set to whether |
| 982 * or not notifications are enabled. |
| 983 */ |
| 984 // function onNotificationStateChange(details); |
| 985 |
| 986 /** |
| 987 * @param {{ changedTypes: Array.<string> }} details changedTypes is |
| 988 * a list of types (as strings) for which there are new updates. |
| 989 */ |
| 990 // function onIncomingNotification(details); |
| 991 |
| 992 // jsDocs for handled messages are below (all other messages are |
| 993 // ignored). |
| 994 |
| 995 /** |
| 996 * Gets the current notification state. |
| 997 * |
| 998 * @param {function(boolean)} callback Called with whether or not |
| 999 * notifications are enabled. |
| 1000 */ |
| 1001 // function getNotificationState(callback); |
| 1002 |
| 1003 /** |
| 1004 * Gets details about the root node. |
| 1005 * |
| 1006 * @param {function(!Object)} callback Called with details about the |
| 1007 * root node. |
| 1008 */ |
| 1009 // TODO(akalin): Change this to getRootNodeId or eliminate it |
| 1010 // entirely. |
| 976 // | 1011 // |
| 977 // onNotificationStateChange({ enabled: (boolean) }): | 1012 // function getRootNodeDetails(callback); |
| 978 // Sent when notifications are enabled or disabled. | 1013 |
| 979 // | 1014 /** |
| 980 // onIncomingNotification({ changedTypes: (array) }): | 1015 * Gets summary information for a list of ids. |
| 981 // Sent when an incoming notification arrives. |changedTypes| | 1016 * |
| 982 // is a list of sync types (strings) which have changed. | 1017 * @param {Array.<string>} idList List of 64-bit ids in decimal |
| 983 // | 1018 * string form. |
| 984 // The following messages are processed by the returned backend: | 1019 * @param {Array.<{id: string, title: string, isFolder: boolean}>} |
| 985 // | 1020 * callback Called with summaries for the nodes in idList that |
| 986 // getNotificationState(): | 1021 * exist. |
| 987 // callback(boolean notificationsEnabled): | 1022 */ |
| 988 // notificationsEnabled: whether or not notifications are | 1023 // function getNodeSummariesById(idList, callback); |
| 989 // enabled. | 1024 |
| 990 // | 1025 /** |
| 991 // getRootNode(): | 1026 * Gets detailed information for a list of ids. |
| 992 // callback(dictionary nodeInfo): | 1027 * |
| 993 // nodeInfo: Information on the root node. | 1028 * @param {Array.<string>} idList List of 64-bit ids in decimal |
| 994 // | 1029 * string form. |
| 995 // getNodesById(array idList): | 1030 * @param {Array.<!Object>} callback Called with detailed |
| 996 // idList: A list of IDs as strings. | 1031 * information for the nodes in idList that exist. |
| 997 // callback(array nodeList): | 1032 */ |
| 998 // nodeList: Information on each node for each valid id in | 1033 // function getNodeDetailsById(idList, callback); |
| 999 // idList. Not guaranteed to be in any order. | 1034 |
| 1000 // | 1035 /** |
| 1001 // getChildNodeIds(string id): | 1036 * Gets child ids for a given id. |
| 1002 // id: The id of the node for which to return the child node ids. | 1037 * |
| 1003 // callback(array idList): | 1038 * @param {string} id 64-bit id in decimal string form of the parent |
| 1004 // idList: The child node IDs of the node with the given id. | 1039 * node. |
| 1005 // | 1040 * @param {Array.<string>} callback Called with the (possibly empty) |
| 1006 // All other messages are dropped. | 1041 * list of child ids. |
| 1042 */ |
| 1043 // function getChildNodeIds(id); |
| 1044 |
| 1007 browser_sync::JsBackend* GetJsBackend(); | 1045 browser_sync::JsBackend* GetJsBackend(); |
| 1008 | 1046 |
| 1009 // Status-related getters. Typically GetStatusSummary will suffice, but | 1047 // Status-related getters. Typically GetStatusSummary will suffice, but |
| 1010 // GetDetailedSyncStatus can be useful for gathering debug-level details of | 1048 // GetDetailedSyncStatus can be useful for gathering debug-level details of |
| 1011 // the internals of the sync engine. | 1049 // the internals of the sync engine. |
| 1012 Status::Summary GetStatusSummary() const; | 1050 Status::Summary GetStatusSummary() const; |
| 1013 Status GetDetailedStatus() const; | 1051 Status GetDetailedStatus() const; |
| 1014 | 1052 |
| 1015 // Whether or not the Nigori node is encrypted using an explicit passphrase. | 1053 // Whether or not the Nigori node is encrypted using an explicit passphrase. |
| 1016 bool IsUsingExplicitPassphrase(); | 1054 bool IsUsingExplicitPassphrase(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1046 private: | 1084 private: |
| 1047 // An opaque pointer to the nested private class. | 1085 // An opaque pointer to the nested private class. |
| 1048 SyncInternal* data_; | 1086 SyncInternal* data_; |
| 1049 | 1087 |
| 1050 DISALLOW_COPY_AND_ASSIGN(SyncManager); | 1088 DISALLOW_COPY_AND_ASSIGN(SyncManager); |
| 1051 }; | 1089 }; |
| 1052 | 1090 |
| 1053 } // namespace sync_api | 1091 } // namespace sync_api |
| 1054 | 1092 |
| 1055 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_ | 1093 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_ |
| OLD | NEW |