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

Side by Side Diff: lib/synchronizer.js

Issue 9251039: Get rid of nested functions declarations that are not on top level (causes strict mode warnings) (Closed)
Patch Set: Created Jan. 23, 2013, 12:52 p.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/requestNotifier.js ('k') | lib/typoAppIntegration.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 the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * @class 54 * @class
55 */ 55 */
56 let Synchronizer = exports.Synchronizer = 56 let Synchronizer = exports.Synchronizer =
57 { 57 {
58 /** 58 /**
59 * Called on module startup. 59 * Called on module startup.
60 */ 60 */
61 init: function() 61 init: function()
62 { 62 {
63 TimeLine.enter("Entered Synchronizer.init()"); 63 TimeLine.enter("Entered Synchronizer.init()");
64 64
65 let callback = function() 65 let callback = function()
66 { 66 {
67 timer.delay = CHECK_INTERVAL * MILLISECONDS_IN_SECOND; 67 timer.delay = CHECK_INTERVAL * MILLISECONDS_IN_SECOND;
68 checkSubscriptions(); 68 checkSubscriptions();
69 }; 69 };
70 70
71 timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 71 timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
72 timer.initWithCallback(callback, INITIAL_DELAY * MILLISECONDS_IN_SECOND, Ci. nsITimer.TYPE_REPEATING_SLACK); 72 timer.initWithCallback(callback, INITIAL_DELAY * MILLISECONDS_IN_SECOND, Ci. nsITimer.TYPE_REPEATING_SLACK);
73 onShutdown.add(function() 73 onShutdown.add(function()
74 { 74 {
75 timer.cancel(); 75 timer.cancel();
76 }); 76 });
77 77
78 TimeLine.leave("Synchronizer.init() done"); 78 TimeLine.leave("Synchronizer.init() done");
79 }, 79 },
80 80
81 /** 81 /**
82 * Checks whether a subscription is currently being downloaded. 82 * Checks whether a subscription is currently being downloaded.
83 * @param {String} url URL of the subscription 83 * @param {String} url URL of the subscription
84 * @return {Boolean} 84 * @return {Boolean}
85 */ 85 */
86 isExecuting: function(url) 86 isExecuting: function(url)
87 { 87 {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 else 161 else
162 { 162 {
163 // Ignore modification date if we are downloading from a different locatio n 163 // Ignore modification date if we are downloading from a different locatio n
164 forceDownload = true; 164 forceDownload = true;
165 } 165 }
166 166
167 let {addonVersion} = require("info"); 167 let {addonVersion} = require("info");
168 loadFrom = loadFrom.replace(/%VERSION%/, "ABP" + addonVersion); 168 loadFrom = loadFrom.replace(/%VERSION%/, "ABP" + addonVersion);
169 169
170 let request = null; 170 let request = null;
171 function errorCallback(error) 171 let errorCallback = function(error)
172 { 172 {
173 let channelStatus = -1; 173 let channelStatus = -1;
174 try 174 try
175 { 175 {
176 channelStatus = request.channel.status; 176 channelStatus = request.channel.status;
177 } catch (e) {} 177 } catch (e) {}
178 let responseStatus = ""; 178 let responseStatus = "";
179 try 179 try
180 { 180 {
181 responseStatus = request.channel.QueryInterface(Ci.nsIHttpChannel).respo nseStatus; 181 responseStatus = request.channel.QueryInterface(Ci.nsIHttpChannel).respo nseStatus;
182 } catch (e) {} 182 } catch (e) {}
183 setError(subscription, error, channelStatus, responseStatus, loadFrom, isB aseLocation, manual); 183 setError(subscription, error, channelStatus, responseStatus, loadFrom, isB aseLocation, manual);
184 } 184 };
185 185
186 try 186 try
187 { 187 {
188 request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci. nsIXMLHttpRequest); 188 request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci. nsIXMLHttpRequest);
189 request.mozBackgroundRequest = true; 189 request.mozBackgroundRequest = true;
190 request.open("GET", loadFrom); 190 request.open("GET", loadFrom);
191 } 191 }
192 catch (e) 192 catch (e)
193 { 193 {
194 errorCallback("synchronize_invalid_url"); 194 errorCallback("synchronize_invalid_url");
(...skipping 18 matching lines...) Expand all
213 213
214 getInterface: function(iid) 214 getInterface: function(iid)
215 { 215 {
216 if (iid.equals(Ci.nsIChannelEventSink)) 216 if (iid.equals(Ci.nsIChannelEventSink))
217 { 217 {
218 try { 218 try {
219 oldEventSink = oldNotifications.QueryInterface(iid); 219 oldEventSink = oldNotifications.QueryInterface(iid);
220 } catch(e) {} 220 } catch(e) {}
221 return this; 221 return this;
222 } 222 }
223 223
224 if (oldNotifications) 224 if (oldNotifications)
225 return oldNotifications.QueryInterface(iid); 225 return oldNotifications.QueryInterface(iid);
226 else 226 else
227 throw Cr.NS_ERROR_NO_INTERFACE; 227 throw Cr.NS_ERROR_NO_INTERFACE;
228 }, 228 },
229 229
230 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback ) 230 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback )
231 { 231 {
232 if (isBaseLocation && !hadTemporaryRedirect && oldChannel instanceof C i.nsIHttpChannel) 232 if (isBaseLocation && !hadTemporaryRedirect && oldChannel instanceof C i.nsIHttpChannel)
233 { 233 {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 newSubscription.disabled = subscription.disabled; 605 newSubscription.disabled = subscription.disabled;
606 FilterStorage.removeSubscription(subscription); 606 FilterStorage.removeSubscription(subscription);
607 FilterStorage.addSubscription(newSubscription); 607 FilterStorage.addSubscription(newSubscription);
608 Synchronizer.execute(newSubscription); 608 Synchronizer.execute(newSubscription);
609 } 609 }
610 }, false); 610 }, false);
611 request.send(null); 611 request.send(null);
612 } 612 }
613 } 613 }
614 } 614 }
OLDNEW
« no previous file with comments | « lib/requestNotifier.js ('k') | lib/typoAppIntegration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld