Commit 7a436bf3 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[blink] Clear loader client when script loads

Clear the response_body_loader_client field on ScriptResource when the
resource body finishes loading. This matches what the ResourceLoader
does, and removes a memory leak.

Bug: 944471
Change-Id: Icd2ef954c7f19624f4947a816882ef028321c95c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626858Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662579}
parent 43d2e1ad
......@@ -290,6 +290,7 @@ void ScriptResource::OnDataPipeReadable(MojoResult result,
// This means the producer finished and streamed to completion.
watcher_.reset();
response_body_loader_client_->DidFinishLoadingBody();
response_body_loader_client_ = nullptr;
return;
case MOJO_RESULT_SHOULD_WAIT:
......@@ -300,6 +301,7 @@ void ScriptResource::OnDataPipeReadable(MojoResult result,
// Some other error occurred.
watcher_.reset();
response_body_loader_client_->DidFailLoadingBody();
response_body_loader_client_ = nullptr;
return;
}
CHECK(state.readable());
......@@ -358,6 +360,7 @@ void ScriptResource::NotifyFinished() {
case StreamingState::kStreamingNotAllowed:
watcher_.reset();
data_pipe_.reset();
response_body_loader_client_ = nullptr;
AdvanceStreamingState(StreamingState::kFinishedNotificationSent);
TextResource::NotifyFinished();
break;
......@@ -382,6 +385,7 @@ void ScriptResource::StreamingFinished() {
// small) and b) an external error triggered the finished notification.
watcher_.reset();
data_pipe_.reset();
response_body_loader_client_ = nullptr;
AdvanceStreamingState(StreamingState::kFinishedNotificationSent);
TextResource::NotifyFinished();
}
......@@ -463,6 +467,7 @@ void ScriptResource::SetClientIsWaitingForFinished() {
if (IsLoaded()) {
watcher_.reset();
data_pipe_.reset();
response_body_loader_client_ = nullptr;
AdvanceStreamingState(StreamingState::kFinishedNotificationSent);
TextResource::NotifyFinished();
}
......@@ -536,6 +541,7 @@ void ScriptResource::CheckStreamingState() const {
CHECK(!streamer_ || streamer_->IsFinished());
CHECK(!watcher_ || !watcher_->IsWatching());
CHECK(!data_pipe_);
CHECK(!response_body_loader_client_);
CHECK(IsLoaded());
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment