Places/AsyncAPIsForSync

< Places
Revision as of 22:51, 9 November 2010 by Philikon (talk | contribs) (Created page with "=Overview= Tracking bug for Sync: {{bug|606353}} =Bookmarks= {{bug|519514}} IMHO the overall theme here would be to provide powerful asynchronous methods to replace Sync's ma...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

Tracking bug for Sync: bug 606353

Bookmarks

bug 519514

IMHO the overall theme here would be to provide powerful asynchronous methods to replace Sync's many synchronous calls. So instead of adding a bookmark and then adding a bunch of annotations to it, it would be great if Places had an API that would let us do it one go, do all the writes async and then call us back.

tl;dr: Ideally we'd have methods like getBookmarkInfoAsync(), insertBookmarkAsync() and updateBookmarkAsync() that would return/take in as much information as we keep about bookmarks (see https://wiki.mozilla.org/Labs/Weave/Developer/BrowserObjects#bookmark) and do their work async.

Read

For syncing out as well as conflict resolution, right now we call

  • getFolderIdForItem()
  • getBookmarkURI()
  • getKeywordForBookmark()
  • and get the various "bookmarkProperties/" annotations (description, loadInSidebar, staticTitle, etc.).

I imagine that this information could be retrieved with one query which could be wrapped into getBookmarkInfoAsync() or similar API call.


Write

We currently use the following nsINavBookmarksService methods to create items:

insertBookmark() createFolder() insertSeparator() as well as nsILivemarkService::createLivemark()

When we make these or a subset of these async, how will be notified of the ID (and later, when we add GUIDs, their GUID)? Through an nsINavBookmarkObserver? Or will there be a callback we can pass into? We need the ID / GUID so that we can set various "bookmarkProperties/" annotations (description, loadInSidebar, staticTitle, etc.) as well as keywords via setKeywordForBookmark(). Ideally, of course, we could follow aforementioned theme and have the insert*Async() methods allow us to pass those in as well. Then we'd only need a callback for special cases such as microsummaries and tags.

To update already existing items, we call setItemTitle(), changeBookmarkURI(), setKeywordForBookmark() and update various annations. Perhaps there could be an updateBookmarkAsync() akin to insertBookmarkAsync() to save us these various separate method calls?


History

bug 606966

Same as with bookmarks, really, but much less complicated.

Read

We already roll our own async SQL queries to fetch the metadata for a history entry and its visits (two queries). We could push this down to Places, but given that we already do the right thing here, it probably has low priority.

Write

Right now call nsINavHistoryService::addVisit() for each visit in a history record that doesn't exist locally yet and then nsINavHistoryService::setPageTitle() to set the page title. As discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=606966#c14, an API that would allow us to pass in the page title and a list of visits would be great. It would asynchronously set the page title and add all the visits (unless they exist already)