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

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

Issue 2413233003: DevTools: introduce WI.Resource.contentSize() and WI.Resource.lastModified() (Closed)
Patch Set: always send last-modified in php script Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/Resource.js ('k') | no next file » | 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 * 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 var frameId = event.data.frameId; 295 var frameId = event.data.frameId;
296 var frame = this._frames.get(frameId); 296 var frame = this._frames.get(frameId);
297 if (!frame) 297 if (!frame)
298 return; 298 return;
299 299
300 var url = event.data.url; 300 var url = event.data.url;
301 if (frame._resourcesMap[url]) 301 if (frame._resourcesMap[url])
302 return; 302 return;
303 303
304 var resource = new WebInspector.Resource(this.target(), null, url, frame .url, frameId, event.data.loaderId, WebInspector.resourceTypes[event.data.resour ceType], event.data.mimeType); 304 var resource = new WebInspector.Resource(this.target(), null, url, frame .url, frameId, event.data.loaderId, WebInspector.resourceTypes[event.data.resour ceType], event.data.mimeType, event.data.lastModified, null);
305 frame.addResource(resource); 305 frame.addResource(resource);
306 }, 306 },
307 307
308 /** 308 /**
309 * @param {!PageAgent.FrameId} frameId 309 * @param {!PageAgent.FrameId} frameId
310 * @return {!WebInspector.ResourceTreeFrame} 310 * @return {!WebInspector.ResourceTreeFrame}
311 */ 311 */
312 frameForId: function(frameId) 312 frameForId: function(frameId)
313 { 313 {
314 return this._frames.get(frameId); 314 return this._frames.get(frameId);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 /** 346 /**
347 * @param {?WebInspector.ResourceTreeFrame} parentFrame 347 * @param {?WebInspector.ResourceTreeFrame} parentFrame
348 * @param {!PageAgent.FrameResourceTree} frameTreePayload 348 * @param {!PageAgent.FrameResourceTree} frameTreePayload
349 */ 349 */
350 _addFramesRecursively: function(parentFrame, frameTreePayload) 350 _addFramesRecursively: function(parentFrame, frameTreePayload)
351 { 351 {
352 var framePayload = frameTreePayload.frame; 352 var framePayload = frameTreePayload.frame;
353 var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameP ayload.id, framePayload); 353 var frame = new WebInspector.ResourceTreeFrame(this, parentFrame, frameP ayload.id, framePayload);
354 this._addFrame(frame); 354 this._addFrame(frame);
355 355
356 var frameResource = this._createResourceFromFramePayload(framePayload, f ramePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType); 356 var frameResource = this._createResourceFromFramePayload(framePayload, f ramePayload.url, WebInspector.resourceTypes.Document, framePayload.mimeType, nul l, null);
357 frame.addResource(frameResource); 357 frame.addResource(frameResource);
358 358
359 for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.chi ldFrames.length; ++i) 359 for (var i = 0; frameTreePayload.childFrames && i < frameTreePayload.chi ldFrames.length; ++i)
360 this._addFramesRecursively(frame, frameTreePayload.childFrames[i]); 360 this._addFramesRecursively(frame, frameTreePayload.childFrames[i]);
361 361
362 for (var i = 0; i < frameTreePayload.resources.length; ++i) { 362 for (var i = 0; i < frameTreePayload.resources.length; ++i) {
363 var subresource = frameTreePayload.resources[i]; 363 var subresource = frameTreePayload.resources[i];
364 var resource = this._createResourceFromFramePayload(framePayload, su bresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeTyp e); 364 var resource = this._createResourceFromFramePayload(framePayload, su bresource.url, WebInspector.resourceTypes[subresource.type], subresource.mimeTyp e, subresource.lastModified || null, subresource.contentSize || null);
365 frame.addResource(resource); 365 frame.addResource(resource);
366 } 366 }
367 }, 367 },
368 368
369 /** 369 /**
370 * @param {!PageAgent.Frame} frame 370 * @param {!PageAgent.Frame} frame
371 * @param {string} url 371 * @param {string} url
372 * @param {!WebInspector.ResourceType} type 372 * @param {!WebInspector.ResourceType} type
373 * @param {string} mimeType 373 * @param {string} mimeType
374 * @param {?number} lastModifiedTime
375 * @param {?number} contentSize
374 * @return {!WebInspector.Resource} 376 * @return {!WebInspector.Resource}
375 */ 377 */
376 _createResourceFromFramePayload: function(frame, url, type, mimeType) 378 _createResourceFromFramePayload: function(frame, url, type, mimeType, lastMo difiedTime, contentSize)
377 { 379 {
378 return new WebInspector.Resource(this.target(), null, url, frame.url, fr ame.id, frame.loaderId, type, mimeType); 380 var lastModified = typeof lastModifiedTime === "number" ? new Date(lastM odifiedTime * 1000) : null;
381 return new WebInspector.Resource(this.target(), null, url, frame.url, fr ame.id, frame.loaderId, type, mimeType, lastModified, contentSize);
379 }, 382 },
380 383
381 suspendReload: function() 384 suspendReload: function()
382 { 385 {
383 this._reloadSuspensionCount++; 386 this._reloadSuspensionCount++;
384 }, 387 },
385 388
386 resumeReload: function() 389 resumeReload: function()
387 { 390 {
388 this._reloadSuspensionCount--; 391 this._reloadSuspensionCount--;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 if (this._resourcesMap[resource.url] === resource) { 690 if (this._resourcesMap[resource.url] === resource) {
688 // Already in the tree, we just got an extra update. 691 // Already in the tree, we just got an extra update.
689 return; 692 return;
690 } 693 }
691 this._resourcesMap[resource.url] = resource; 694 this._resourcesMap[resource.url] = resource;
692 this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.Even ts.ResourceAdded, resource); 695 this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.Even ts.ResourceAdded, resource);
693 }, 696 },
694 697
695 /** 698 /**
696 * @param {!WebInspector.NetworkRequest} request 699 * @param {!WebInspector.NetworkRequest} request
697 * @return {!WebInspector.Resource}
698 */ 700 */
699 _addRequest: function(request) 701 _addRequest: function(request)
700 { 702 {
701 var resource = this._resourcesMap[request.url]; 703 var resource = this._resourcesMap[request.url];
702 if (resource && resource.request === request) { 704 if (resource && resource.request === request) {
703 // Already in the tree, we just got an extra update. 705 // Already in the tree, we just got an extra update.
704 return resource; 706 return;
705 } 707 }
706 resource = new WebInspector.Resource(this.target(), request, request.url , request.documentURL, request.frameId, request.loaderId, request.resourceType() , request.mimeType); 708 resource = new WebInspector.Resource(this.target(), request, request.url , request.documentURL, request.frameId, request.loaderId, request.resourceType() , request.mimeType, null, null);
707 this._resourcesMap[resource.url] = resource; 709 this._resourcesMap[resource.url] = resource;
708 this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.Even ts.ResourceAdded, resource); 710 this._model.dispatchEventToListeners(WebInspector.ResourceTreeModel.Even ts.ResourceAdded, resource);
709 return resource;
710 }, 711 },
711 712
712 /** 713 /**
713 * @return {!Array.<!WebInspector.Resource>} 714 * @return {!Array.<!WebInspector.Resource>}
714 */ 715 */
715 resources: function() 716 resources: function()
716 { 717 {
717 var result = []; 718 var result = [];
718 for (var url in this._resourcesMap) 719 for (var url in this._resourcesMap)
719 result.push(this._resourcesMap[url]); 720 result.push(this._resourcesMap[url]);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 936
936 /** 937 /**
937 * @override 938 * @override
938 */ 939 */
939 navigationRequested: function() 940 navigationRequested: function()
940 { 941 {
941 // Frontend is not interested in when navigations are requested. 942 // Frontend is not interested in when navigations are requested.
942 } 943 }
943 944
944 } 945 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sdk/Resource.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698