Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsISupports.idl"
6
7
interface mozIPlacesPendingOperation;
8
interface mozIStorageConnection;
9
interface nsIPropertyBag;
10
11
// A progress listener used to record telemetry.
12
[scriptable, uuid(6239ffe3-6ffd-49ac-8b1d-958407395bf9)]
13
interface mozISyncedBookmarksMirrorProgressListener : nsISupports {
14
// Called after the merger fetches the local tree from Places, with the time
15
// taken to build the tree, number of items in the tree, and a map of
16
// structure problem counts for validation telemetry.
17
void onFetchLocalTree(in long long took, in long long itemCount,
18
in long long deletedCount, in nsIPropertyBag problems);
19
20
// Called after the merger builds the remote tree from the mirror database.
21
void onFetchRemoteTree(in long long took, in long long itemCount,
22
in long long deletedCount, in nsIPropertyBag problems);
23
24
// Called after the merger builds the merged tree, including structure change
25
// counts for event telemetry.
26
void onMerge(in long long took, in nsIPropertyBag counts);
27
28
// Called after the merger finishes applying the merged tree to Places and
29
// staging outgoing items.
30
void onApply(in long long took);
31
};
32
33
// A callback called when the merge finishes.
34
[scriptable, uuid(d23fdfea-92c8-409d-a516-08ae395d578f)]
35
interface mozISyncedBookmarksMirrorCallback : nsISupports {
36
void handleSuccess(in bool result);
37
void handleError(in nsresult code, in AString message);
38
};
39
40
[scriptable, uuid(37485984-a6ab-46e3-9b0c-e8b613413ef3)]
41
interface mozISyncedBookmarksMirrorLogger : nsISupports {
42
const short LEVEL_OFF = 0;
43
const short LEVEL_ERROR = 1;
44
const short LEVEL_WARN = 2;
45
const short LEVEL_DEBUG = 3;
46
const short LEVEL_TRACE = 4;
47
48
attribute short maxLevel;
49
50
void error(in AString message);
51
void warn(in AString message);
52
void debug(in AString message);
53
void trace(in AString message);
54
};
55
56
[scriptable, builtinclass, uuid(f0a6217d-8344-4e68-9995-bbf5554be86e)]
57
interface mozISyncedBookmarksMerger : nsISupports {
58
// Synced item kinds. These are stored in the mirror database.
59
const short KIND_BOOKMARK = 1;
60
const short KIND_QUERY = 2;
61
const short KIND_FOLDER = 3;
62
const short KIND_LIVEMARK = 4;
63
const short KIND_SEPARATOR = 5;
64
65
// Synced item validity states. These are also stored in the mirror
66
// database. `REUPLOAD` means a remote item can be fixed up and applied,
67
// and should be reuploaded. `REPLACE` means a remote item isn't valid
68
// at all, and should either be replaced with a valid local copy, or deleted
69
// if a valid local copy doesn't exist.
70
const short VALIDITY_VALID = 1;
71
const short VALIDITY_REUPLOAD = 2;
72
const short VALIDITY_REPLACE = 3;
73
74
// The mirror database connection to use for merging. The merge runs on the
75
// connection's async thread, to avoid blocking the main thread. The
76
// connection must be open, and the database schema, temp tables, and
77
// triggers must be set up before calling `merge`.
78
attribute mozIStorageConnection db;
79
80
// Optional; used for logging.
81
attribute mozISyncedBookmarksMirrorLogger logger;
82
83
// Merges the local and remote bookmark trees, applies the merged tree to
84
// Places, and stages locally changed and reconciled items for upload. When
85
// the merge finishes, either `callback.handleSuccess` or
86
// `callback.handleError` are called. If `callback` also implements
87
// `mozISyncedBookmarksMergerProgressListener`, the merger reports progress
88
// after each step. Returns an object with a `cancel` method that can be used
89
// to interrupt the merge.
90
mozIPlacesPendingOperation merge(
91
in long long localTimeSeconds,
92
in long long remoteTimeSeconds,
93
in Array<AString> weakUploads,
94
in mozISyncedBookmarksMirrorCallback callback
95
);
96
97
// Resets the database connection and logger. This does _not_ automatically
98
// close the database connection.
99
void reset();
100
};