OLD | NEW |
1 # Chrome Sync's Model API | 1 # Chrome Sync's Model API |
2 | 2 |
3 Chrome Sync operates on discrete, explicitly defined model types (bookmarks, | 3 Chrome Sync operates on discrete, explicitly defined model types (bookmarks, |
4 preferences, tabs, etc). These model types are individually responsible for | 4 preferences, tabs, etc). These model types are individually responsible for |
5 implementing their own local storage and responding to remote changes. This | 5 implementing their own local storage and responding to remote changes. This |
6 guide is for developers interested in syncing data for their model type to the | 6 guide is for developers interested in syncing data for their model type to the |
7 cloud using Chrome Sync. It describes the newest version of the API, known as | 7 cloud using Chrome Sync. It describes the newest version of the API, known as |
8 Unified Sync and Storage (USS). There is also the deprecated [SyncableService | 8 Unified Sync and Storage (USS). There is also the deprecated [SyncableService |
9 API] (aka Directory), which as of early 2016 is still used by most model types. | 9 API] (aka Directory), which as of early 2016 is still used by most model types. |
10 | 10 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 * Define your specifics proto in [`//components/sync/protocol/`][protocol]. | 255 * Define your specifics proto in [`//components/sync/protocol/`][protocol]. |
256 * Add a field for it to [`EntitySpecifics`][EntitySpecifics]. | 256 * Add a field for it to [`EntitySpecifics`][EntitySpecifics]. |
257 * Add it to the [`ModelType`][ModelType] enum and | 257 * Add it to the [`ModelType`][ModelType] enum and |
258 [`kModelTypeInfoMap`][info_map]. | 258 [`kModelTypeInfoMap`][info_map]. |
259 * Add it to the [proto value conversions][conversions] files. | 259 * Add it to the [proto value conversions][conversions] files. |
260 * Register a [`ModelTypeController`][ModelTypeController] for your type in | 260 * Register a [`ModelTypeController`][ModelTypeController] for your type in |
261 [`ProfileSyncComponentsFactoryImpl::RegisterDataTypes`][RegisterDataTypes]. | 261 [`ProfileSyncComponentsFactoryImpl::RegisterDataTypes`][RegisterDataTypes]. |
262 * Tell sync how to access your `ModelTypeSyncBridge` in | 262 * Tell sync how to access your `ModelTypeSyncBridge` in |
263 [`ChromeSyncClient::GetSyncBridgeForModelType`][GetSyncBridge]. | 263 [`ChromeSyncClient::GetSyncBridgeForModelType`][GetSyncBridge]. |
| 264 * Add your KeyedService dependency to |
| 265 [`ProfileSyncServiceFactory`][ProfileSyncServiceFactory]. |
264 * Add to the [start order list][kStartOrder]. | 266 * Add to the [start order list][kStartOrder]. |
265 * Add an field for encrypted data to [`NigoriSpecifics`][NigoriSpecifics]. | 267 * Add an field for encrypted data to [`NigoriSpecifics`][NigoriSpecifics]. |
266 * Add to two encrypted types translation functions in | 268 * Add to two encrypted types translation functions in |
267 [`nigori_util.cc`][nigori_util]. | 269 [`nigori_util.cc`][nigori_util]. |
268 * Add a [preference][pref_names] for tracking whether your type is enabled. | 270 * Add a [preference][pref_names] for tracking whether your type is enabled. |
269 * Map your type to the pref in [`GetPrefNameForDataType`][GetPrefName]. | 271 * Map your type to the pref in [`GetPrefNameForDataType`][GetPrefName]. |
270 * Check whether you should be part of a [pref group][RegisterPrefGroup]. | 272 * Check whether you should be part of a [pref group][RegisterPrefGroup]. |
271 * Add to the `SyncModelTypes` enum and `SyncModelType` suffix in | 273 * Add to the `SyncModelTypes` enum and `SyncModelType` suffix in |
272 [`histograms.xml`][histograms]. | 274 [`histograms.xml`][histograms]. |
273 * Add to the [`SYNC_DATA_TYPE_HISTOGRAM`][DataTypeHistogram] macro. | 275 * Add to the [`SYNC_DATA_TYPE_HISTOGRAM`][DataTypeHistogram] macro. |
274 | 276 |
275 [protocol]: https://cs.chromium.org/chromium/src/components/sync/protocol/ | 277 [protocol]: https://cs.chromium.org/chromium/src/components/sync/protocol/ |
276 [ModelType]: https://cs.chromium.org/chromium/src/components/sync/base/model_typ
e.h | 278 [ModelType]: https://cs.chromium.org/chromium/src/components/sync/base/model_typ
e.h |
277 [info_map]: https://cs.chromium.org/search/?q="kModelTypeInfoMap%5B%5D"+file:mod
el_type.cc | 279 [info_map]: https://cs.chromium.org/search/?q="kModelTypeInfoMap%5B%5D"+file:mod
el_type.cc |
278 [conversions]: https://cs.chromium.org/chromium/src/components/sync/protocol/pro
to_value_conversions.h | 280 [conversions]: https://cs.chromium.org/chromium/src/components/sync/protocol/pro
to_value_conversions.h |
279 [ModelTypeController]: https://cs.chromium.org/chromium/src/components/sync/driv
er/model_type_controller.h | 281 [ModelTypeController]: https://cs.chromium.org/chromium/src/components/sync/driv
er/model_type_controller.h |
280 [RegisterDataTypes]: https://cs.chromium.org/search/?q="ProfileSyncComponentsFac
toryImpl::RegisterDataTypes" | 282 [RegisterDataTypes]: https://cs.chromium.org/search/?q="ProfileSyncComponentsFac
toryImpl::RegisterDataTypes" |
281 [GetSyncBridge]: https://cs.chromium.org/search/?q=GetSyncBridgeForModelType+fil
e:chrome_sync_client.cc | 283 [GetSyncBridge]: https://cs.chromium.org/search/?q=GetSyncBridgeForModelType+fil
e:chrome_sync_client.cc |
| 284 [ProfileSyncServiceFactory]: https://cs.chromium.org/search/?q=:ProfileSyncServi
ceFactory%5C(%5C) |
282 [kStartOrder]: https://cs.chromium.org/search/?q="kStartOrder[]" | 285 [kStartOrder]: https://cs.chromium.org/search/?q="kStartOrder[]" |
283 [NigoriSpecifics]: https://cs.chromium.org/chromium/src/components/sync/protocol
/nigori_specifics.proto | 286 [NigoriSpecifics]: https://cs.chromium.org/chromium/src/components/sync/protocol
/nigori_specifics.proto |
284 [nigori_util]: https://cs.chromium.org/chromium/src/components/sync/syncable/nig
ori_util.cc | 287 [nigori_util]: https://cs.chromium.org/chromium/src/components/sync/syncable/nig
ori_util.cc |
285 [pref_names]: https://cs.chromium.org/chromium/src/components/sync/base/pref_nam
es.h | 288 [pref_names]: https://cs.chromium.org/chromium/src/components/sync/base/pref_nam
es.h |
286 [GetPrefName]: https://cs.chromium.org/search/?q=::GetPrefNameForDataType+file:s
ync_prefs.cc | 289 [GetPrefName]: https://cs.chromium.org/search/?q=::GetPrefNameForDataType+file:s
ync_prefs.cc |
287 [RegisterPrefGroup]: https://cs.chromium.org/search/?q=::RegisterPrefGroups+file
:sync_prefs.cc | 290 [RegisterPrefGroup]: https://cs.chromium.org/search/?q=::RegisterPrefGroups+file
:sync_prefs.cc |
288 [histograms]: https://cs.chromium.org/chromium/src/tools/metrics/histograms/hist
ograms.xml | 291 [histograms]: https://cs.chromium.org/chromium/src/tools/metrics/histograms/hist
ograms.xml |
289 [DataTypeHistogram]: https://cs.chromium.org/chromium/src/components/sync/base/d
ata_type_histogram.h | 292 [DataTypeHistogram]: https://cs.chromium.org/chromium/src/components/sync/base/d
ata_type_histogram.h |
290 | 293 |
291 ## Testing | 294 ## Testing |
292 | 295 |
293 The [`TwoClientUssSyncTest`][UssTest] suite is probably a good place to start | 296 The [`TwoClientUssSyncTest`][UssTest] suite is probably a good place to start |
294 for integration testing. Especially note the use of a `StatusChangeChecker` to | 297 for integration testing. Especially note the use of a `StatusChangeChecker` to |
295 wait for events to happen. | 298 wait for events to happen. |
296 | 299 |
297 [UssTest]: https://cs.chromium.org/chromium/src/chrome/browser/sync/test/integra
tion/two_client_uss_sync_test.cc | 300 [UssTest]: https://cs.chromium.org/chromium/src/chrome/browser/sync/test/integra
tion/two_client_uss_sync_test.cc |
OLD | NEW |