| Index: content/browser/service_worker/embedded_worker_instance.cc
|
| diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc
|
| index a0c48cd25fcf2d7e7dcf2b6d0c9d7fa7a9a7c78b..d0db28120bb3ee108610b050756446478b8f6ace 100644
|
| --- a/content/browser/service_worker/embedded_worker_instance.cc
|
| +++ b/content/browser/service_worker/embedded_worker_instance.cc
|
| @@ -7,6 +7,7 @@
|
| #include <utility>
|
|
|
| #include "base/bind_helpers.h"
|
| +#include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/metrics/histogram_macros.h"
|
| @@ -482,6 +483,10 @@ void EmbeddedWorkerInstance::StopIfIdle() {
|
| devtools_proxy_->NotifyWorkerStopIgnored();
|
| return;
|
| }
|
| + if (external_ref_count_ > 0) {
|
| + LOG(WARNING) << "Skipped StopIfIdle due to external_ref_count_";
|
| + return;
|
| + }
|
| Stop();
|
| }
|
|
|
| @@ -531,6 +536,7 @@ EmbeddedWorkerInstance::EmbeddedWorkerInstance(
|
| thread_id_(kInvalidEmbeddedWorkerThreadId),
|
| devtools_attached_(false),
|
| network_accessed_for_script_(false),
|
| + external_ref_count_(0),
|
| weak_factory_(this) {}
|
|
|
| void EmbeddedWorkerInstance::OnProcessAllocated(
|
| @@ -726,6 +732,15 @@ void EmbeddedWorkerInstance::Detach() {
|
| OnDetached();
|
| }
|
|
|
| +void EmbeddedWorkerInstance::IncrementRefCount() {
|
| + ++external_ref_count_;
|
| +}
|
| +
|
| +void EmbeddedWorkerInstance::DecrementRefCount() {
|
| + DCHECK(external_ref_count_ > 0);
|
| + --external_ref_count_;
|
| +}
|
| +
|
| base::WeakPtr<EmbeddedWorkerInstance> EmbeddedWorkerInstance::AsWeakPtr() {
|
| return weak_factory_.GetWeakPtr();
|
| }
|
|
|