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

Side by Side Diff: lib/sync.js

Issue 5636077285015552: Issue 656 - Replace some __proto__ with Object.create (Closed)
Patch Set: Created June 23, 2014, 8:46 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/subscriptionClasses.js ('k') | lib/timeline.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 update: function(record) 243 update: function(record)
244 { 244 {
245 if (record.id != filtersRecordID) 245 if (record.id != filtersRecordID)
246 return; 246 return;
247 247
248 this._log.trace("Merging in remote data"); 248 this._log.trace("Merging in remote data");
249 249
250 let data = record.cleartext.subscriptions; 250 let data = record.cleartext.subscriptions;
251 251
252 // First make sure we have the same subscriptions on both sides 252 // First make sure we have the same subscriptions on both sides
253 let seenSubscription = {__proto__: null}; 253 let seenSubscription = Object.create(null);
254 for (let remoteSubscription of data) 254 for (let remoteSubscription of data)
255 { 255 {
256 seenSubscription[remoteSubscription.url] = true; 256 seenSubscription[remoteSubscription.url] = true;
257 if (remoteSubscription.url in FilterStorage.knownSubscriptions) 257 if (remoteSubscription.url in FilterStorage.knownSubscriptions)
258 { 258 {
259 let subscription = FilterStorage.knownSubscriptions[remoteSubscription.u rl]; 259 let subscription = FilterStorage.knownSubscriptions[remoteSubscription.u rl];
260 if (!trackerInstance.didSubscriptionChange(remoteSubscription)) 260 if (!trackerInstance.didSubscriptionChange(remoteSubscription))
261 { 261 {
262 // Only change local subscription if there were no changes, otherwise dismiss remote changes 262 // Only change local subscription if there were no changes, otherwise dismiss remote changes
263 subscription.disabled = remoteSubscription.disabled; 263 subscription.disabled = remoteSubscription.disabled;
(...skipping 21 matching lines...) Expand all
285 for (let subscription of FilterStorage.subscriptions.slice()) 285 for (let subscription of FilterStorage.subscriptions.slice())
286 { 286 {
287 if (!(subscription.url in seenSubscription) && subscription instanceof Dow nloadableSubscription && !trackerInstance.didSubscriptionChange(subscription)) 287 if (!(subscription.url in seenSubscription) && subscription instanceof Dow nloadableSubscription && !trackerInstance.didSubscriptionChange(subscription))
288 { 288 {
289 // Subscription was removed remotely, remove it locally as well 289 // Subscription was removed remotely, remove it locally as well
290 FilterStorage.removeSubscription(subscription); 290 FilterStorage.removeSubscription(subscription);
291 } 291 }
292 } 292 }
293 293
294 // Now sync the custom filters 294 // Now sync the custom filters
295 let seenFilter = {__proto__: null}; 295 let seenFilter = Object.create(null);
296 for (let remoteSubscription of data) 296 for (let remoteSubscription of data)
297 { 297 {
298 if (!("filters" in remoteSubscription)) 298 if (!("filters" in remoteSubscription))
299 continue; 299 continue;
300 300
301 for (let remoteFilter of remoteSubscription.filters) 301 for (let remoteFilter of remoteSubscription.filters)
302 { 302 {
303 seenFilter[remoteFilter.text] = true; 303 seenFilter[remoteFilter.text] = true;
304 304
305 let filter = Filter.fromText(remoteFilter.text); 305 let filter = Filter.fromText(remoteFilter.text);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 case "filter.added": 450 case "filter.added":
451 case "filter.removed": 451 case "filter.removed":
452 case "filter.disabled": 452 case "filter.disabled":
453 this.addPrivateChange("filter " + item.text); 453 this.addPrivateChange("filter " + item.text);
454 break; 454 break;
455 } 455 }
456 } 456 }
457 }; 457 };
458 458
459 SyncServiceObserver.init(); 459 SyncServiceObserver.init();
OLDNEW
« no previous file with comments | « lib/subscriptionClasses.js ('k') | lib/timeline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld