Skip to content

Commit 63b084e

Browse files
Support for wtm.page messages
1 parent fdcac44 commit 63b084e

File tree

1 file changed

+6
-14
lines changed
  • extension-manifest-v3/src/background/reporting

1 file changed

+6
-14
lines changed

extension-manifest-v3/src/background/reporting/index.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ const config = {
8989
COLLECTOR_DIRECT_URL,
9090
COLLECTOR_PROXY_URL,
9191
CONFIG_URL: 'https://api.ghostery.net/api/v1/config',
92+
SAFE_QUORUM_CONFIG_ENDPOINT:
93+
'https://safe-browsing-quorum.privacy.ghostery.net/config',
9294
...platformSpecificSettings(),
9395
},
9496
request: {
@@ -107,6 +109,7 @@ const communication = new AnonymousCommunication({
107109
const urlReporter = new UrlReporter({
108110
config: config.url,
109111
storage: new Storage('reporting'),
112+
connectDatabase: prefixedIndexedDBKeyValueStore('reporting'),
110113
communication,
111114
});
112115
let requestReporter = null;
@@ -176,10 +179,6 @@ const setup = asyncSetup([
176179
}),
177180
]);
178181

179-
function delay(timeInMs) {
180-
return new Promise((resolve) => setTimeout(resolve, timeInMs));
181-
}
182-
183182
async function onLocationChange(details) {
184183
try {
185184
setup.pending && (await setup.pending);
@@ -220,15 +219,7 @@ async function onLocationChange(details) {
220219
}
221220

222221
try {
223-
const jobRegistered = await urlReporter.analyzeUrl(url);
224-
if (jobRegistered) {
225-
// TODO: This part here is not robust:
226-
// we should avoid timers in MV3 or at least assume that we the service
227-
// worker will die (persisting the jobs and shift the scheduling
228-
// responsibility into the reporting module itself could help)
229-
await delay(2000 + 3000 * Math.random());
230-
await urlReporter.processPendingJobs();
231-
}
222+
await urlReporter.analyzeUrl(url);
232223
} catch (e) {
233224
console.warn('Unexpected error in reporting module:', e);
234225
}
@@ -253,12 +244,13 @@ chrome.runtime.onMessage.addListener((msg, sender) => {
253244
}
254245
});
255246

256-
// for debugging service-workers (TODO: provide a way to control logging)
247+
// for debugging service-workers
257248
globalThis.ghostery = globalThis.ghostery || {};
258249
globalThis.ghostery.WTM = {
259250
communication,
260251
urlReporter,
261252
requestReporter,
262253
config,
263254
webRequestPipeline,
255+
extensionStartedAt: new Date(),
264256
};

0 commit comments

Comments
 (0)