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

Delta Between Two Patch Sets: lib/crawler.js

Issue 29338153: Issue 3780 - wait for the loading of filters and only afterwards start to fetch pages (Closed)
Left Patch Set: don't use internal FilterStorage._loading Created March 15, 2016, 2:42 p.m.
Right Patch Set: remove onFiltersLoaded listener and fit 80 chars Created March 15, 2016, 2:57 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 | « no previous file | no next file » | 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 Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 /** 7 /**
8 * @module crawler 8 * @module crawler
9 */ 9 */
10 10
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 */ 209 */
210 function run(window, urls, timeout, maxtabs, targetURL, onDone) 210 function run(window, urls, timeout, maxtabs, targetURL, onDone)
211 { 211 {
212 new Promise((resolve, reject) => 212 new Promise((resolve, reject) =>
213 { 213 {
214 if (FilterStorage.subscriptions.length > 0) 214 if (FilterStorage.subscriptions.length > 0)
215 { 215 {
216 resolve(); 216 resolve();
217 return; 217 return;
218 } 218 }
219 FilterNotifier.addListener((action, item, newValue, oldValue) => 219 let onFiltersLoaded = (action, item, newValue, oldValue) =>
Wladimir Palant 2016/03/15 14:50:58 Just realized: you have to remove that listener af
sergei 2016/03/15 14:58:45 Acknowledged.
220 { 220 {
221 if (action == "load") 221 if (action == "load")
222 { 222 {
223 FilterNotifier.removeListener(onFiltersLoaded);
223 resolve(); 224 resolve();
224 } 225 }
225 }); 226 };
226 }).then(() => crawl_urls(window, urls, timeout, maxtabs, targetURL, onDone)).c atch(reportException); 227 FilterNotifier.addListener(onFiltersLoaded);
Wladimir Palant 2016/03/15 14:50:58 Sorry but now having catch() on the same line no l
sergei 2016/03/15 14:58:45 Done.
228 }).then(() => crawl_urls(window, urls, timeout, maxtabs, targetURL, onDone))
229 .catch(reportException);
227 } 230 }
228 exports.run = run; 231 exports.run = run;
229 232
230 /** 233 /**
231 * Spawns a {Task} task to crawl each url from `urls` argument and calls 234 * Spawns a {Task} task to crawl each url from `urls` argument and calls
232 * `onDone` when all tasks are finished. 235 * `onDone` when all tasks are finished.
233 * @param {Window} window 236 * @param {Window} window
234 * The browser window we're operating in 237 * The browser window we're operating in
235 * @param {String[]} urls 238 * @param {String[]} urls
236 * URLs to be crawled 239 * URLs to be crawled
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 356
354 function reportException(e) 357 function reportException(e)
355 { 358 {
356 let stack = ""; 359 let stack = "";
357 if (e && typeof e == "object" && "stack" in e) 360 if (e && typeof e == "object" && "stack" in e)
358 stack = e.stack + "\n"; 361 stack = e.stack + "\n";
359 362
360 Cu.reportError(e); 363 Cu.reportError(e);
361 dump(e + "\n" + stack + "\n"); 364 dump(e + "\n" + stack + "\n");
362 } 365 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld