OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/worker_host/worker_service_impl.h" | 5 #include "content/browser/worker_host/worker_service_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 FOR_EACH_OBSERVER(WorkerServiceObserver, observers_, | 643 FOR_EACH_OBSERVER(WorkerServiceObserver, observers_, |
644 WorkerDestroyed(process->GetData().id, worker_route_id)); | 644 WorkerDestroyed(process->GetData().id, worker_route_id)); |
645 } | 645 } |
646 | 646 |
647 void WorkerServiceImpl::NotifyWorkerProcessCreated() { | 647 void WorkerServiceImpl::NotifyWorkerProcessCreated() { |
648 priority_setter_->NotifyWorkerProcessCreated(); | 648 priority_setter_->NotifyWorkerProcessCreated(); |
649 } | 649 } |
650 | 650 |
651 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindSharedWorkerInstance( | 651 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindSharedWorkerInstance( |
652 const GURL& url, | 652 const GURL& url, |
653 const string16& name, | 653 const base::string16& name, |
654 const WorkerStoragePartition& partition, | 654 const WorkerStoragePartition& partition, |
655 ResourceContext* resource_context) { | 655 ResourceContext* resource_context) { |
656 for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { | 656 for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { |
657 for (WorkerProcessHost::Instances::iterator instance_iter = | 657 for (WorkerProcessHost::Instances::iterator instance_iter = |
658 iter->mutable_instances().begin(); | 658 iter->mutable_instances().begin(); |
659 instance_iter != iter->mutable_instances().end(); | 659 instance_iter != iter->mutable_instances().end(); |
660 ++instance_iter) { | 660 ++instance_iter) { |
661 if (instance_iter->Matches(url, name, partition, resource_context)) | 661 if (instance_iter->Matches(url, name, partition, resource_context)) |
662 return &(*instance_iter); | 662 return &(*instance_iter); |
663 } | 663 } |
664 } | 664 } |
665 return NULL; | 665 return NULL; |
666 } | 666 } |
667 | 667 |
668 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindPendingInstance( | 668 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindPendingInstance( |
669 const GURL& url, | 669 const GURL& url, |
670 const string16& name, | 670 const base::string16& name, |
671 const WorkerStoragePartition& partition, | 671 const WorkerStoragePartition& partition, |
672 ResourceContext* resource_context) { | 672 ResourceContext* resource_context) { |
673 // Walk the pending instances looking for a matching pending worker. | 673 // Walk the pending instances looking for a matching pending worker. |
674 for (WorkerProcessHost::Instances::iterator iter = | 674 for (WorkerProcessHost::Instances::iterator iter = |
675 pending_shared_workers_.begin(); | 675 pending_shared_workers_.begin(); |
676 iter != pending_shared_workers_.end(); | 676 iter != pending_shared_workers_.end(); |
677 ++iter) { | 677 ++iter) { |
678 if (iter->Matches(url, name, partition, resource_context)) | 678 if (iter->Matches(url, name, partition, resource_context)) |
679 return &(*iter); | 679 return &(*iter); |
680 } | 680 } |
681 return NULL; | 681 return NULL; |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 void WorkerServiceImpl::RemovePendingInstances( | 685 void WorkerServiceImpl::RemovePendingInstances( |
686 const GURL& url, | 686 const GURL& url, |
687 const string16& name, | 687 const base::string16& name, |
688 const WorkerStoragePartition& partition, | 688 const WorkerStoragePartition& partition, |
689 ResourceContext* resource_context) { | 689 ResourceContext* resource_context) { |
690 // Walk the pending instances looking for a matching pending worker. | 690 // Walk the pending instances looking for a matching pending worker. |
691 for (WorkerProcessHost::Instances::iterator iter = | 691 for (WorkerProcessHost::Instances::iterator iter = |
692 pending_shared_workers_.begin(); | 692 pending_shared_workers_.begin(); |
693 iter != pending_shared_workers_.end(); ) { | 693 iter != pending_shared_workers_.end(); ) { |
694 if (iter->Matches(url, name, partition, resource_context)) { | 694 if (iter->Matches(url, name, partition, resource_context)) { |
695 iter = pending_shared_workers_.erase(iter); | 695 iter = pending_shared_workers_.erase(iter); |
696 } else { | 696 } else { |
697 ++iter; | 697 ++iter; |
698 } | 698 } |
699 } | 699 } |
700 } | 700 } |
701 | 701 |
702 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::CreatePendingInstance( | 702 WorkerProcessHost::WorkerInstance* WorkerServiceImpl::CreatePendingInstance( |
703 const GURL& url, | 703 const GURL& url, |
704 const string16& name, | 704 const base::string16& name, |
705 ResourceContext* resource_context, | 705 ResourceContext* resource_context, |
706 const WorkerStoragePartition& partition) { | 706 const WorkerStoragePartition& partition) { |
707 // Look for an existing pending shared worker. | 707 // Look for an existing pending shared worker. |
708 WorkerProcessHost::WorkerInstance* instance = | 708 WorkerProcessHost::WorkerInstance* instance = |
709 FindPendingInstance(url, name, partition, resource_context); | 709 FindPendingInstance(url, name, partition, resource_context); |
710 if (instance) | 710 if (instance) |
711 return instance; | 711 return instance; |
712 | 712 |
713 // No existing pending worker - create a new one. | 713 // No existing pending worker - create a new one. |
714 WorkerProcessHost::WorkerInstance pending( | 714 WorkerProcessHost::WorkerInstance pending( |
715 url, true, name, resource_context, partition); | 715 url, true, name, resource_context, partition); |
716 pending_shared_workers_.push_back(pending); | 716 pending_shared_workers_.push_back(pending); |
717 return &pending_shared_workers_.back(); | 717 return &pending_shared_workers_.back(); |
718 } | 718 } |
719 | 719 |
720 } // namespace content | 720 } // namespace content |
OLD | NEW |