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

Delta Between Two Patch Sets: messageResponder.js

Issue 29715759: Issue 6440 - Use long-lived connections to listen to extension events (Closed)
Left Patch Set: Use less generic name for only listener argument we care about Created March 7, 2018, 2:01 p.m.
Right Patch Set: Added message passing mock for ports Created March 7, 2018, 7:10 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
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 if (!(name in listenedFilterChanges)) 129 if (!(name in listenedFilterChanges))
130 { 130 {
131 listenedFilterChanges[name] = null; 131 listenedFilterChanges[name] = null;
132 FilterNotifier.on(name, (item) => 132 FilterNotifier.on(name, (item) =>
133 { 133 {
134 sendMessage(type, action, item); 134 sendMessage(type, action, item);
135 }); 135 });
136 } 136 }
137 } 137 }
138 }
139
140 function getListenerFilters(page)
saroyanm 2018/03/07 17:49:45 Seems like function is not being used anymore.
Thomas Greiner 2018/03/07 19:19:39 Done.
141 {
142 let listenerFilters = changeListeners.get(page);
143 if (!listenerFilters)
144 {
145 listenerFilters = Object.create(null);
146 changeListeners.set(page, listenerFilters);
147 }
148 return listenerFilters;
149 } 138 }
150 139
151 function addSubscription(subscription, properties) 140 function addSubscription(subscription, properties)
152 { 141 {
153 subscription.disabled = false; 142 subscription.disabled = false;
154 if ("title" in properties) 143 if ("title" in properties)
155 subscription.title = properties.title; 144 subscription.title = properties.title;
156 if ("homepage" in properties) 145 if ("homepage" in properties)
157 subscription.homepage = properties.homepage; 146 subscription.homepage = properties.homepage;
158 147
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 let filters = new Map(); 457 let filters = new Map();
469 uiPorts.set(uiPort, filters); 458 uiPorts.set(uiPort, filters);
470 459
471 uiPort.onDisconnect.addListener(() => 460 uiPort.onDisconnect.addListener(() =>
472 { 461 {
473 uiPorts.delete(uiPort); 462 uiPorts.delete(uiPort);
474 }); 463 });
475 464
476 uiPort.onMessage.addListener((message) => 465 uiPort.onMessage.addListener((message) =>
477 { 466 {
478 let [type, action] = message.type.split(".", 2); 467 let [type, action] = message.type.split(".", 2);
479 468
480 // For now we're only using long-lived connections for handling 469 // For now we're only using long-lived connections for handling
481 // "*.listen" messages to tackle #6440 470 // "*.listen" messages to tackle #6440
482 if (action == "listen") 471 if (action == "listen")
483 { 472 {
484 listen(type, filters, message.filter); 473 listen(type, filters, message.filter);
485 } 474 }
486 }); 475 });
487 } 476 }
488 477
489 browser.runtime.onConnect.addListener(onConnect); 478 browser.runtime.onConnect.addListener(onConnect);
490 })(this); 479 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld