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

Side by Side Diff: content/renderer/service_worker/embedded_worker_dispatcher.cc

Issue 2430403005: ServiceWorker: check if StopWorker is called twice (Closed)
Patch Set: Removed obvious DCHECKs Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/service_worker/embedded_worker_instance_client_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" 5 #include "content/renderer/service_worker/embedded_worker_dispatcher.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 params, base::MakeUnique<ServiceWorkerContextClient>( 70 params, base::MakeUnique<ServiceWorkerContextClient>(
71 params.embedded_worker_id, params.service_worker_version_id, 71 params.embedded_worker_id, params.service_worker_version_id,
72 params.scope, params.script_url, 72 params.scope, params.script_url,
73 params.worker_devtools_agent_route_id, nullptr)); 73 params.worker_devtools_agent_route_id, nullptr));
74 RegisterWorker(params.embedded_worker_id, std::move(wrapper)); 74 RegisterWorker(params.embedded_worker_id, std::move(wrapper));
75 } 75 }
76 76
77 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) { 77 void EmbeddedWorkerDispatcher::OnStopWorker(int embedded_worker_id) {
78 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker"); 78 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerDispatcher::OnStopWorker");
79 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); 79 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id);
80 DCHECK(wrapper); 80 // OnStopWorker is possible to be called twice.
81 if (!wrapper) {
82 LOG(WARNING) << "Got OnStopWorker for nonexistent worker";
83 return;
84 }
81 // This should eventually call WorkerContextDestroyed. (We may need to post 85 // This should eventually call WorkerContextDestroyed. (We may need to post
82 // a delayed task to forcibly abort the worker context if we find it 86 // a delayed task to forcibly abort the worker context if we find it
83 // necessary) 87 // necessary)
84 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); 88 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now();
85 wrapper->worker()->terminateWorkerContext(); 89 wrapper->worker()->terminateWorkerContext();
86 } 90 }
87 91
88 void EmbeddedWorkerDispatcher::OnResumeAfterDownload(int embedded_worker_id) { 92 void EmbeddedWorkerDispatcher::OnResumeAfterDownload(int embedded_worker_id) {
89 TRACE_EVENT0("ServiceWorker", 93 TRACE_EVENT0("ServiceWorker",
90 "EmbeddedWorkerDispatcher::OnResumeAfterDownload"); 94 "EmbeddedWorkerDispatcher::OnResumeAfterDownload");
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) { 173 void EmbeddedWorkerDispatcher::RecordStopWorkerTimer(int embedded_worker_id) {
170 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id); 174 WorkerWrapper* wrapper = workers_.Lookup(embedded_worker_id);
171 DCHECK(wrapper); 175 DCHECK(wrapper);
172 // This should eventually call WorkerContextDestroyed. (We may need to post 176 // This should eventually call WorkerContextDestroyed. (We may need to post
173 // a delayed task to forcibly abort the worker context if we find it 177 // a delayed task to forcibly abort the worker context if we find it
174 // necessary) 178 // necessary)
175 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now(); 179 stop_worker_times_[embedded_worker_id] = base::TimeTicks::Now();
176 } 180 }
177 181
178 } // namespace content 182 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/service_worker/embedded_worker_instance_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698