1Overview of chrome://sync-internals
2-----------------------------------
3
4This note explains how chrome://sync-internals (also known as
5about:sync) interacts with the sync service/backend.
6
7Basically, chrome://sync-internals sends messages to the sync backend
8and the sync backend sends the reply asynchronously.  The sync backend
9also asynchronously raises events which chrome://sync-internals listen
10to.
11
12A message and its reply has a name and a list of arguments, which is
13basically a wrapper around an immutable ListValue.
14
15An event has a name and a details object, which is represented by a
16JsEventDetails (js_event_details.h) object, which is basically a
17wrapper around an immutable DictionaryValue.
18
19Message/event flow
20------------------
21
22chrome://sync-internals is represented by SyncInternalsUI
23(chrome/browser/ui/webui/sync_internals_ui.h).  SyncInternalsUI
24interacts with the sync service via a JsController (js_controller.h)
25object, which has a ProcessJsMessage() method that just delegates to
26an underlying JsBackend instance (js_backend.h).  The SyncInternalsUI
27object also registers itself (as a JsEventHandler
28[js_event_handler.h]) to the JsController object, and any events
29raised by the JsBackend are propagated to the JsController and then to
30the registered JsEventHandlers.
31
32The ProcessJsMessage() takes a WeakHandle (weak_handle.h) to a
33JsReplyHandler (js_reply_handler.h), which the backend uses to send
34replies safely across threads.  SyncInternalsUI implements
35JsReplyHandler, so it simply passes itself as the reply handler when
36it calls ProcessJsMessage() on the JsController.
37
38The following objects live on the UI thread:
39
40- SyncInternalsUI (implements JsEventHandler, JsReplyHandler)
41- SyncJsController (implements JsController, JsEventHandler)
42
43The following objects live on the sync thread:
44
45- SyncManager::SyncInternal (implements JsBackend)
46
47Of course, none of these objects need to know where the other objects
48live, since they interact via WeakHandles.
49