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 #include "content/browser/worker_host/worker_service_impl.h" | 5 #include "content/browser/worker_host/worker_service_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "content/browser/devtools/worker_devtools_manager.h" | 12 #include "content/browser/devtools/worker_devtools_manager.h" |
13 #include "content/browser/renderer_host/render_widget_host_impl.h" | 13 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 14 #include "content/browser/shared_worker/shared_worker_service_impl.h" |
14 #include "content/browser/worker_host/worker_message_filter.h" | 15 #include "content/browser/worker_host/worker_message_filter.h" |
15 #include "content/browser/worker_host/worker_process_host.h" | 16 #include "content/browser/worker_host/worker_process_host.h" |
16 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
17 #include "content/common/worker_messages.h" | 18 #include "content/common/worker_messages.h" |
18 #include "content/public/browser/child_process_data.h" | 19 #include "content/public/browser/child_process_data.h" |
19 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
21 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 base::Bind(&WorkerPrioritySetter::OnRenderWidgetVisibilityChanged, | 222 base::Bind(&WorkerPrioritySetter::OnRenderWidgetVisibilityChanged, |
222 this, std::pair<int, int>(render_process_pid, render_widget_id))); | 223 this, std::pair<int, int>(render_process_pid, render_widget_id))); |
223 } | 224 } |
224 } | 225 } |
225 else if (type == NOTIFICATION_RENDERER_PROCESS_CREATED) { | 226 else if (type == NOTIFICATION_RENDERER_PROCESS_CREATED) { |
226 PostTaskToGatherAndUpdateWorkerPriorities(); | 227 PostTaskToGatherAndUpdateWorkerPriorities(); |
227 } | 228 } |
228 } | 229 } |
229 | 230 |
230 WorkerService* WorkerService::GetInstance() { | 231 WorkerService* WorkerService::GetInstance() { |
231 return WorkerServiceImpl::GetInstance(); | 232 if (EmbeddedSharedWorkerEnabled()) |
| 233 return SharedWorkerServiceImpl::GetInstance(); |
| 234 else |
| 235 return WorkerServiceImpl::GetInstance(); |
| 236 } |
| 237 |
| 238 bool WorkerService::EmbeddedSharedWorkerEnabled() { |
| 239 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 240 switches::kEnableEmbeddedSharedWorker); |
| 241 return enabled; |
232 } | 242 } |
233 | 243 |
234 WorkerServiceImpl* WorkerServiceImpl::GetInstance() { | 244 WorkerServiceImpl* WorkerServiceImpl::GetInstance() { |
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
236 return Singleton<WorkerServiceImpl>::get(); | 246 return Singleton<WorkerServiceImpl>::get(); |
237 } | 247 } |
238 | 248 |
239 WorkerServiceImpl::WorkerServiceImpl() | 249 WorkerServiceImpl::WorkerServiceImpl() |
240 : priority_setter_(new WorkerPrioritySetter()), | 250 : priority_setter_(new WorkerPrioritySetter()), |
241 next_worker_route_id_(0) { | 251 next_worker_route_id_(0) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 instance_iter != iter->mutable_instances().end(); | 590 instance_iter != iter->mutable_instances().end(); |
581 ++instance_iter) { | 591 ++instance_iter) { |
582 if (instance_iter->Matches(url, name, partition, resource_context)) | 592 if (instance_iter->Matches(url, name, partition, resource_context)) |
583 return &(*instance_iter); | 593 return &(*instance_iter); |
584 } | 594 } |
585 } | 595 } |
586 return NULL; | 596 return NULL; |
587 } | 597 } |
588 | 598 |
589 } // namespace content | 599 } // namespace content |
OLD | NEW |