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 bd5c9cfe0f4aaf96f7b24e384ac1b6fb9b375e8b..66e30f59c20ec6514db14b574ed945d41d8436a8 100644 |
--- a/content/browser/service_worker/embedded_worker_instance.cc |
+++ b/content/browser/service_worker/embedded_worker_instance.cc |
@@ -57,6 +57,20 @@ void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { |
worker_process_id, worker_route_id); |
} |
+void NotifyWorkerStopIgnored(int worker_process_id, int worker_route_id) { |
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
pfeldman
2014/12/15 05:57:04
This implies it can be called multiple threads, bu
pfeldman
2014/12/15 06:11:08
I can see you are following a pattern here, but th
kinuko
2014/12/15 06:39:14
This pattern is used pretty widely in content/brow
pfeldman
2014/12/15 07:05:04
Hm, I am surprised how widely it has spread. I thi
pfeldman
2014/12/15 07:18:42
I looked at the usages of the pattern and found ou
kinuko
2014/12/15 07:41:18
Is the reason you think so because this pattern gi
|
+ BrowserThread::PostTask(BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(NotifyWorkerStopIgnored, |
+ worker_process_id, |
+ worker_route_id)); |
+ return; |
+ } |
+ EmbeddedWorkerDevToolsManager::GetInstance()->WorkerStopIgnored( |
+ worker_process_id, worker_route_id); |
+} |
+ |
+ |
void RegisterToWorkerDevToolsManager( |
int process_id, |
const ServiceWorkerContextCore* service_worker_context, |
@@ -155,6 +169,14 @@ ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { |
return status; |
} |
+void EmbeddedWorkerInstance::StopIfIdle() { |
+ if (devtools_attached_) { |
+ NotifyWorkerStopIgnored(process_id_, worker_devtools_agent_route_id_); |
+ return; |
+ } |
+ Stop(); |
+} |
+ |
void EmbeddedWorkerInstance::ResumeAfterDownload() { |
DCHECK_EQ(STARTING, status_); |
registry_->Send( |
@@ -182,6 +204,7 @@ EmbeddedWorkerInstance::EmbeddedWorkerInstance( |
process_id_(-1), |
thread_id_(kInvalidEmbeddedWorkerThreadId), |
worker_devtools_agent_route_id_(MSG_ROUTING_NONE), |
+ devtools_attached_(false), |
weak_factory_(this) { |
} |