Skip to content

Commit df2324d

Browse files
author
p01
committed
Review fixes including _suppress_updates_url alone to suppress the "resource-update" of the resource data being fetched.
1 parent e490ef8 commit df2324d

File tree

2 files changed

+36
-57
lines changed

2 files changed

+36
-57
lines changed

src/resource-manager/resource_display_broker.js

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ window.cls = window.cls || {};
55
cls.ResourceDisplayBroker = function()
66
{
77
if (cls.ResourceDisplayBroker.instance)
8-
{
98
return cls.ResourceDisplayBroker.instance;
10-
}
11-
cls.ResourceDisplayBroker.instance = this;
129

10+
cls.ResourceDisplayBroker.instance = this;
1311

14-
this._show_resource = function(resource, line)
12+
this._show_resource = function(id_or_url, line)
1513
{
1614
var data = {};
1715
var manager = window.services["resource-manager"];
@@ -21,55 +19,44 @@ cls.ResourceDisplayBroker = function()
2119
if (line)
2220
data.lines = [line];
2321

24-
view.show_resource(resource, data);
22+
view.show_resource(id_or_url, data);
2523

2624
return true;
2725
}
2826
return false;
29-
}
30-
31-
this.show_resource_for_id = function(id, line)
32-
{
33-
if (!this._show_resource(id, line))
34-
window.open(url);
35-
}
36-
37-
this.show_resource_for_url = function(url, line)
38-
{
39-
if (!this._show_resource(url, line))
40-
window.open(url);
41-
}
27+
};
4228

4329
/**
4430
* convenience method that looks for a data-resource-id or
45-
* data-resource-url attribute on an element and calls the
46-
* appropriate method
31+
* data-resource-url attribute on an element to show the
32+
* corresponding resource and fallback to a popup
4733
*/
4834
this.show_resource_for_ele = function(ele)
4935
{
5036
var id = Number(ele.getAttribute("data-resource-id"));
5137
var url = ele.getAttribute("data-resource-url");
5238
var line = ele.getAttribute("data-resource-line-number");
39+
var id_or_url = id;
5340
var rt_id;
5441

55-
if (id)
56-
this.show_resource_for_id(id, line);
57-
else if (url)
42+
if (url)
5843
{
59-
// resolve the URL based on that of the runtime if we only have a relative path
44+
// resolve the URL based on that of the runtime if we only have a relative path
6045
if (url.indexOf("://") == -1)
6146
{
6247
rt_id = ele.get_attr("parent-node-chain", "rt-id");
6348
if (rt_id)
6449
url = window.helpers.resolveURLS(runtimes.getURI(rt_id), url);
6550
}
66-
this.show_resource_for_url(url, line);
6751
}
68-
}
6952

70-
}
53+
if (!this._show_resource(id_or_url, line) && url)
54+
window.open(url);
55+
};
56+
57+
};
7158

7259
cls.ResourceDisplayBroker.get_instance = function()
7360
{
7461
return this.instance || new cls.ResourceDisplayBroker();
75-
}
62+
};

src/resource-manager/resource_service.js

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ cls.ResourceManagerService = function(view, network_logger)
2323
"*": ui_strings.S_HTTP_LABEL_FILTER_OTHER
2424
};
2525

26-
2726
this._view = view;
2827
this._network_logger = network_logger;
2928

30-
3129
this._handle_list_documents = function(status, msg)
3230
{
3331
this._document_list = new cls.DocumentManager["1.0"].DocumentList(msg).documentList;
@@ -38,7 +36,6 @@ cls.ResourceManagerService = function(view, network_logger)
3836
d.url = new URI(d.url);
3937
});
4038

41-
4239
this._update({type: "_handle_list_documents"});
4340
};
4441

@@ -57,21 +54,24 @@ cls.ResourceManagerService = function(view, network_logger)
5754

5855
if (!this._document_resources[document_id].contains(r.uid))
5956
this._document_resources[document_id].push(r.uid);
60-
}
57+
};
6158

6259
this._update = function(msg)
6360
{
6461
// bounce if _suppress_updates
65-
if (this._suppress_updates)
62+
if (this._suppress_updates_url)
6663
{
6764
if (msg && msg.type == "resource-update")
6865
{
6966
// suppress the uid altogether if its URL matches the one we are requesting
70-
var r = this._network_logger.get_resources([msg.id]);
71-
if (r && r[0] && r[0].url == this._suppress_updates_url)
67+
var r = this._network_logger.get_resources([msg.id])[0];
68+
if (r && r.url == this._suppress_updates_url)
7269
this._suppress_uids[msg.id] = true;
70+
71+
// skip the update if it is about a suppressed uid
72+
if (this._suppress_uids[msg.id])
73+
return;
7374
}
74-
return setTimeout(this._update_bound, THROTTLE_DELAY);
7575
}
7676

7777
// build the context
@@ -124,7 +124,7 @@ cls.ResourceManagerService = function(view, network_logger)
124124
// set depth, pivotID and sameOrigin
125125
var p = a[document_id_index[d.parentDocumentID]] || {pivotID:d.windowID, depth:0};
126126
var id = p.pivotID + "_" + d.documentID;
127-
d.depth = p.depth+1;
127+
d.depth = p.depth + 1;
128128
d.pivotID = id;
129129
d.sameOrigin = cls.ResourceUtil.sameOrigin(p.url, d.url);
130130

@@ -133,7 +133,7 @@ cls.ResourceManagerService = function(view, network_logger)
133133
if (!hash.hasOwnProperty(id))
134134
{
135135
hash[id] = d.depth > 1;
136-
ctx.groupOrder.forEach(function(g) { hash[id + "_"+ g] = true; });
136+
ctx.groupOrder.forEach(function(g) { hash[id + "_" + g] = true; });
137137
}
138138
}
139139

