| Index: third_party/WebKit/Source/devtools/front_end/sdk/ApplicationCacheModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ApplicationCacheModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ApplicationCacheModel.js
|
| index 5ce96af49a1be33a8086be053be50b689abeef54..2de0acbd3661cf0087c86971234d751d89146a93 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/ApplicationCacheModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ApplicationCacheModel.js
|
| @@ -25,22 +25,23 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.SDKModel}
|
| - * @param {!WebInspector.Target} target
|
| - * @param {!WebInspector.ResourceTreeModel} resourceTreeModel
|
| + * @unrestricted
|
| */
|
| -WebInspector.ApplicationCacheModel = function(target, resourceTreeModel)
|
| -{
|
| - WebInspector.SDKModel.call(this, WebInspector.ApplicationCacheModel, target);
|
| +WebInspector.ApplicationCacheModel = class extends WebInspector.SDKModel {
|
| + /**
|
| + * @param {!WebInspector.Target} target
|
| + * @param {!WebInspector.ResourceTreeModel} resourceTreeModel
|
| + */
|
| + constructor(target, resourceTreeModel) {
|
| + super(WebInspector.ApplicationCacheModel, target);
|
|
|
| target.registerApplicationCacheDispatcher(new WebInspector.ApplicationCacheDispatcher(this));
|
| this._agent = target.applicationCacheAgent();
|
| this._agent.enable();
|
|
|
| - resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this);
|
| + resourceTreeModel.addEventListener(
|
| + WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this);
|
| resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this);
|
|
|
| this._statuses = {};
|
| @@ -48,233 +49,214 @@ WebInspector.ApplicationCacheModel = function(target, resourceTreeModel)
|
|
|
| this._mainFrameNavigated();
|
| this._onLine = true;
|
| -};
|
| -
|
| -/** @enum {symbol} */
|
| -WebInspector.ApplicationCacheModel.Events = {
|
| - FrameManifestStatusUpdated: Symbol("FrameManifestStatusUpdated"),
|
| - FrameManifestAdded: Symbol("FrameManifestAdded"),
|
| - FrameManifestRemoved: Symbol("FrameManifestRemoved"),
|
| - FrameManifestsReset: Symbol("FrameManifestsReset"),
|
| - NetworkStateChanged: Symbol("NetworkStateChanged")
|
| -};
|
| -
|
| -WebInspector.ApplicationCacheModel.prototype = {
|
| - _frameNavigated: function(event)
|
| - {
|
| - var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
|
| - if (frame.isMainFrame()) {
|
| - this._mainFrameNavigated();
|
| - return;
|
| - }
|
| -
|
| - this._agent.getManifestForFrame(frame.id, this._manifestForFrameLoaded.bind(this, frame.id));
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.Event} event
|
| - */
|
| - _frameDetached: function(event)
|
| - {
|
| - var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
|
| - this._frameManifestRemoved(frame.id);
|
| - },
|
| -
|
| - reset: function()
|
| - {
|
| - this._statuses = {};
|
| - this._manifestURLsByFrame = {};
|
| - this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestsReset);
|
| - },
|
| -
|
| - _mainFrameNavigated: function()
|
| - {
|
| - this._agent.getFramesWithManifests(this._framesWithManifestsLoaded.bind(this));
|
| - },
|
| -
|
| - /**
|
| - * @param {string} frameId
|
| - * @param {?Protocol.Error} error
|
| - * @param {string} manifestURL
|
| - */
|
| - _manifestForFrameLoaded: function(frameId, error, manifestURL)
|
| - {
|
| - if (error) {
|
| - console.error(error);
|
| - return;
|
| - }
|
| + }
|
|
|
| - if (!manifestURL)
|
| - this._frameManifestRemoved(frameId);
|
| - },
|
| -
|
| - /**
|
| - * @param {?Protocol.Error} error
|
| - * @param {!Array.<!ApplicationCacheAgent.FrameWithManifest>} framesWithManifests
|
| - */
|
| - _framesWithManifestsLoaded: function(error, framesWithManifests)
|
| - {
|
| - if (error) {
|
| - console.error(error);
|
| - return;
|
| - }
|
| -
|
| - for (var i = 0; i < framesWithManifests.length; ++i)
|
| - this._frameManifestUpdated(framesWithManifests[i].frameId, framesWithManifests[i].manifestURL, framesWithManifests[i].status);
|
| - },
|
| -
|
| - /**
|
| - * @param {string} frameId
|
| - * @param {string} manifestURL
|
| - * @param {number} status
|
| - */
|
| - _frameManifestUpdated: function(frameId, manifestURL, status)
|
| - {
|
| - if (status === applicationCache.UNCACHED) {
|
| - this._frameManifestRemoved(frameId);
|
| - return;
|
| - }
|
| -
|
| - if (!manifestURL)
|
| - return;
|
| + /**
|
| + * @param {!WebInspector.Target} target
|
| + * @return {?WebInspector.ApplicationCacheModel}
|
| + */
|
| + static fromTarget(target) {
|
| + return /** @type {?WebInspector.ApplicationCacheModel} */ (target.model(WebInspector.ApplicationCacheModel));
|
| + }
|
|
|
| - if (this._manifestURLsByFrame[frameId] && manifestURL !== this._manifestURLsByFrame[frameId])
|
| - this._frameManifestRemoved(frameId);
|
| + _frameNavigated(event) {
|
| + var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
|
| + if (frame.isMainFrame()) {
|
| + this._mainFrameNavigated();
|
| + return;
|
| + }
|
|
|
| - var statusChanged = this._statuses[frameId] !== status;
|
| - this._statuses[frameId] = status;
|
| + this._agent.getManifestForFrame(frame.id, this._manifestForFrameLoaded.bind(this, frame.id));
|
| + }
|
|
|
| - if (!this._manifestURLsByFrame[frameId]) {
|
| - this._manifestURLsByFrame[frameId] = manifestURL;
|
| - this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestAdded, frameId);
|
| - }
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| + _frameDetached(event) {
|
| + var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
|
| + this._frameManifestRemoved(frame.id);
|
| + }
|
|
|
| - if (statusChanged)
|
| - this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestStatusUpdated, frameId);
|
| - },
|
| + reset() {
|
| + this._statuses = {};
|
| + this._manifestURLsByFrame = {};
|
| + this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestsReset);
|
| + }
|
| +
|
| + _mainFrameNavigated() {
|
| + this._agent.getFramesWithManifests(this._framesWithManifestsLoaded.bind(this));
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @param {?Protocol.Error} error
|
| + * @param {string} manifestURL
|
| + */
|
| + _manifestForFrameLoaded(frameId, error, manifestURL) {
|
| + if (error) {
|
| + console.error(error);
|
| + return;
|
| + }
|
|
|
| - /**
|
| - * @param {string} frameId
|
| - */
|
| - _frameManifestRemoved: function(frameId)
|
| - {
|
| - if (!this._manifestURLsByFrame[frameId])
|
| - return;
|
| + if (!manifestURL)
|
| + this._frameManifestRemoved(frameId);
|
| + }
|
| +
|
| + /**
|
| + * @param {?Protocol.Error} error
|
| + * @param {!Array.<!ApplicationCacheAgent.FrameWithManifest>} framesWithManifests
|
| + */
|
| + _framesWithManifestsLoaded(error, framesWithManifests) {
|
| + if (error) {
|
| + console.error(error);
|
| + return;
|
| + }
|
|
|
| - delete this._manifestURLsByFrame[frameId];
|
| - delete this._statuses[frameId];
|
| + for (var i = 0; i < framesWithManifests.length; ++i)
|
| + this._frameManifestUpdated(
|
| + framesWithManifests[i].frameId, framesWithManifests[i].manifestURL, framesWithManifests[i].status);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @param {string} manifestURL
|
| + * @param {number} status
|
| + */
|
| + _frameManifestUpdated(frameId, manifestURL, status) {
|
| + if (status === applicationCache.UNCACHED) {
|
| + this._frameManifestRemoved(frameId);
|
| + return;
|
| + }
|
|
|
| - this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestRemoved, frameId);
|
| - },
|
| + if (!manifestURL)
|
| + return;
|
|
|
| - /**
|
| - * @param {string} frameId
|
| - * @return {string}
|
| - */
|
| - frameManifestURL: function(frameId)
|
| - {
|
| - return this._manifestURLsByFrame[frameId] || "";
|
| - },
|
| + if (this._manifestURLsByFrame[frameId] && manifestURL !== this._manifestURLsByFrame[frameId])
|
| + this._frameManifestRemoved(frameId);
|
|
|
| - /**
|
| - * @param {string} frameId
|
| - * @return {number}
|
| - */
|
| - frameManifestStatus: function(frameId)
|
| - {
|
| - return this._statuses[frameId] || applicationCache.UNCACHED;
|
| - },
|
| + var statusChanged = this._statuses[frameId] !== status;
|
| + this._statuses[frameId] = status;
|
|
|
| - /**
|
| - * @return {boolean}
|
| - */
|
| - get onLine()
|
| - {
|
| - return this._onLine;
|
| - },
|
| + if (!this._manifestURLsByFrame[frameId]) {
|
| + this._manifestURLsByFrame[frameId] = manifestURL;
|
| + this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestAdded, frameId);
|
| + }
|
|
|
| + if (statusChanged)
|
| + this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestStatusUpdated, frameId);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + */
|
| + _frameManifestRemoved(frameId) {
|
| + if (!this._manifestURLsByFrame[frameId])
|
| + return;
|
| +
|
| + delete this._manifestURLsByFrame[frameId];
|
| + delete this._statuses[frameId];
|
| +
|
| + this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.FrameManifestRemoved, frameId);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @return {string}
|
| + */
|
| + frameManifestURL(frameId) {
|
| + return this._manifestURLsByFrame[frameId] || '';
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @return {number}
|
| + */
|
| + frameManifestStatus(frameId) {
|
| + return this._statuses[frameId] || applicationCache.UNCACHED;
|
| + }
|
| +
|
| + /**
|
| + * @return {boolean}
|
| + */
|
| + get onLine() {
|
| + return this._onLine;
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @param {string} manifestURL
|
| + * @param {number} status
|
| + */
|
| + _statusUpdated(frameId, manifestURL, status) {
|
| + this._frameManifestUpdated(frameId, manifestURL, status);
|
| + }
|
| +
|
| + /**
|
| + * @param {string} frameId
|
| + * @param {function(?ApplicationCacheAgent.ApplicationCache)} callback
|
| + */
|
| + requestApplicationCache(frameId, callback) {
|
| /**
|
| - * @param {string} frameId
|
| - * @param {string} manifestURL
|
| - * @param {number} status
|
| + * @param {?Protocol.Error} error
|
| + * @param {!ApplicationCacheAgent.ApplicationCache} applicationCache
|
| */
|
| - _statusUpdated: function(frameId, manifestURL, status)
|
| - {
|
| - this._frameManifestUpdated(frameId, manifestURL, status);
|
| - },
|
| + function callbackWrapper(error, applicationCache) {
|
| + if (error) {
|
| + console.error(error);
|
| + callback(null);
|
| + return;
|
| + }
|
| +
|
| + callback(applicationCache);
|
| + }
|
|
|
| - /**
|
| - * @param {string} frameId
|
| - * @param {function(?ApplicationCacheAgent.ApplicationCache)} callback
|
| - */
|
| - requestApplicationCache: function(frameId, callback)
|
| - {
|
| - /**
|
| - * @param {?Protocol.Error} error
|
| - * @param {!ApplicationCacheAgent.ApplicationCache} applicationCache
|
| - */
|
| - function callbackWrapper(error, applicationCache)
|
| - {
|
| - if (error) {
|
| - console.error(error);
|
| - callback(null);
|
| - return;
|
| - }
|
| -
|
| - callback(applicationCache);
|
| - }
|
| -
|
| - this._agent.getApplicationCacheForFrame(frameId, callbackWrapper);
|
| - },
|
| + this._agent.getApplicationCacheForFrame(frameId, callbackWrapper);
|
| + }
|
|
|
| - /**
|
| - * @param {boolean} isNowOnline
|
| - */
|
| - _networkStateUpdated: function(isNowOnline)
|
| - {
|
| - this._onLine = isNowOnline;
|
| - this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.NetworkStateChanged, isNowOnline);
|
| - },
|
| + /**
|
| + * @param {boolean} isNowOnline
|
| + */
|
| + _networkStateUpdated(isNowOnline) {
|
| + this._onLine = isNowOnline;
|
| + this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.NetworkStateChanged, isNowOnline);
|
| + }
|
| +};
|
|
|
| - __proto__: WebInspector.SDKModel.prototype
|
| +/** @enum {symbol} */
|
| +WebInspector.ApplicationCacheModel.Events = {
|
| + FrameManifestStatusUpdated: Symbol('FrameManifestStatusUpdated'),
|
| + FrameManifestAdded: Symbol('FrameManifestAdded'),
|
| + FrameManifestRemoved: Symbol('FrameManifestRemoved'),
|
| + FrameManifestsReset: Symbol('FrameManifestsReset'),
|
| + NetworkStateChanged: Symbol('NetworkStateChanged')
|
| };
|
|
|
| /**
|
| - * @constructor
|
| * @implements {ApplicationCacheAgent.Dispatcher}
|
| + * @unrestricted
|
| */
|
| -WebInspector.ApplicationCacheDispatcher = function(applicationCacheModel)
|
| -{
|
| +WebInspector.ApplicationCacheDispatcher = class {
|
| + constructor(applicationCacheModel) {
|
| this._applicationCacheModel = applicationCacheModel;
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {string} frameId
|
| + * @param {string} manifestURL
|
| + * @param {number} status
|
| + */
|
| + applicationCacheStatusUpdated(frameId, manifestURL, status) {
|
| + this._applicationCacheModel._statusUpdated(frameId, manifestURL, status);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {boolean} isNowOnline
|
| + */
|
| + networkStateUpdated(isNowOnline) {
|
| + this._applicationCacheModel._networkStateUpdated(isNowOnline);
|
| + }
|
| };
|
|
|
| -WebInspector.ApplicationCacheDispatcher.prototype = {
|
| - /**
|
| - * @override
|
| - * @param {string} frameId
|
| - * @param {string} manifestURL
|
| - * @param {number} status
|
| - */
|
| - applicationCacheStatusUpdated: function(frameId, manifestURL, status)
|
| - {
|
| - this._applicationCacheModel._statusUpdated(frameId, manifestURL, status);
|
| - },
|
|
|
| - /**
|
| - * @override
|
| - * @param {boolean} isNowOnline
|
| - */
|
| - networkStateUpdated: function(isNowOnline)
|
| - {
|
| - this._applicationCacheModel._networkStateUpdated(isNowOnline);
|
| - }
|
| -};
|
| -
|
| -/**
|
| - * @param {!WebInspector.Target} target
|
| - * @return {?WebInspector.ApplicationCacheModel}
|
| - */
|
| -WebInspector.ApplicationCacheModel.fromTarget = function(target)
|
| -{
|
| - return /** @type {?WebInspector.ApplicationCacheModel} */ (target.model(WebInspector.ApplicationCacheModel));
|
| -};
|
|
|