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

Delta Between Two Patch Sets: safari/contentBlocking.js

Issue 29503587: Issue 5464 - Upgrade to new asynchronous version of abp2blocklist (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Don't wrap setContentBlocker call into another promise Created Aug. 16, 2017, 11:33 a.m.
Right Patch Set: Use function declaration syntax Created Aug. 21, 2017, 2:14 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/requestBlocker.js ('k') | 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 file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 for (let page of pages) 48 for (let page of pages)
49 page.browserAction.setBadge(); 49 page.browserAction.setBadge();
50 }); 50 });
51 } 51 }
52 52
53 function setContentBlocker() 53 function setContentBlocker()
54 { 54 {
55 return new Promise((resolve, reject) => 55 return new Promise((resolve, reject) =>
56 { 56 {
57 // Reset state and either fulfill or reject this promise. 57 // Reset state and either fulfill or reject this promise.
58 let completePromise = error => 58 function completePromise(error)
kzar 2017/08/21 12:30:12 Nit: Since this is a named function maybe just use
Manish Jethani 2017/08/21 14:17:04 Done.
59 { 59 {
60 lastSetContentBlockerError = error; 60 lastSetContentBlockerError = error;
61 contentBlockListDirty = false; 61 contentBlockListDirty = false;
62 62
63 if (error instanceof Error) 63 if (error instanceof Error)
64 reject(error); 64 reject(error);
65 else 65 else
66 resolve(); 66 resolve();
67 }; 67 }
68 68
69 // When given the same rules as last time setContentBlocker will always 69 // When given the same rules as last time setContentBlocker will always
70 // resolve with null (success), even when there was actually an 70 // resolve with null (success), even when there was actually an
71 // error. We cache the last result therefore so that we can provide a 71 // error. We cache the last result therefore so that we can provide a
72 // consistent result and also to avoid wastefully regenerating an identical 72 // consistent result and also to avoid wastefully regenerating an identical
73 // blocklist. 73 // blocklist.
74 if (!contentBlockListDirty) 74 if (!contentBlockListDirty)
75 { 75 {
76 completePromise(lastSetContentBlockerError); 76 completePromise(lastSetContentBlockerError);
77 return; 77 return;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 }); 203 });
204 }); 204 });
205 } 205 }
206 206
207 port.on("safari.contentBlockingActive", (msg, sender) => 207 port.on("safari.contentBlockingActive", (msg, sender) =>
208 { 208 {
209 if (!contentBlockingActive && afterContentBlockingFinished) 209 if (!contentBlockingActive && afterContentBlockingFinished)
210 return afterContentBlockingFinished; 210 return afterContentBlockingFinished;
211 return contentBlockingActive; 211 return contentBlockingActive;
212 }); 212 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld