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 } | |
kinuko
2014/03/11 07:40:19
nit: no need of { } for single-line body
horo
2014/03/11 07:49:20
Done.
| |
237 } | |
238 | |
239 bool WorkerService::EmbeddedSharedWorkerEnabled() { | |
240 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( | |
241 switches::kEnableEmbeddedSharedWorker); | |
242 return enabled; | |
232 } | 243 } |
233 | 244 |
234 WorkerServiceImpl* WorkerServiceImpl::GetInstance() { | 245 WorkerServiceImpl* WorkerServiceImpl::GetInstance() { |
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
236 return Singleton<WorkerServiceImpl>::get(); | 247 return Singleton<WorkerServiceImpl>::get(); |
237 } | 248 } |
238 | 249 |
239 WorkerServiceImpl::WorkerServiceImpl() | 250 WorkerServiceImpl::WorkerServiceImpl() |
240 : priority_setter_(new WorkerPrioritySetter()), | 251 : priority_setter_(new WorkerPrioritySetter()), |
241 next_worker_route_id_(0) { | 252 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(); | 591 instance_iter != iter->mutable_instances().end(); |
581 ++instance_iter) { | 592 ++instance_iter) { |
582 if (instance_iter->Matches(url, name, partition, resource_context)) | 593 if (instance_iter->Matches(url, name, partition, resource_context)) |
583 return &(*instance_iter); | 594 return &(*instance_iter); |
584 } | 595 } |
585 } | 596 } |
586 return NULL; | 597 return NULL; |
587 } | 598 } |
588 | 599 |
589 } // namespace content | 600 } // namespace content |
OLD | NEW |