Skip to content

Commit 640ef00

Browse files
author
Daniel Herzog
committed
Review fixes
1 parent e15b245 commit 640ef00

File tree

2 files changed

+22
-42
lines changed

2 files changed

+22
-42
lines changed

src/network/network_details_templates.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,10 @@ templates._response_body = function(resp, do_raw, is_last_response)
379379
var ret = [];
380380
var classname = "";
381381

382-
var should_track_content = (
382+
var should_track_content =
383383
resp.saw_responsefinished &&
384384
(!resp.responsebody || !resp.responsebody.content) &&
385-
(!resp.logger_entry_called_get_body || resp.logger_entry_get_body_unsuccessful)
386-
);
385+
(!resp.logger_entry_called_get_body || resp.logger_entry_get_body_unsuccessful);
387386

388387
if (should_track_content)
389388
{

src/network/network_service.js

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,9 @@ cls.NetworkLoggerEntryPrototype = function()
752752
this.encoding = event.characterEncoding;
753753
this.size = event.contentLength;
754754
this.is_finished = true;
755-
// Responses keep duplicates of the finished state. It's only relevant on the last one though.
755+
// Responses keep duplicates of the finished state. It's only relevant on the last one.
756756
if (this._current_response)
757-
this._current_response.update_event_urlfinished(event);
758-
757+
this._current_response.logger_entry_is_finished = true;
759758
this._guess_response_type();
760759
this._humanize_url();
761760
};
@@ -860,7 +859,12 @@ cls.NetworkLoggerEntryPrototype = function()
860859
this.type = cls.ResourceUtil.mime_to_type(this.mime);
861860

862861
if (this._current_response)
863-
this._current_response.update_mime_and_type(this.mime, this.type);
862+
{
863+
// This could be only on the response. But as only the last response has body
864+
// that would complicate it for nothing.
865+
this._current_response.logger_entry_mime = this.mime;
866+
this._current_response.logger_entry_type = this.type;
867+
}
864868
};
865869

866870
this._humanize_url = function()
@@ -920,14 +924,14 @@ cls.NetworkLoggerEntryPrototype = function()
920924

921925
this.check_to_get_body = function()
922926
{
923-
var should_get_body = (
927+
var should_get_body =
924928
this.is_finished &&
925929
!this.called_get_body &&
926930
(!this._current_response || !this._current_response.responsebody) &&
927931
// When we have a response, but didn't see responsefinished, there really is no
928932
// responsebody. Don't attempt to fetch it.
929-
(!this._current_response || this._current_response.saw_responsefinished)
930-
);
933+
(!this._current_response || this._current_response.saw_responsefinished);
934+
931935
// Todo: The exception for !saw_responsefinished is AFAIR so we don't fetch a wrong result like a
932936
// placeholder from Opera, but thee's currently no testcase for that.
933937
// We could also avoid it when this.is_unloaded, but seems there it will
@@ -938,13 +942,13 @@ cls.NetworkLoggerEntryPrototype = function()
938942
// Decide if body should be fetched, for when content-tracking is off or it's a cached request.
939943
this.called_get_body = true;
940944
if (this._current_response)
941-
this._current_response.update_called_get_body(true);
942-
943-
var contentmode = cls.ResourceUtil.mime_to_content_mode(this.mime);
944-
var typecode = {datauri: 3, text: 1}[contentmode];
945-
var tag = window.tagManager.set_callback(this, this._handle_get_resource);
945+
this._current_response.logger_entry_called_get_body = true;
946+
var content_mode = cls.ResourceUtil.mime_to_content_mode(this.mime);
947+
var transport_type = {"text": 1, "datauri": 3}[content_mode];
948+
var tag = window.tag_manager.set_callback(this, this._handle_get_resource);
946949
var CONTENT_MODE_STRING = 1;
947-
window.services["resource-manager"].requestGetResource(tag, [this.resource_id, [typecode, CONTENT_MODE_STRING]]);
950+
window.services["resource-manager"].requestGetResource(tag, [this.resource_id,
951+
[transport_type, CONTENT_MODE_STRING]]);
948952
}
949953
};
950954

@@ -966,8 +970,7 @@ cls.NetworkLoggerEntryPrototype = function()
966970
}
967971
else
968972
{
969-
this.get_body_unsuccessful = true;
970-
this._current_response.update_get_body_unsuccessful(true);
973+
this.get_body_unsuccessful = this._current_response.logger_entry_get_body_unsuccessful = true;
971974
}
972975
window.messages.post("network-resource-updated", {id: this.resource_id});
973976
};
@@ -1076,7 +1079,8 @@ cls.NetworkLoggerResponse = function(entry)
10761079
this.is_response = true; // Simpler for recognizing than dealing with comparing the constructor
10771080
this.saw_responsefinished = false;
10781081

1079-
// The following are duplicated from the entry to have them available directly on the response
1082+
// The following are duplicated from the entry to have them available directly on the response.
1083+
// They are accessed and updated directly from the entry.
10801084
this.logger_entry_type = entry.type;
10811085
this.logger_entry_id = entry.id;
10821086
this.logger_entry_mime = entry.mime;
@@ -1116,29 +1120,6 @@ cls.NetworkLoggerResponsePrototype = function()
11161120
{
11171121
this.responsebody = responsebody;
11181122
};
1119-
1120-
// The following are to reflect changes that happened on Entry.
1121-
this.update_event_urlfinished = function(event)
1122-
{
1123-
this.logger_entry_is_finished = true;
1124-
};
1125-
1126-
this.update_mime_and_type = function(mime, type)
1127-
{
1128-
// This could actually be per response too. But as only the last response has body, it can be on the entry.
1129-
this.logger_entry_mime = mime;
1130-
this.logger_entry_type = type;
1131-
};
1132-
1133-
this.update_called_get_body = function(called_get_body)
1134-
{
1135-
this.logger_entry_called_get_body = called_get_body;
1136-
};
1137-
1138-
this.update_get_body_unsuccessful = function(get_body_unsuccessful)
1139-
{
1140-
this.logger_entry_get_body_unsuccessful = get_body_unsuccessful;
1141-
};
11421123
};
11431124

11441125
cls.NetworkLoggerResponse.prototype = new cls.NetworkLoggerResponsePrototype();

0 commit comments

Comments
 (0)