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 #include "chrome/browser/worker_host/worker_service.h" | 5 #include "chrome/browser/worker_host/worker_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/thread.h" | 10 #include "base/thread.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 const int WorkerService::kMaxWorkerProcessesWhenSharing = 10; | 21 const int WorkerService::kMaxWorkerProcessesWhenSharing = 10; |
22 const int WorkerService::kMaxWorkersWhenSeparate = 64; | 22 const int WorkerService::kMaxWorkersWhenSeparate = 64; |
23 const int WorkerService::kMaxWorkersPerTabWhenSeparate = 16; | 23 const int WorkerService::kMaxWorkersPerTabWhenSeparate = 16; |
24 | 24 |
25 WorkerService* WorkerService::GetInstance() { | 25 WorkerService* WorkerService::GetInstance() { |
26 return Singleton<WorkerService>::get(); | 26 return Singleton<WorkerService>::get(); |
27 } | 27 } |
28 | 28 |
29 WorkerService::WorkerService() | 29 WorkerService::WorkerService() |
30 : next_worker_route_id_(0), | 30 : next_worker_route_id_(0), |
31 resource_dispatcher_host_(NULL), | 31 resource_dispatcher_host_(NULL) { |
32 ui_loop_(NULL) { | |
33 // Receive a notification if a message filter or WorkerProcessHost is deleted. | 32 // Receive a notification if a message filter or WorkerProcessHost is deleted. |
34 registrar_.Add(this, NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, | 33 registrar_.Add(this, NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN, |
35 NotificationService::AllSources()); | 34 NotificationService::AllSources()); |
36 | 35 |
37 registrar_.Add(this, NotificationType::WORKER_PROCESS_HOST_SHUTDOWN, | 36 registrar_.Add(this, NotificationType::WORKER_PROCESS_HOST_SHUTDOWN, |
38 NotificationService::AllSources()); | 37 NotificationService::AllSources()); |
39 } | 38 } |
40 | 39 |
41 void WorkerService::Initialize(ResourceDispatcherHost* rdh, | 40 void WorkerService::Initialize(ResourceDispatcherHost* rdh) { |
42 MessageLoop* ui_loop) { | |
43 resource_dispatcher_host_ = rdh; | 41 resource_dispatcher_host_ = rdh; |
44 ui_loop_ = ui_loop; | |
45 } | 42 } |
46 | 43 |
47 WorkerService::~WorkerService() { | 44 WorkerService::~WorkerService() { |
48 } | 45 } |
49 | 46 |
50 bool WorkerService::CreateDedicatedWorker(const GURL &url, | 47 bool WorkerService::CreateDedicatedWorker(const GURL &url, |
51 int renderer_id, | 48 int renderer_id, |
52 int render_view_route_id, | 49 int render_view_route_id, |
53 IPC::Message::Sender* sender, | 50 IPC::Message::Sender* sender, |
54 int sender_id, | 51 int sender_id, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (iter->id() != worker_process_id) | 270 if (iter->id() != worker_process_id) |
274 continue; | 271 continue; |
275 | 272 |
276 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); | 273 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
277 WorkerProcessHost::Instances::const_iterator instance = | 274 WorkerProcessHost::Instances::const_iterator instance = |
278 worker->instances().begin(); | 275 worker->instances().begin(); |
279 return instance == worker->instances().end() ? NULL : &*instance; | 276 return instance == worker->instances().end() ? NULL : &*instance; |
280 } | 277 } |
281 return NULL; | 278 return NULL; |
282 } | 279 } |
OLD | NEW |