OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
6 #define CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 6 #define CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Used when we run each worker in a separate process. | 80 // Used when we run each worker in a separate process. |
81 static const int kMaxWorkersWhenSeparate; | 81 static const int kMaxWorkersWhenSeparate; |
82 static const int kMaxWorkersPerTabWhenSeparate; | 82 static const int kMaxWorkersPerTabWhenSeparate; |
83 | 83 |
84 private: | 84 private: |
85 friend struct DefaultSingletonTraits<WorkerService>; | 85 friend struct DefaultSingletonTraits<WorkerService>; |
86 | 86 |
87 WorkerService(); | 87 WorkerService(); |
88 ~WorkerService(); | 88 ~WorkerService(); |
89 | 89 |
| 90 // Given a WorkerInstance, create an associated worker process. |
| 91 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); |
| 92 |
90 // Returns a WorkerProcessHost object if one exists for the given domain, or | 93 // Returns a WorkerProcessHost object if one exists for the given domain, or |
91 // NULL if there are no such workers yet. | 94 // NULL if there are no such workers yet. |
92 WorkerProcessHost* GetProcessForDomain(const GURL& url); | 95 WorkerProcessHost* GetProcessForDomain(const GURL& url); |
93 | 96 |
94 // Returns a WorkerProcessHost based on a strategy of creating one worker per | 97 // Returns a WorkerProcessHost based on a strategy of creating one worker per |
95 // core. | 98 // core. |
96 WorkerProcessHost* GetProcessToFillUpCores(); | 99 WorkerProcessHost* GetProcessToFillUpCores(); |
97 | 100 |
98 // Returns the WorkerProcessHost from the existing set that has the least | 101 // Returns the WorkerProcessHost from the existing set that has the least |
99 // number of worker instance running. | 102 // number of worker instance running. |
(...skipping 19 matching lines...) Expand all Loading... |
119 void SenderShutdown(IPC::Message::Sender* sender); | 122 void SenderShutdown(IPC::Message::Sender* sender); |
120 | 123 |
121 // Notifies us that a worker process has closed. | 124 // Notifies us that a worker process has closed. |
122 void WorkerProcessDestroyed(WorkerProcessHost* process); | 125 void WorkerProcessDestroyed(WorkerProcessHost* process); |
123 | 126 |
124 // APIs for manipulating our set of pending shared worker instances. | 127 // APIs for manipulating our set of pending shared worker instances. |
125 WorkerProcessHost::WorkerInstance* CreatePendingInstance( | 128 WorkerProcessHost::WorkerInstance* CreatePendingInstance( |
126 const GURL& url, const string16& name, bool off_the_record); | 129 const GURL& url, const string16& name, bool off_the_record); |
127 WorkerProcessHost::WorkerInstance* FindPendingInstance( | 130 WorkerProcessHost::WorkerInstance* FindPendingInstance( |
128 const GURL& url, const string16& name, bool off_the_record); | 131 const GURL& url, const string16& name, bool off_the_record); |
129 void RemovePendingInstance( | 132 void RemovePendingInstances( |
130 const GURL& url, const string16& name, bool off_the_record); | 133 const GURL& url, const string16& name, bool off_the_record); |
131 | 134 |
132 NotificationRegistrar registrar_; | 135 NotificationRegistrar registrar_; |
133 int next_worker_route_id_; | 136 int next_worker_route_id_; |
134 ResourceDispatcherHost* resource_dispatcher_host_; | 137 ResourceDispatcherHost* resource_dispatcher_host_; |
135 | 138 |
136 WorkerProcessHost::Instances queued_workers_; | 139 WorkerProcessHost::Instances queued_workers_; |
137 | 140 |
138 // These are shared workers that have been looked up, but not created yet. | 141 // 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 | 142 // We need to keep a list of these to synchronously detect shared worker |
140 // URL mismatches when two pages launch shared workers simultaneously. | 143 // URL mismatches when two pages launch shared workers simultaneously. |
141 WorkerProcessHost::Instances pending_shared_workers_; | 144 WorkerProcessHost::Instances pending_shared_workers_; |
142 | 145 |
143 DISALLOW_COPY_AND_ASSIGN(WorkerService); | 146 DISALLOW_COPY_AND_ASSIGN(WorkerService); |
144 }; | 147 }; |
145 | 148 |
146 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 149 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
OLD | NEW |