Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/devtools.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
Left Patch Set: Addressed Manish's feedback Created May 1, 2018, 10:49 a.m.
Right Patch Set: Addressed Manish's feedback Created May 9, 2018, 5:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/cssInjection.js ('k') | lib/hitLogger.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 browser.runtime.onConnect.addListener(newPort => 234 browser.runtime.onConnect.addListener(newPort =>
235 { 235 {
236 let match = newPort.name.match(/^devtools-(\d+)$/); 236 let match = newPort.name.match(/^devtools-(\d+)$/);
237 if (!match) 237 if (!match)
238 return; 238 return;
239 239
240 let inspectedTabId = parseInt(match[1], 10); 240 let inspectedTabId = parseInt(match[1], 10);
241 let localOnBeforeRequest = onBeforeRequest.bind(); 241 let localOnBeforeRequest = onBeforeRequest.bind();
242 let panel = {port: newPort, records: []}; 242 let panel = {port: newPort, records: []};
243 let hitListener = addRecord.bind(null, panel);
243 244
244 browser.webRequest.onBeforeRequest.addListener( 245 browser.webRequest.onBeforeRequest.addListener(
245 localOnBeforeRequest, 246 localOnBeforeRequest,
246 { 247 {
247 urls: ["http://*/*", "https://*/*"], 248 urls: ["http://*/*", "https://*/*"],
248 types: ["main_frame"], 249 types: ["main_frame"],
249 tabId: inspectedTabId 250 tabId: inspectedTabId
250 } 251 }
251 ); 252 );
252 253
253 if (panels.size == 0) 254 if (panels.size == 0)
254 { 255 {
255 ext.pages.onLoading.addListener(onLoading); 256 ext.pages.onLoading.addListener(onLoading);
256 FilterNotifier.on("filter.added", onFilterAdded); 257 FilterNotifier.on("filter.added", onFilterAdded);
257 FilterNotifier.on("filter.removed", onFilterRemoved); 258 FilterNotifier.on("filter.removed", onFilterRemoved);
258 FilterNotifier.on("subscription.added", onSubscriptionAdded); 259 FilterNotifier.on("subscription.added", onSubscriptionAdded);
259 } 260 }
260 261
261 let hitListener = addRecord.bind(null, panel);
Sebastian Noack 2018/05/02 16:11:32 Nit: It seems weird to define this variable here,
kzar 2018/05/03 15:56:51 Done.
262
263 newPort.onDisconnect.addListener(() => 262 newPort.onDisconnect.addListener(() =>
264 { 263 {
265 HitLogger.removeListener(inspectedTabId, hitListener); 264 HitLogger.removeListener(inspectedTabId, hitListener);
266 panels.delete(inspectedTabId); 265 panels.delete(inspectedTabId);
267 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); 266 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest);
268 267
269 if (panels.size == 0) 268 if (panels.size == 0)
270 { 269 {
271 ext.pages.onLoading.removeListener(onLoading); 270 ext.pages.onLoading.removeListener(onLoading);
272 FilterNotifier.off("filter.added", onFilterAdded); 271 FilterNotifier.off("filter.added", onFilterAdded);
273 FilterNotifier.off("filter.removed", onFilterRemoved); 272 FilterNotifier.off("filter.removed", onFilterRemoved);
274 FilterNotifier.off("subscription.added", onSubscriptionAdded); 273 FilterNotifier.off("subscription.added", onSubscriptionAdded);
275 } 274 }
276 }); 275 });
277 276
278 HitLogger.addListener(inspectedTabId, hitListener); 277 HitLogger.addListener(inspectedTabId, hitListener);
279 panels.set(inspectedTabId, panel); 278 panels.set(inspectedTabId, panel);
280 }); 279 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld