| 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_service_impl.h" | 5 #include "content/browser/shared_worker/shared_worker_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 std::vector<WorkerService::WorkerInfo> results; | 271 std::vector<WorkerService::WorkerInfo> results; |
| 272 for (const auto& iter : worker_hosts_) { | 272 for (const auto& iter : worker_hosts_) { |
| 273 SharedWorkerHost* host = iter.second.get(); | 273 SharedWorkerHost* host = iter.second.get(); |
| 274 const SharedWorkerInstance* instance = host->instance(); | 274 const SharedWorkerInstance* instance = host->instance(); |
| 275 if (instance) { | 275 if (instance) { |
| 276 WorkerService::WorkerInfo info; | 276 WorkerService::WorkerInfo info; |
| 277 info.url = instance->url(); | 277 info.url = instance->url(); |
| 278 info.name = instance->name(); | 278 info.name = instance->name(); |
| 279 info.route_id = host->worker_route_id(); | 279 info.route_id = host->worker_route_id(); |
| 280 info.process_id = host->process_id(); | 280 info.process_id = host->process_id(); |
| 281 info.handle = host->container_render_filter()->PeerHandle(); | 281 info.handle = host->worker_render_filter()->PeerHandle(); |
| 282 results.push_back(info); | 282 results.push_back(info); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 return results; | 285 return results; |
| 286 } | 286 } |
| 287 | 287 |
| 288 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { | 288 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { |
| 289 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 289 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 290 observers_.AddObserver(observer); | 290 observers_.AddObserver(observer); |
| 291 } | 291 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 if (SharedWorkerHost* host = | 355 if (SharedWorkerHost* host = |
| 356 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) | 356 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) |
| 357 host->WorkerContextClosed(); | 357 host->WorkerContextClosed(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void SharedWorkerServiceImpl::WorkerContextDestroyed( | 360 void SharedWorkerServiceImpl::WorkerContextDestroyed( |
| 361 int worker_route_id, | 361 int worker_route_id, |
| 362 SharedWorkerMessageFilter* filter) { | 362 SharedWorkerMessageFilter* filter) { |
| 363 ScopedWorkerDependencyChecker checker(this); | 363 ScopedWorkerDependencyChecker checker(this); |
| 364 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id); | 364 ProcessRouteIdPair key(filter->render_process_id(), worker_route_id); |
| 365 if (!base::ContainsKey(worker_hosts_, key)) | |
| 366 return; | |
| 367 std::unique_ptr<SharedWorkerHost> host(worker_hosts_[key].release()); | |
| 368 worker_hosts_.erase(key); | 365 worker_hosts_.erase(key); |
| 369 host->WorkerContextDestroyed(); | |
| 370 } | 366 } |
| 371 | 367 |
| 372 void SharedWorkerServiceImpl::WorkerReadyForInspection( | 368 void SharedWorkerServiceImpl::WorkerReadyForInspection( |
| 373 int worker_route_id, | 369 int worker_route_id, |
| 374 SharedWorkerMessageFilter* filter) { | 370 SharedWorkerMessageFilter* filter) { |
| 375 if (SharedWorkerHost* host = | 371 if (SharedWorkerHost* host = |
| 376 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) | 372 FindSharedWorkerHost(filter->render_process_id(), worker_route_id)) |
| 377 host->WorkerReadyForInspection(); | 373 host->WorkerReadyForInspection(); |
| 378 } | 374 } |
| 379 | 375 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 UpdateWorkerDependencyFunc new_func) { | 670 UpdateWorkerDependencyFunc new_func) { |
| 675 update_worker_dependency_ = new_func; | 671 update_worker_dependency_ = new_func; |
| 676 } | 672 } |
| 677 | 673 |
| 678 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 674 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
| 679 bool (*new_func)(int)) { | 675 bool (*new_func)(int)) { |
| 680 s_try_increment_worker_ref_count_ = new_func; | 676 s_try_increment_worker_ref_count_ = new_func; |
| 681 } | 677 } |
| 682 | 678 |
| 683 } // namespace content | 679 } // namespace content |
| OLD | NEW |