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

Side by Side Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 739383002: Don't drop messages/events send to a service worker that is stopping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@termnate_sw
Patch Set: address nit Created 6 years 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
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/browser/service_worker/embedded_worker_instance.h" 5 #include "content/browser/service_worker/embedded_worker_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 DCHECK(status_ == STARTING); 284 DCHECK(status_ == STARTING);
285 status_ = RUNNING; 285 status_ = RUNNING;
286 FOR_EACH_OBSERVER(Listener, listener_list_, OnStarted()); 286 FOR_EACH_OBSERVER(Listener, listener_list_, OnStarted());
287 } 287 }
288 288
289 void EmbeddedWorkerInstance::OnStopped() { 289 void EmbeddedWorkerInstance::OnStopped() {
290 if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE) 290 if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE)
291 NotifyWorkerDestroyed(process_id_, worker_devtools_agent_route_id_); 291 NotifyWorkerDestroyed(process_id_, worker_devtools_agent_route_id_);
292 if (context_) 292 if (context_)
293 context_->process_manager()->ReleaseWorkerProcess(embedded_worker_id_); 293 context_->process_manager()->ReleaseWorkerProcess(embedded_worker_id_);
294 Status old_status = status_;
294 status_ = STOPPED; 295 status_ = STOPPED;
295 process_id_ = -1; 296 process_id_ = -1;
296 thread_id_ = -1; 297 thread_id_ = -1;
297 worker_devtools_agent_route_id_ = MSG_ROUTING_NONE; 298 worker_devtools_agent_route_id_ = MSG_ROUTING_NONE;
298 start_callback_.Reset(); 299 start_callback_.Reset();
299 FOR_EACH_OBSERVER(Listener, listener_list_, OnStopped()); 300 FOR_EACH_OBSERVER(Listener, listener_list_, OnStopped(old_status));
300 } 301 }
301 302
302 void EmbeddedWorkerInstance::OnPausedAfterDownload() { 303 void EmbeddedWorkerInstance::OnPausedAfterDownload() {
303 // Stop can be requested before getting this far. 304 // Stop can be requested before getting this far.
304 if (status_ == STOPPING) 305 if (status_ == STOPPING)
305 return; 306 return;
306 DCHECK(status_ == STARTING); 307 DCHECK(status_ == STARTING);
307 FOR_EACH_OBSERVER(Listener, listener_list_, OnPausedAfterDownload()); 308 FOR_EACH_OBSERVER(Listener, listener_list_, OnPausedAfterDownload());
308 } 309 }
309 310
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 348
348 void EmbeddedWorkerInstance::AddListener(Listener* listener) { 349 void EmbeddedWorkerInstance::AddListener(Listener* listener) {
349 listener_list_.AddObserver(listener); 350 listener_list_.AddObserver(listener);
350 } 351 }
351 352
352 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) { 353 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) {
353 listener_list_.RemoveObserver(listener); 354 listener_list_.RemoveObserver(listener);
354 } 355 }
355 356
356 } // namespace content 357 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698