| 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 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 5 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
| 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "content/browser/worker_host/worker_process_host.h" | 13 #include "content/browser/worker_host/worker_process_host.h" |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/worker_service.h" | 15 #include "content/public/browser/worker_service.h" |
| 17 | 16 |
| 18 class GURL; | 17 class GURL; |
| 19 struct ViewHostMsg_CreateWorker_Params; | 18 struct ViewHostMsg_CreateWorker_Params; |
| 20 | 19 |
| 21 namespace content { | 20 namespace content { |
| 22 class ResourceContext; | 21 class ResourceContext; |
| 23 class WorkerServiceObserver; | 22 class WorkerServiceObserver; |
| 24 class WorkerStoragePartition; | 23 class WorkerStoragePartition; |
| 25 class WorkerPrioritySetter; | |
| 26 | 24 |
| 27 class CONTENT_EXPORT WorkerServiceImpl | 25 class CONTENT_EXPORT WorkerServiceImpl |
| 28 : public NON_EXPORTED_BASE(WorkerService) { | 26 : public NON_EXPORTED_BASE(WorkerService) { |
| 29 public: | 27 public: |
| 30 // Returns the WorkerServiceImpl singleton. | 28 // Returns the WorkerServiceImpl singleton. |
| 31 static WorkerServiceImpl* GetInstance(); | 29 static WorkerServiceImpl* GetInstance(); |
| 32 | 30 |
| 33 // WorkerService implementation: | 31 // WorkerService implementation: |
| 34 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; | 32 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; |
| 35 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; | 33 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool GetRendererForWorker(int worker_process_id, | 65 bool GetRendererForWorker(int worker_process_id, |
| 68 int* render_process_id, | 66 int* render_process_id, |
| 69 int* render_view_id) const; | 67 int* render_view_id) const; |
| 70 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( | 68 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( |
| 71 int worker_process_id); | 69 int worker_process_id); |
| 72 | 70 |
| 73 void NotifyWorkerDestroyed( | 71 void NotifyWorkerDestroyed( |
| 74 WorkerProcessHost* process, | 72 WorkerProcessHost* process, |
| 75 int worker_route_id); | 73 int worker_route_id); |
| 76 | 74 |
| 77 void NotifyWorkerProcessCreated(); | |
| 78 | |
| 79 // Used when we run each worker in a separate process. | 75 // Used when we run each worker in a separate process. |
| 80 static const int kMaxWorkersWhenSeparate; | 76 static const int kMaxWorkersWhenSeparate; |
| 81 static const int kMaxWorkersPerTabWhenSeparate; | 77 static const int kMaxWorkersPerTabWhenSeparate; |
| 82 | 78 |
| 83 private: | 79 private: |
| 84 friend struct DefaultSingletonTraits<WorkerServiceImpl>; | 80 friend struct DefaultSingletonTraits<WorkerServiceImpl>; |
| 85 | 81 |
| 86 WorkerServiceImpl(); | 82 WorkerServiceImpl(); |
| 87 virtual ~WorkerServiceImpl(); | 83 virtual ~WorkerServiceImpl(); |
| 88 | 84 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 119 const string16& name, | 115 const string16& name, |
| 120 const WorkerStoragePartition& worker_partition, | 116 const WorkerStoragePartition& worker_partition, |
| 121 ResourceContext* resource_context); | 117 ResourceContext* resource_context); |
| 122 | 118 |
| 123 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( | 119 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( |
| 124 const GURL& url, | 120 const GURL& url, |
| 125 const string16& name, | 121 const string16& name, |
| 126 const WorkerStoragePartition& worker_partition, | 122 const WorkerStoragePartition& worker_partition, |
| 127 ResourceContext* resource_context); | 123 ResourceContext* resource_context); |
| 128 | 124 |
| 129 scoped_refptr<WorkerPrioritySetter> priority_setter_; | 125 NotificationRegistrar registrar_; |
| 130 | |
| 131 int next_worker_route_id_; | 126 int next_worker_route_id_; |
| 132 | 127 |
| 133 WorkerProcessHost::Instances queued_workers_; | 128 WorkerProcessHost::Instances queued_workers_; |
| 134 | 129 |
| 135 // These are shared workers that have been looked up, but not created yet. | 130 // These are shared workers that have been looked up, but not created yet. |
| 136 // We need to keep a list of these to synchronously detect shared worker | 131 // We need to keep a list of these to synchronously detect shared worker |
| 137 // URL mismatches when two pages launch shared workers simultaneously. | 132 // URL mismatches when two pages launch shared workers simultaneously. |
| 138 WorkerProcessHost::Instances pending_shared_workers_; | 133 WorkerProcessHost::Instances pending_shared_workers_; |
| 139 | 134 |
| 140 ObserverList<WorkerServiceObserver> observers_; | 135 ObserverList<WorkerServiceObserver> observers_; |
| 141 | 136 |
| 142 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); | 137 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); |
| 143 }; | 138 }; |
| 144 | 139 |
| 145 } // namespace content | 140 } // namespace content |
| 146 | 141 |
| 147 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 142 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
| OLD | NEW |