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

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

Issue 2430403005: ServiceWorker: check if StopWorker is called twice (Closed)
Patch Set: Removed obvious DCHECKs Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/renderer/service_worker/embedded_worker_dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_instance_client_impl.h " 5 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h "
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/child/scoped_child_process_reference.h" 10 #include "content/child/scoped_child_process_reference.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 params.script_url, params.worker_devtools_agent_route_id, 62 params.script_url, params.worker_devtools_agent_route_id,
63 std::move(temporal_self_))); 63 std::move(temporal_self_)));
64 wrapper_ = wrapper.get(); 64 wrapper_ = wrapper.get();
65 dispatcher_->RegisterWorker(params.embedded_worker_id, std::move(wrapper)); 65 dispatcher_->RegisterWorker(params.embedded_worker_id, std::move(wrapper));
66 } 66 }
67 67
68 void EmbeddedWorkerInstanceClientImpl::StopWorker( 68 void EmbeddedWorkerInstanceClientImpl::StopWorker(
69 const StopWorkerCallback& callback) { 69 const StopWorkerCallback& callback) {
70 DCHECK(ChildThreadImpl::current()); 70 DCHECK(ChildThreadImpl::current());
71 DCHECK(embedded_worker_id_); 71 DCHECK(embedded_worker_id_);
72 DCHECK(!stop_callback_); 72 // StopWorker is possible to be called twice.
73 if (stop_callback_) {
74 LOG(WARNING) << "Got StopWorker for stopping worker";
75 return;
76 }
73 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstanceClientImpl::StopWorker"); 77 TRACE_EVENT0("ServiceWorker", "EmbeddedWorkerInstanceClientImpl::StopWorker");
74 stop_callback_ = std::move(callback); 78 stop_callback_ = std::move(callback);
75 dispatcher_->RecordStopWorkerTimer(embedded_worker_id_.value()); 79 dispatcher_->RecordStopWorkerTimer(embedded_worker_id_.value());
76 wrapper_->worker()->terminateWorkerContext(); 80 wrapper_->worker()->terminateWorkerContext();
77 } 81 }
78 82
79 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl( 83 EmbeddedWorkerInstanceClientImpl::EmbeddedWorkerInstanceClientImpl(
80 EmbeddedWorkerDispatcher* dispatcher, 84 EmbeddedWorkerDispatcher* dispatcher,
81 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request) 85 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request)
82 : dispatcher_(dispatcher), 86 : dispatcher_(dispatcher),
83 binding_(this, std::move(request)), 87 binding_(this, std::move(request)),
84 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)) { 88 temporal_self_(std::unique_ptr<EmbeddedWorkerInstanceClientImpl>(this)) {
85 binding_.set_connection_error_handler(base::Bind( 89 binding_.set_connection_error_handler(base::Bind(
86 &EmbeddedWorkerInstanceClientImpl::OnError, base::Unretained(this))); 90 &EmbeddedWorkerInstanceClientImpl::OnError, base::Unretained(this)));
87 } 91 }
88 92
89 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {} 93 EmbeddedWorkerInstanceClientImpl::~EmbeddedWorkerInstanceClientImpl() {}
90 94
91 void EmbeddedWorkerInstanceClientImpl::OnError() { 95 void EmbeddedWorkerInstanceClientImpl::OnError() {
92 // Removes myself if it's owned by myself. 96 // Removes myself if it's owned by myself.
93 temporal_self_.reset(); 97 temporal_self_.reset();
94 } 98 }
95 99
96 } // namespace content 100 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/embedded_worker_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698