Changes

Jump to: navigation, search

CloudServices/Sync/FxSync/Developer/ClientAPI

494 bytes removed, 22:45, 21 February 2011
Overview
== Overview ==
This page describes how to the client-side Sync API for sync engines (and their helper classesobjects). The focus is on using this API to create a new sync engine to synchronize a new data type. The data type can be anything that extension JS code has access to through any Mozilla API; this means this page must of necessity be pretty vague about reading and writing the underlying data. You'll have to fill in those blanks yourself. Try browsing the [link] xpcom documentation to find out how to get at the many types of useful data that Mozilla stores.
To sync a new data type, you'll need to write an engine class* object that extends the base SyncEngine classobject; you'll also need to extend three helper classesobjects. Here are the classes you need to extend, and the files in which they're defined:
# <tt>SyncEngine</tt>, in <tt>services/sync/modules/engines.js</tt># <tt>CryptoWrapperStore</tt>, in <tt>services/sync/modules/base_records/crypto.jsTracker</tt># <tt>Store</tt>, in <tt>services/sync/modules/storesengines.js</tt># <tt>TrackerCryptoWrapper</tt>, in <tt>services/sync/modules/trackersrecord.js</tt>
It will be very helpful to look at the existing sync engines -- such as the one for bookmarks and the one for history -- and their helper classes, for guidance. You can find these files at:
* <tt>services/sync/modules/engines/bookmarks.js</tt> -- the Record implementations for the various subtypes of bookmarks and the <tt>BookmarkEngine</tt>, <tt>BookmarkStore</tt>, and <tt>BookmarkTracker</tt>.* <tt>services/sync/modules/type_recordsengines/bookmarkhistory.js</tt> -- the Record classes for the various subtypes of bookmarks* <tt>services/sync/modules/engines/history.jsHistoryRec</tt> -- the ,<tt>HistoryEngine</tt>, <tt>HistoryStore</tt>, and <tt>HistoryTracker</tt>.* <tt>services/sync/modules/type_records/history.js</tt> -- the <tt>HistoryRec</tt> record class.
After implementing your classesobjects, you'll have to register them with the Sync service. * - Javascript is prototype-based, not class-based, so technically it's not correct to talk about "subclassing" or "extending a class", but what we're doing is very much the equivalent of that, and I don't know any other terminology to explain it as clearly.
== Writing a Record class ==
Canmove, confirm
725
edits

Navigation menu