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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) | 415 if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) |
416 host->AllowIndexedDB(url, name, result); | 416 host->AllowIndexedDB(url, name, result); |
417 else | 417 else |
418 *result = false; | 418 *result = false; |
419 } | 419 } |
420 | 420 |
421 void SharedWorkerServiceImpl::OnSharedWorkerMessageFilterClosing( | 421 void SharedWorkerServiceImpl::OnSharedWorkerMessageFilterClosing( |
422 SharedWorkerMessageFilter* filter) { | 422 SharedWorkerMessageFilter* filter) { |
423 ScopedWorkerDependencyChecker checker(this); | 423 ScopedWorkerDependencyChecker checker(this); |
424 std::vector<ProcessRouteIdPair> remove_list; | 424 std::vector<ProcessRouteIdPair> remove_list; |
425 for (WorkerHostMap::iterator iter = worker_hosts_.begin(); | 425 for (auto it : worker_hosts_) { |
426 iter != worker_hosts_.end(); | 426 it.second->FilterShutdown(filter); |
427 ++iter) { | 427 if (it.first.first == filter->render_process_id()) |
428 iter->second->FilterShutdown(filter); | 428 remove_list.push_back(it.first); |
429 if (iter->first.first == filter->render_process_id()) | |
430 remove_list.push_back(iter->first); | |
431 } | 429 } |
432 for (size_t i = 0; i < remove_list.size(); ++i) { | 430 for (ProcessRouteIdPair& to_remove : remove_list) { |
433 std::unique_ptr<SharedWorkerHost> host = | 431 std::unique_ptr<SharedWorkerHost> host = |
434 worker_hosts_.take_and_erase(remove_list[i]); | 432 worker_hosts_.take_and_erase(to_remove); |
435 } | 433 } |
436 | 434 |
437 std::vector<int> remove_pending_instance_list; | 435 std::vector<int> remove_pending_instance_list; |
438 for (PendingInstanceMap::iterator iter = pending_instances_.begin(); | 436 for (auto it : pending_instances_) { |
439 iter != pending_instances_.end(); ++iter) { | 437 it.second->RemoveRequest(filter->render_process_id()); |
440 iter->second->RemoveRequest(filter->render_process_id()); | 438 if (it.second->requests()->empty()) |
441 if (!iter->second->requests()->size()) | 439 remove_pending_instance_list.push_back(it.first); |
442 remove_pending_instance_list.push_back(iter->first); | |
443 } | 440 } |
444 for (size_t i = 0; i < remove_pending_instance_list.size(); ++i) | 441 for (int to_remove : remove_pending_instance_list) |
445 pending_instances_.take_and_erase(remove_pending_instance_list[i]); | 442 pending_instances_.take_and_erase(to_remove); |
446 } | 443 } |
447 | 444 |
448 void SharedWorkerServiceImpl::NotifyWorkerDestroyed(int worker_process_id, | 445 void SharedWorkerServiceImpl::NotifyWorkerDestroyed(int worker_process_id, |
449 int worker_route_id) { | 446 int worker_route_id) { |
450 FOR_EACH_OBSERVER(WorkerServiceObserver, | 447 FOR_EACH_OBSERVER(WorkerServiceObserver, |
451 observers_, | 448 observers_, |
452 WorkerDestroyed(worker_process_id, worker_route_id)); | 449 WorkerDestroyed(worker_process_id, worker_route_id)); |
453 } | 450 } |
454 | 451 |
455 void SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker( | 452 void SharedWorkerServiceImpl::ReserveRenderProcessToCreateWorker( |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 UpdateWorkerDependencyFunc new_func) { | 646 UpdateWorkerDependencyFunc new_func) { |
650 update_worker_dependency_ = new_func; | 647 update_worker_dependency_ = new_func; |
651 } | 648 } |
652 | 649 |
653 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( | 650 void SharedWorkerServiceImpl::ChangeTryIncrementWorkerRefCountFuncForTesting( |
654 bool (*new_func)(int)) { | 651 bool (*new_func)(int)) { |
655 s_try_increment_worker_ref_count_ = new_func; | 652 s_try_increment_worker_ref_count_ = new_func; |
656 } | 653 } |
657 | 654 |
658 } // namespace content | 655 } // namespace content |
OLD | NEW |