Files
tubestation/toolkit/components/places/SyncedBookmarksMirror.h
Lina Cambridge aca17f0545 Bug 1482608 - Port the synced bookmarks merger to Rust. r=nika,mak,markh,tcsc
This commit introduces a Rust XPCOM component,
`mozISyncedBookmarksMerger`, that wraps the Dogear crate for
merging and applying synced bookmarks.

How this works: `SyncedBookmarksMirror.jsm` manages opening
the connection, initializing the schema, and writing incoming
items into the mirror database. The new `mozISyncedBookmarksMerger`
holds a handle to the same connection. When JS code calls
`mozISyncedBookmarksMerger::apply`, the merger builds local and
remote trees, produces a merged tree, applies the tree back to Places,
and stages outgoing items for upload in a temp table, all on the
storage thread. It then calls back in to JS, which inflates Sync
records for outgoing items, notifies Places observers, and cleans up.

Since Dogear has a more robust merging algorithm that attempts to fix
up invalid trees, `test_bookmark_corruption.js` intentionally fails.
This is fixed in the next commit, which changes the merger to handle
invalid structure.

Differential Revision: https://phabricator.services.mozilla.com/D20076
2019-03-25 04:50:14 +00:00

31 lines
865 B
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_places_SyncedBookmarksMirror_h_
#define mozilla_places_SyncedBookmarksMirror_h_
#include "mozISyncedBookmarksMirror.h"
#include "nsCOMPtr.h"
extern "C" {
// Implemented in Rust, in the `bookmark_sync` crate.
void NS_NewSyncedBookmarksMerger(mozISyncedBookmarksMerger** aResult);
} // extern "C"
namespace mozilla {
namespace places {
already_AddRefed<mozISyncedBookmarksMerger> NewSyncedBookmarksMerger() {
nsCOMPtr<mozISyncedBookmarksMerger> merger;
NS_NewSyncedBookmarksMerger(getter_AddRefs(merger));
return merger.forget();
}
} // namespace places
} // namespace mozilla
#endif // mozilla_places_SyncedBookmarksMirror_h_