Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js

Issue 2801943003: [DevTools] Remove SDK.SDKObject (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 * @param {boolean=} bypassCache 86 * @param {boolean=} bypassCache
87 * @param {string=} scriptToEvaluateOnLoad 87 * @param {string=} scriptToEvaluateOnLoad
88 */ 88 */
89 static reloadAllPages(bypassCache, scriptToEvaluateOnLoad) { 89 static reloadAllPages(bypassCache, scriptToEvaluateOnLoad) {
90 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel )) { 90 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel )) {
91 if (!resourceTreeModel.target().parentTarget()) 91 if (!resourceTreeModel.target().parentTarget())
92 resourceTreeModel.reloadPage(bypassCache, scriptToEvaluateOnLoad); 92 resourceTreeModel.reloadPage(bypassCache, scriptToEvaluateOnLoad);
93 } 93 }
94 } 94 }
95 95
96 /**
97 * @return {!SDK.DOMModel}
98 */
99 domModel() {
100 return /** @type {!SDK.DOMModel} */ (this.target().model(SDK.DOMModel));
101 }
102
96 _fetchResourceTree() { 103 _fetchResourceTree() {
97 /** @type {!Map<string, !SDK.ResourceTreeFrame>} */ 104 /** @type {!Map<string, !SDK.ResourceTreeFrame>} */
98 this._frames = new Map(); 105 this._frames = new Map();
99 this._cachedResourcesProcessed = false; 106 this._cachedResourcesProcessed = false;
100 this._agent.getResourceTree(this._processCachedResources.bind(this)); 107 this._agent.getResourceTree(this._processCachedResources.bind(this));
101 } 108 }
102 109
103 _processCachedResources(error, mainFramePayload) { 110 _processCachedResources(error, mainFramePayload) {
104 if (!error) { 111 if (!error) {
105 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources); 112 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 var frameId = event.data.frameId; 261 var frameId = event.data.frameId;
255 var frame = this._frames.get(frameId); 262 var frame = this._frames.get(frameId);
256 if (!frame) 263 if (!frame)
257 return; 264 return;
258 265
259 var url = event.data.url; 266 var url = event.data.url;
260 if (frame._resourcesMap[url]) 267 if (frame._resourcesMap[url])
261 return; 268 return;
262 269
263 var resource = new SDK.Resource( 270 var resource = new SDK.Resource(
264 this.target(), null, url, frame.url, frameId, event.data.loaderId, 271 this, null, url, frame.url, frameId, event.data.loaderId, Common.resourc eTypes[event.data.resourceType],
265 Common.resourceTypes[event.data.resourceType], event.data.mimeType, even t.data.lastModified, null); 272 event.data.mimeType, event.data.lastModified, null);
266 frame.addResource(resource); 273 frame.addResource(resource);
267 } 274 }
268 275
269 /** 276 /**
270 * @param {!Protocol.Page.FrameId} frameId 277 * @param {!Protocol.Page.FrameId} frameId
271 * @return {!SDK.ResourceTreeFrame} 278 * @return {!SDK.ResourceTreeFrame}
272 */ 279 */
273 frameForId(frameId) { 280 frameForId(frameId) {
274 return this._frames.get(frameId); 281 return this._frames.get(frameId);
275 } 282 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 * @param {string} url 337 * @param {string} url
331 * @param {!Common.ResourceType} type 338 * @param {!Common.ResourceType} type
332 * @param {string} mimeType 339 * @param {string} mimeType
333 * @param {?number} lastModifiedTime 340 * @param {?number} lastModifiedTime
334 * @param {?number} contentSize 341 * @param {?number} contentSize
335 * @return {!SDK.Resource} 342 * @return {!SDK.Resource}
336 */ 343 */
337 _createResourceFromFramePayload(frame, url, type, mimeType, lastModifiedTime, contentSize) { 344 _createResourceFromFramePayload(frame, url, type, mimeType, lastModifiedTime, contentSize) {
338 var lastModified = typeof lastModifiedTime === 'number' ? new Date(lastModif iedTime * 1000) : null; 345 var lastModified = typeof lastModifiedTime === 'number' ? new Date(lastModif iedTime * 1000) : null;
339 return new SDK.Resource( 346 return new SDK.Resource(
340 this.target(), null, url, frame.url, frame.id, frame.loaderId, type, mim eType, lastModified, contentSize); 347 this, null, url, frame.url, frame.id, frame.loaderId, type, mimeType, la stModified, contentSize);
341 } 348 }
342 349
343 suspendReload() { 350 suspendReload() {
344 this._reloadSuspensionCount++; 351 this._reloadSuspensionCount++;
345 } 352 }
346 353
347 resumeReload() { 354 resumeReload() {
348 this._reloadSuspensionCount--; 355 this._reloadSuspensionCount--;
349 console.assert(this._reloadSuspensionCount >= 0, 'Unbalanced call to Resourc eTreeModel.resumeReload()'); 356 console.assert(this._reloadSuspensionCount >= 0, 'Unbalanced call to Resourc eTreeModel.resumeReload()');
350 if (!this._reloadSuspensionCount && this._pendingReloadOptions) 357 if (!this._reloadSuspensionCount && this._pendingReloadOptions)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 /** 514 /**
508 * @type {!Object.<string, !SDK.Resource>} 515 * @type {!Object.<string, !SDK.Resource>}
509 */ 516 */
510 this._resourcesMap = {}; 517 this._resourcesMap = {};
511 518
512 if (this._parentFrame) 519 if (this._parentFrame)
513 this._parentFrame._childFrames.push(this); 520 this._parentFrame._childFrames.push(this);
514 } 521 }
515 522
516 /** 523 /**
517 * @return {!SDK.Target} 524 * @return {!SDK.ResourceTreeModel}
518 */ 525 */
519 target() { 526 resourceTreeModel() {
520 return this._model.target(); 527 return this._model;
521 } 528 }
522 529
523 /** 530 /**
524 * @return {string} 531 * @return {string}
525 */ 532 */
526 get id() { 533 get id() {
527 return this._id; 534 return this._id;
528 } 535 }
529 536
530 /** 537 /**
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 /** 650 /**
644 * @param {!SDK.NetworkRequest} request 651 * @param {!SDK.NetworkRequest} request
645 */ 652 */
646 _addRequest(request) { 653 _addRequest(request) {
647 var resource = this._resourcesMap[request.url()]; 654 var resource = this._resourcesMap[request.url()];
648 if (resource && resource.request === request) { 655 if (resource && resource.request === request) {
649 // Already in the tree, we just got an extra update. 656 // Already in the tree, we just got an extra update.
650 return; 657 return;
651 } 658 }
652 resource = new SDK.Resource( 659 resource = new SDK.Resource(
653 this.target(), request, request.url(), request.documentURL, request.fram eId, request.loaderId, 660 this._model, request, request.url(), request.documentURL, request.frameI d, request.loaderId,
654 request.resourceType(), request.mimeType, null, null); 661 request.resourceType(), request.mimeType, null, null);
655 this._resourcesMap[resource.url] = resource; 662 this._resourcesMap[resource.url] = resource;
656 this._model.dispatchEventToListeners(SDK.ResourceTreeModel.Events.ResourceAd ded, resource); 663 this._model.dispatchEventToListeners(SDK.ResourceTreeModel.Events.ResourceAd ded, resource);
657 } 664 }
658 665
659 /** 666 /**
660 * @return {!Array.<!SDK.Resource>} 667 * @return {!Array.<!SDK.Resource>}
661 */ 668 */
662 resources() { 669 resources() {
663 var result = []; 670 var result = [];
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden); 867 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden);
861 } 868 }
862 869
863 /** 870 /**
864 * @override 871 * @override
865 */ 872 */
866 navigationRequested() { 873 navigationRequested() {
867 // Frontend is not interested in when navigations are requested. 874 // Frontend is not interested in when navigations are requested.
868 } 875 }
869 }; 876 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698