Skip to content

Commit da886da

Browse files
author
p01
committed
Pruning of the lists of:
* WindowContext, keeping only the ones with saw_main_document set * resources, keeping only the ones that are not unloaded.
1 parent 24869bb commit da886da

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/resource-manager/resource_service.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ cls.ResourceManagerService = function(view, network_logger)
5959
this._update = function(msg)
6060
{
6161
var ctx = {};
62+
// get list of window_contexts for which we saw the main_document
63+
ctx.windowList = (this._network_logger.get_window_contexts()||[]).filter(function(w)
64+
{
65+
return w.saw_main_document;
66+
});
6267

63-
ctx.windowList = this._network_logger.get_window_contexts();
6468
if (ctx.windowList && ctx.windowList.length)
6569
{
6670
var typeGroupMapping =
@@ -73,16 +77,25 @@ cls.ResourceManagerService = function(view, network_logger)
7377
'*':'others'
7478
};
7579

76-
// get all the resources
7780
ctx.resourceList = [];
78-
ctx.windowList.forEach(function(w)
81+
ctx.documentResourceHash = {};
82+
83+
// get all the resources
84+
ctx.windowList
85+
.forEach(function(w)
7986
{
80-
var wr = w.get_resources();
81-
ctx.resourceList = ctx.resourceList.concat( wr );
87+
// get resources of the current window
88+
var windowResources = w.get_resources();
89+
// filter out the resources that are unloaded
90+
windowResources
91+
.filter(function(r)
92+
{
93+
return !r.is_unloaded;
94+
});
95+
// concat the result to flat list of resource
96+
ctx.resourceList = ctx.resourceList.concat( windowResources );
8297
});
8398

84-
ctx.documentResourceHash = {};
85-
8699
// filter the documentId that belong in the windowIdList
87100
ctx.documentList = this._documentList.filter(function(d)
88101
{

0 commit comments

Comments
 (0)