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

Unified Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 844913002: [ServiceWorker] Refactor the codes for releasing the resources for streaming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_url_request_job.cc
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index 3a2dee5cb93e2c05868e019af17d51e54d031639..b2d836b947d3d99e65539ed5fb1ac42d556b6f75 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -83,21 +83,7 @@ void ServiceWorkerURLRequestJob::Start() {
void ServiceWorkerURLRequestJob::Kill() {
net::URLRequestJob::Kill();
- if (stream_ || !waiting_stream_url_.is_empty()) {
- if (ServiceWorkerVersion* active_version = provider_host_->active_version())
- active_version->RemoveStreamingURLRequestJob(this);
- }
- if (stream_) {
- stream_->RemoveReadObserver(this);
- stream_->Abort();
- stream_ = nullptr;
- }
- if (!waiting_stream_url_.is_empty()) {
- StreamRegistry* stream_registry =
- GetStreamContextForResourceContext(resource_context_)->registry();
- stream_registry->RemoveRegisterObserver(waiting_stream_url_);
- stream_registry->AbortPendingStream(waiting_stream_url_);
- }
+ ClearStream();
fetch_dispatcher_.reset();
blob_request_.reset();
weak_factory_.InvalidateWeakPtrs();
@@ -341,6 +327,7 @@ void ServiceWorkerURLRequestJob::GetExtraResponseInfo(
ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() {
+ ClearStream();
}
void ServiceWorkerURLRequestJob::MaybeStartRequest() {
@@ -539,7 +526,8 @@ void ServiceWorkerURLRequestJob::DidDispatchFetchEvent(
if (response.stream_url.is_valid()) {
DCHECK(response.blob_uuid.empty());
DCHECK(provider_host_->active_version());
- provider_host_->active_version()->AddStreamingURLRequestJob(this);
+ streaming_version_ = provider_host_->active_version();
+ streaming_version_->AddStreamingURLRequestJob(this);
response_url_ = response.url;
service_worker_response_type_ = response.response_type;
CreateResponseHeader(
@@ -619,4 +607,22 @@ void ServiceWorkerURLRequestJob::DeliverErrorResponse() {
CommitResponseHeader();
}
+void ServiceWorkerURLRequestJob::ClearStream() {
+ if (streaming_version_) {
+ streaming_version_->RemoveStreamingURLRequestJob(this);
+ streaming_version_ = nullptr;
+ }
+ if (stream_) {
+ stream_->RemoveReadObserver(this);
+ stream_->Abort();
+ stream_ = nullptr;
+ }
+ if (!waiting_stream_url_.is_empty()) {
+ StreamRegistry* stream_registry =
+ GetStreamContextForResourceContext(resource_context_)->registry();
+ stream_registry->RemoveRegisterObserver(waiting_stream_url_);
+ stream_registry->AbortPendingStream(waiting_stream_url_);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698