OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.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/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class ResourceContext; | 19 class ResourceContext; |
20 } // namespace content | 20 } // namespace content |
21 namespace net { | 21 namespace net { |
22 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
23 } // namespace net | 23 } // namespace net |
24 class WorkerServiceObserver; | 24 class WorkerServiceObserver; |
25 struct ViewHostMsg_CreateWorker_Params; | 25 struct ViewHostMsg_CreateWorker_Params; |
26 | 26 |
27 // A singleton for managing HTML5 web workers. | 27 // A singleton for managing HTML5 web workers. |
28 class WorkerService { | 28 class CONTENT_EXPORT WorkerService { |
29 public: | 29 public: |
30 // Returns the WorkerService singleton. | 30 // Returns the WorkerService singleton. |
31 static WorkerService* GetInstance(); | 31 static WorkerService* GetInstance(); |
32 | 32 |
33 // These methods correspond to worker related IPCs. | 33 // These methods correspond to worker related IPCs. |
34 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, | 34 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, |
35 int route_id, | 35 int route_id, |
36 WorkerMessageFilter* filter, | 36 WorkerMessageFilter* filter, |
37 const content::ResourceContext& resource_context); | 37 const content::ResourceContext& resource_context); |
38 void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params, | 38 void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params, |
(...skipping 30 matching lines...) Expand all Loading... |
69 WorkerProcessHost* process, | 69 WorkerProcessHost* process, |
70 int worker_route_id); | 70 int worker_route_id); |
71 void NotifyWorkerContextStarted( | 71 void NotifyWorkerContextStarted( |
72 WorkerProcessHost* process, | 72 WorkerProcessHost* process, |
73 int worker_route_id); | 73 int worker_route_id); |
74 | 74 |
75 // Used when multiple workers can run in the same process. | 75 // Used when multiple workers can run in the same process. |
76 static const int kMaxWorkerProcessesWhenSharing; | 76 static const int kMaxWorkerProcessesWhenSharing; |
77 | 77 |
78 // Used when we run each worker in a separate process. | 78 // Used when we run each worker in a separate process. |
79 CONTENT_EXPORT static const int kMaxWorkersWhenSeparate; | 79 static const int kMaxWorkersWhenSeparate; |
80 CONTENT_EXPORT static const int kMaxWorkersPerTabWhenSeparate; | 80 static const int kMaxWorkersPerTabWhenSeparate; |
81 | 81 |
82 private: | 82 private: |
83 friend struct DefaultSingletonTraits<WorkerService>; | 83 friend struct DefaultSingletonTraits<WorkerService>; |
84 | 84 |
85 WorkerService(); | 85 WorkerService(); |
86 ~WorkerService(); | 86 ~WorkerService(); |
87 | 87 |
88 // Given a WorkerInstance, create an associated worker process. | 88 // Given a WorkerInstance, create an associated worker process. |
89 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); | 89 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); |
90 | 90 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // We need to keep a list of these to synchronously detect shared worker | 142 // We need to keep a list of these to synchronously detect shared worker |
143 // URL mismatches when two pages launch shared workers simultaneously. | 143 // URL mismatches when two pages launch shared workers simultaneously. |
144 WorkerProcessHost::Instances pending_shared_workers_; | 144 WorkerProcessHost::Instances pending_shared_workers_; |
145 | 145 |
146 ObserverList<WorkerServiceObserver> observers_; | 146 ObserverList<WorkerServiceObserver> observers_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(WorkerService); | 148 DISALLOW_COPY_AND_ASSIGN(WorkerService); |
149 }; | 149 }; |
150 | 150 |
151 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 151 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
OLD | NEW |