| 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_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/worker_service.h" | 15 #include "content/public/browser/worker_service.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 class WorkerStoragePartition; |
| 18 struct ViewHostMsg_CreateWorker_Params; | 19 struct ViewHostMsg_CreateWorker_Params; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class ResourceContext; | 22 class ResourceContext; |
| 22 class WorkerServiceObserver; | 23 class WorkerServiceObserver; |
| 23 | 24 |
| 24 class CONTENT_EXPORT WorkerServiceImpl | 25 class CONTENT_EXPORT WorkerServiceImpl |
| 25 : public NON_EXPORTED_BASE(WorkerService) { | 26 : public NON_EXPORTED_BASE(WorkerService) { |
| 26 public: | 27 public: |
| 27 // Returns the WorkerServiceImpl singleton. | 28 // Returns the WorkerServiceImpl singleton. |
| 28 static WorkerServiceImpl* GetInstance(); | 29 static WorkerServiceImpl* GetInstance(); |
| 29 | 30 |
| 30 // WorkerService implementation: | 31 // WorkerService implementation: |
| 31 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; | 32 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; |
| 32 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; | 33 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; |
| 33 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; | 34 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; |
| 34 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; | 35 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; |
| 35 | 36 |
| 36 // These methods correspond to worker related IPCs. | 37 // These methods correspond to worker related IPCs. |
| 37 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, | 38 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, |
| 38 int route_id, | 39 int route_id, |
| 39 WorkerMessageFilter* filter, | 40 WorkerMessageFilter* filter, |
| 40 ResourceContext* resource_context); | 41 ResourceContext* resource_context, |
| 42 const WorkerStoragePartition& worker_partition); |
| 41 void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params, | 43 void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params, |
| 42 int route_id, | 44 int route_id, |
| 43 WorkerMessageFilter* filter, | 45 WorkerMessageFilter* filter, |
| 44 ResourceContext* resource_context, | 46 ResourceContext* resource_context, |
| 47 const WorkerStoragePartition& worker_partition, |
| 45 bool* exists, | 48 bool* exists, |
| 46 bool* url_error); | 49 bool* url_error); |
| 47 void CancelCreateDedicatedWorker(int route_id, WorkerMessageFilter* filter); | 50 void CancelCreateDedicatedWorker(int route_id, WorkerMessageFilter* filter); |
| 48 void ForwardToWorker(const IPC::Message& message, | 51 void ForwardToWorker(const IPC::Message& message, |
| 49 WorkerMessageFilter* filter); | 52 WorkerMessageFilter* filter); |
| 50 void DocumentDetached(unsigned long long document_id, | 53 void DocumentDetached(unsigned long long document_id, |
| 51 WorkerMessageFilter* filter); | 54 WorkerMessageFilter* filter); |
| 52 | 55 |
| 53 void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter); | 56 void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter); |
| 54 | 57 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 bool TabCanCreateWorkerProcess( | 111 bool TabCanCreateWorkerProcess( |
| 109 int render_process_id, int render_route_id, bool* hit_total_worker_limit); | 112 int render_process_id, int render_route_id, bool* hit_total_worker_limit); |
| 110 | 113 |
| 111 // Tries to see if any of the queued workers can be created. | 114 // Tries to see if any of the queued workers can be created. |
| 112 void TryStartingQueuedWorker(); | 115 void TryStartingQueuedWorker(); |
| 113 | 116 |
| 114 // APIs for manipulating our set of pending shared worker instances. | 117 // APIs for manipulating our set of pending shared worker instances. |
| 115 WorkerProcessHost::WorkerInstance* CreatePendingInstance( | 118 WorkerProcessHost::WorkerInstance* CreatePendingInstance( |
| 116 const GURL& url, | 119 const GURL& url, |
| 117 const string16& name, | 120 const string16& name, |
| 118 ResourceContext* resource_context); | 121 ResourceContext* resource_context, |
| 122 const WorkerStoragePartition& worker_partition); |
| 119 WorkerProcessHost::WorkerInstance* FindPendingInstance( | 123 WorkerProcessHost::WorkerInstance* FindPendingInstance( |
| 120 const GURL& url, | 124 const GURL& url, |
| 121 const string16& name, | 125 const string16& name, |
| 126 const WorkerStoragePartition& worker_partition, |
| 122 ResourceContext* resource_context); | 127 ResourceContext* resource_context); |
| 123 void RemovePendingInstances( | 128 void RemovePendingInstances( |
| 124 const GURL& url, | 129 const GURL& url, |
| 125 const string16& name, | 130 const string16& name, |
| 131 const WorkerStoragePartition& worker_partition, |
| 126 ResourceContext* resource_context); | 132 ResourceContext* resource_context); |
| 127 | 133 |
| 128 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( | 134 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( |
| 129 const GURL& url, | 135 const GURL& url, |
| 130 const string16& name, | 136 const string16& name, |
| 137 const WorkerStoragePartition& worker_partition, |
| 131 ResourceContext* resource_context); | 138 ResourceContext* resource_context); |
| 132 | 139 |
| 133 NotificationRegistrar registrar_; | 140 NotificationRegistrar registrar_; |
| 134 int next_worker_route_id_; | 141 int next_worker_route_id_; |
| 135 | 142 |
| 136 WorkerProcessHost::Instances queued_workers_; | 143 WorkerProcessHost::Instances queued_workers_; |
| 137 | 144 |
| 138 // These are shared workers that have been looked up, but not created yet. | 145 // These are shared workers that have been looked up, but not created yet. |
| 139 // We need to keep a list of these to synchronously detect shared worker | 146 // We need to keep a list of these to synchronously detect shared worker |
| 140 // URL mismatches when two pages launch shared workers simultaneously. | 147 // URL mismatches when two pages launch shared workers simultaneously. |
| 141 WorkerProcessHost::Instances pending_shared_workers_; | 148 WorkerProcessHost::Instances pending_shared_workers_; |
| 142 | 149 |
| 143 ObserverList<WorkerServiceObserver> observers_; | 150 ObserverList<WorkerServiceObserver> observers_; |
| 144 | 151 |
| 145 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); | 152 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); |
| 146 }; | 153 }; |
| 147 | 154 |
| 148 } // namespace content | 155 } // namespace content |
| 149 | 156 |
| 150 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 157 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
| OLD | NEW |