@@ -194,7 +194,6 @@ cls.ResourceManagerService = function(view, network_logger)
194194

195195
this._update_bound = this._update.bind(this);
196196

197-
198197
this._on_debug_context_selected_bound = function()
199198
{
200199
this._reset();
@@ -215,7 +214,7 @@ cls.ResourceManagerService = function(view, network_logger)
215214

216215
if (event.shiftKey)
217216
{
218-
pivotIDs.push.apply(pivotIDs, Object.keys(hash).filter( function(p) {
217+
pivotIDs.push.apply(pivotIDs, Object.keys(hash).filter(function(p) {
219218
return p.startswith(pivotID + '_');
220219
}));
221220
}
@@ -226,7 +225,6 @@ cls.ResourceManagerService = function(view, network_logger)
226225
}
227226
}.bind(this);
228227

229-
230228
this._handle_resource_detail_bound = function(event, target)
231229
{
232230
if (!this._context)
@@ -278,7 +276,7 @@ cls.ResourceManagerService = function(view, network_logger)
278276

279277
this.highlight_resource(uid);
280278
cls.ResourceDetailView.instance.show_resource(uid);
281-
}
279+
};
282280

283281
this.highlight_next_resource_bound = function()
284282
{
@@ -292,7 +290,7 @@ cls.ResourceManagerService = function(view, network_logger)
292290

293291
this._resource_request_update_bound = function(msg)
294292
{
295-
this._suppress_updates = (msg.type == "resource-request-id");
293+
delete this._suppress_updates_url;
296294
}.bind(this);
297295

298296
this._init = function()
@@ -312,7 +310,6 @@ cls.ResourceManagerService = function(view, network_logger)
312310
messages.add_listener('debug-context-selected', this._on_debug_context_selected_bound);
313311

314312
listener = this._resource_request_update_bound;
315-
messages.add_listener('resource-request-id', listener);
316313
messages.add_listener('resource-request-resource', listener);
317314
messages.add_listener('resource-request-fallback', listener);
318315

@@ -335,7 +332,6 @@ cls.ResourceManagerService = function(view, network_logger)
335332
this._collapsed_hash = {};
336333
this._document_resources = {};
337334

338-
this._suppress_updates = false;
339335
this._suppress_uids = {};
340336
this._view.update();
341337
};
@@ -367,10 +363,9 @@ cls.ResourceManagerService = function(view, network_logger)
367363

368364
this.request_resource_data = function(url, callback, data, resourceInfo)
369365
{
370-
this._suppress_updates = true;
371366
this._suppress_updates_url = url;
372367
new cls.ResourceRequest(url, callback, data, resourceInfo);
373-
}
368+
};
374369

375370
this._init();
376371
};
@@ -400,15 +395,15 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
400395
this._request_create_request();
401396
else
402397
this._fallback();
403-
}
398+
};
404399

405400
this._fallback = function()
406401
{
407402
// broadcast that we fellback
408403
window.messages.post("resource-request-fallback", {resource_id: this.resource_id});
409404

410405
window.open(this.url);
411-
}
406+
};
412407

413408
this._request_create_request = function()
414409
{
@@ -420,7 +415,7 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
420415
}
421416
else
422417
this._fallback();
423-
}
418+
};
424419

425420
this._on_request_resource_id = function(status, message)
426421
{
@@ -430,14 +425,11 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
430425
var RESOURCE_ID = 0;
431426
this.resource_id = message[RESOURCE_ID];
432427

433-
// broadcast that we are working on the resource this.resource_id
434-
window.messages.post("resource-request-id", {resource_id: this.resource_id});
435-
436428
this._request_get_resource();
437429
}
438430
else
439431
this._fallback();
440-
}
432+
};
441433

442434
this._request_get_resource = function()
443435
{
@@ -451,7 +443,7 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
451443

452444
var tag = this._tag_manager.set_callback(this, this._on_request_get_resource);
453445
this._resource_manager.requestGetResource(tag, [this.resource_id, [transport_type, DECODE_TRUE, SIZE_LIMIT]]);
454-
}
446+
};
455447

456448
this._on_request_get_resource = function(status, message)
457449
{
@@ -484,9 +476,9 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
484476
}
485477
else
486478
this._fallback();
487-
}
479+
};
488480

489481
this._init(url, callback, data, resourceInfo);
490-
}
482+
};
491483

492484
cls.ResourceRequest.prototype = new URIPrototype("url");

0 commit comments

Comments
 (0)