| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shared_worker/shared_worker_host.h" | 5 #include "content/browser/shared_worker/shared_worker_host.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 8 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
| 9 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
| 10 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (!instance_) | 125 if (!instance_) |
| 126 return; | 126 return; |
| 127 // Walk all instances and remove the document from their document set. | 127 // Walk all instances and remove the document from their document set. |
| 128 worker_document_set_->Remove(filter, document_id); | 128 worker_document_set_->Remove(filter, document_id); |
| 129 if (worker_document_set_->IsEmpty()) { | 129 if (worker_document_set_->IsEmpty()) { |
| 130 // This worker has no more associated documents - shut it down. | 130 // This worker has no more associated documents - shut it down. |
| 131 TerminateWorker(); | 131 TerminateWorker(); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 void SharedWorkerHost::DetachAllDocument(SharedWorkerMessageFilter* filter) { |
| 136 if (!instance_) |
| 137 return; |
| 138 // Walk all instances and remove the all documents from their document set. |
| 139 worker_document_set_->RemoveAll(filter); |
| 140 if (worker_document_set_->IsEmpty()) { |
| 141 // This worker has no more associated documents - shut it down. |
| 142 TerminateWorker(); |
| 143 } |
| 144 } |
| 145 |
| 135 void SharedWorkerHost::WorkerContextClosed() { | 146 void SharedWorkerHost::WorkerContextClosed() { |
| 136 if (!instance_) | 147 if (!instance_) |
| 137 return; | 148 return; |
| 138 // Set the closed flag - this will stop any further messages from | 149 // Set the closed flag - this will stop any further messages from |
| 139 // being sent to the worker (messages can still be sent from the worker, | 150 // being sent to the worker (messages can still be sent from the worker, |
| 140 // for exception reporting, etc). | 151 // for exception reporting, etc). |
| 141 closed_ = true; | 152 closed_ = true; |
| 142 if (!termination_message_sent_) | 153 if (!termination_message_sent_) |
| 143 NotifyWorkerDestroyed(worker_process_id_, worker_route_id_); | 154 NotifyWorkerDestroyed(worker_process_id_, worker_route_id_); |
| 144 } | 155 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 int message_port_id) { | 322 int message_port_id) { |
| 312 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { | 323 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { |
| 313 if (i->filter() == filter && i->route_id() == route_id) { | 324 if (i->filter() == filter && i->route_id() == route_id) { |
| 314 i->set_message_port_id(message_port_id); | 325 i->set_message_port_id(message_port_id); |
| 315 return; | 326 return; |
| 316 } | 327 } |
| 317 } | 328 } |
| 318 } | 329 } |
| 319 | 330 |
| 320 } // namespace content | 331 } // namespace content |
| OLD | NEW |