OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @implements {WebInspector.CSSSourceMapping} | 33 * @implements {WebInspector.CSSSourceMapping} |
34 * @param {!WebInspector.CSSStyleModel} cssModel | 34 * @param {!WebInspector.CSSStyleModel} cssModel |
35 * @param {!WebInspector.Workspace} workspace | 35 * @param {!WebInspector.Workspace} workspace |
36 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding | 36 * @param {!WebInspector.NetworkWorkspaceBinding} networkWorkspaceBinding |
37 */ | 37 */ |
38 WebInspector.SASSSourceMapping = function(cssModel, workspace, networkWorkspaceB
inding) | 38 WebInspector.SASSSourceMapping = function(cssModel, workspace, networkWorkspaceB
inding) |
39 { | 39 { |
40 this.pollPeriodMs = 5000; | 40 this.pollPeriodMs = 30 * 1000; |
41 this.pollIntervalMs = 200; | 41 this.pollIntervalMs = 200; |
42 | 42 |
43 this._cssModel = cssModel; | 43 this._cssModel = cssModel; |
44 this._workspace = workspace; | 44 this._workspace = workspace; |
45 this._networkWorkspaceBinding = networkWorkspaceBinding; | 45 this._networkWorkspaceBinding = networkWorkspaceBinding; |
46 this._addingRevisionCounter = 0; | 46 this._addingRevisionCounter = 0; |
47 this._reset(); | 47 this._reset(); |
48 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventType
s.SavedURL, this._fileSaveFinished, this); | 48 WebInspector.fileManager.addEventListener(WebInspector.FileManager.EventType
s.SavedURL, this._fileSaveFinished, this); |
49 WebInspector.settings.cssSourceMapsEnabled.addChangeListener(this._toggleSou
rceMapSupport, this) | 49 WebInspector.settings.cssSourceMapsEnabled.addChangeListener(this._toggleSou
rceMapSupport, this) |
50 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet
Changed, this._styleSheetChanged, this); | 50 this._cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheet
Changed, this._styleSheetChanged, this); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 * @param {string} sassURL | 214 * @param {string} sassURL |
215 * @param {boolean} stopPolling | 215 * @param {boolean} stopPolling |
216 */ | 216 */ |
217 _pollCallback: function(cssURL, sassURL, stopPolling) | 217 _pollCallback: function(cssURL, sassURL, stopPolling) |
218 { | 218 { |
219 var now; | 219 var now; |
220 var pollData = this._pollDataForSASSURL[sassURL]; | 220 var pollData = this._pollDataForSASSURL[sassURL]; |
221 if (!pollData) | 221 if (!pollData) |
222 return; | 222 return; |
223 | 223 |
224 if (stopPolling || (now = new Date().getTime()) > pollData.deadlineMs) { | 224 if (stopPolling) { |
225 delete pollData.dataByURL[cssURL]; | 225 this._stopPolling(cssURL, sassURL); |
226 if (!Object.keys(pollData.dataByURL).length) | 226 return; |
227 delete this._pollDataForSASSURL[sassURL]; | 227 } |
| 228 |
| 229 if ((now = new Date().getTime()) > pollData.deadlineMs) { |
| 230 WebInspector.console.warn(WebInspector.UIString("%s hasn't been upda
ted in %d seconds.", cssURL, this.pollPeriodMs / 1000)); |
| 231 this._stopPolling(cssURL, sassURL); |
228 return; | 232 return; |
229 } | 233 } |
230 var nextPoll = this.pollIntervalMs + pollData.dataByURL[cssURL].previous
Poll; | 234 var nextPoll = this.pollIntervalMs + pollData.dataByURL[cssURL].previous
Poll; |
231 var remainingTimeoutMs = Math.max(0, nextPoll - now); | 235 var remainingTimeoutMs = Math.max(0, nextPoll - now); |
232 pollData.dataByURL[cssURL].previousPoll = now + remainingTimeoutMs; | 236 pollData.dataByURL[cssURL].previousPoll = now + remainingTimeoutMs; |
233 pollData.dataByURL[cssURL].timer = setTimeout(this._reloadCSS.bind(this,
cssURL, sassURL, this._pollCallback.bind(this)), remainingTimeoutMs); | 237 pollData.dataByURL[cssURL].timer = setTimeout(this._reloadCSS.bind(this,
cssURL, sassURL, this._pollCallback.bind(this)), remainingTimeoutMs); |
234 }, | 238 }, |
235 | 239 |
236 /** | 240 /** |
237 * @param {string} cssURL | 241 * @param {string} cssURL |
238 * @param {string} sassURL | 242 * @param {string} sassURL |
| 243 */ |
| 244 _stopPolling: function(cssURL, sassURL) |
| 245 { |
| 246 var pollData = this._pollDataForSASSURL[sassURL]; |
| 247 delete pollData.dataByURL[cssURL]; |
| 248 if (!Object.keys(pollData.dataByURL).length) |
| 249 delete this._pollDataForSASSURL[sassURL]; |
| 250 }, |
| 251 |
| 252 /** |
| 253 * @param {string} cssURL |
| 254 * @param {string} sassURL |
239 * @param {function(string, string, boolean)} callback | 255 * @param {function(string, string, boolean)} callback |
240 */ | 256 */ |
241 _reloadCSS: function(cssURL, sassURL, callback) | 257 _reloadCSS: function(cssURL, sassURL, callback) |
242 { | 258 { |
243 var cssUISourceCode = this._workspace.uiSourceCodeForURL(cssURL); | 259 var cssUISourceCode = this._workspace.uiSourceCodeForURL(cssURL); |
244 if (!cssUISourceCode) { | 260 if (!cssUISourceCode) { |
245 WebInspector.console.warn(WebInspector.UIString("%s resource missing
. Please reload the page.", cssURL)); | 261 WebInspector.console.warn(WebInspector.UIString("%s resource missing
. Please reload the page.", cssURL)); |
246 callback(cssURL, sassURL, true); | 262 callback(cssURL, sassURL, true); |
247 return; | 263 return; |
248 } | 264 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 this._cssURLsForSASSURL = {}; | 641 this._cssURLsForSASSURL = {}; |
626 /** @type {!Object.<string, !Array.<function(?WebInspector.SourceMap)>>}
*/ | 642 /** @type {!Object.<string, !Array.<function(?WebInspector.SourceMap)>>}
*/ |
627 this._pendingSourceMapLoadingCallbacks = {}; | 643 this._pendingSourceMapLoadingCallbacks = {}; |
628 /** @type {!Object.<string, !{deadlineMs: number, dataByURL: !Object.<st
ring, !{timer: number, previousPoll: number}>}>} */ | 644 /** @type {!Object.<string, !{deadlineMs: number, dataByURL: !Object.<st
ring, !{timer: number, previousPoll: number}>}>} */ |
629 this._pollDataForSASSURL = {}; | 645 this._pollDataForSASSURL = {}; |
630 /** @type {!Object.<string, !WebInspector.SourceMap>} */ | 646 /** @type {!Object.<string, !WebInspector.SourceMap>} */ |
631 this._sourceMapByURL = {}; | 647 this._sourceMapByURL = {}; |
632 this._sourceMapByStyleSheetURL = {}; | 648 this._sourceMapByStyleSheetURL = {}; |
633 } | 649 } |
634 } | 650 } |
OLD | NEW |