summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc43
-rw-r--r--content/browser/worker_host/worker_service_impl.cc12
-rw-r--r--content/public/browser/worker_service.h3
-rw-r--r--content/public/common/content_switches.cc3
-rw-r--r--content/public/common/content_switches.h1
5 files changed, 49 insertions, 13 deletions
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index cb4fbe4..77712f6 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -97,6 +97,7 @@
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_dispatcher_host.h"
+#include "content/browser/shared_worker/shared_worker_message_filter.h"
#include "content/browser/speech/input_tag_speech_dispatcher_host.h"
#include "content/browser/speech/speech_recognition_dispatcher_host.h"
#include "content/browser/storage_partition_impl.h"
@@ -123,6 +124,7 @@
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/worker_service.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
@@ -756,18 +758,35 @@ void RenderProcessHostImpl::CreateMessageFilters() {
base::Unretained(widget_helper_.get())));
AddFilter(message_port_message_filter_);
- AddFilter(new WorkerMessageFilter(
- GetID(),
- resource_context,
- WorkerStoragePartition(
- storage_partition_impl_->GetURLRequestContext(),
- storage_partition_impl_->GetMediaURLRequestContext(),
- storage_partition_impl_->GetAppCacheService(),
- storage_partition_impl_->GetQuotaManager(),
- storage_partition_impl_->GetFileSystemContext(),
- storage_partition_impl_->GetDatabaseTracker(),
- storage_partition_impl_->GetIndexedDBContext()),
- message_port_message_filter_));
+ // If "--enable-embedded-shared-worker" is set, we use
+ // SharedWorkerMessageFilter in stead of WorkerMessageFilter.
+ if (WorkerService::EmbeddedSharedWorkerEnabled()) {
+ AddFilter(new SharedWorkerMessageFilter(
+ GetID(),
+ resource_context,
+ WorkerStoragePartition(
+ storage_partition_impl_->GetURLRequestContext(),
+ storage_partition_impl_->GetMediaURLRequestContext(),
+ storage_partition_impl_->GetAppCacheService(),
+ storage_partition_impl_->GetQuotaManager(),
+ storage_partition_impl_->GetFileSystemContext(),
+ storage_partition_impl_->GetDatabaseTracker(),
+ storage_partition_impl_->GetIndexedDBContext()),
+ message_port_message_filter_));
+ } else {
+ AddFilter(new WorkerMessageFilter(
+ GetID(),
+ resource_context,
+ WorkerStoragePartition(
+ storage_partition_impl_->GetURLRequestContext(),
+ storage_partition_impl_->GetMediaURLRequestContext(),
+ storage_partition_impl_->GetAppCacheService(),
+ storage_partition_impl_->GetQuotaManager(),
+ storage_partition_impl_->GetFileSystemContext(),
+ storage_partition_impl_->GetDatabaseTracker(),
+ storage_partition_impl_->GetIndexedDBContext()),
+ message_port_message_filter_));
+ }
#if defined(ENABLE_WEBRTC)
AddFilter(new P2PSocketDispatcherHost(
diff --git a/content/browser/worker_host/worker_service_impl.cc b/content/browser/worker_host/worker_service_impl.cc
index f2ac3735..d17f440 100644
--- a/content/browser/worker_host/worker_service_impl.cc
+++ b/content/browser/worker_host/worker_service_impl.cc
@@ -11,6 +11,7 @@
#include "base/threading/thread.h"
#include "content/browser/devtools/worker_devtools_manager.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/shared_worker/shared_worker_service_impl.h"
#include "content/browser/worker_host/worker_message_filter.h"
#include "content/browser/worker_host/worker_process_host.h"
#include "content/common/view_messages.h"
@@ -228,7 +229,16 @@ void WorkerPrioritySetter::Observe(int type,
}
WorkerService* WorkerService::GetInstance() {
- return WorkerServiceImpl::GetInstance();
+ if (EmbeddedSharedWorkerEnabled())
+ return SharedWorkerServiceImpl::GetInstance();
+ else
+ return WorkerServiceImpl::GetInstance();
+}
+
+bool WorkerService::EmbeddedSharedWorkerEnabled() {
+ static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableEmbeddedSharedWorker);
+ return enabled;
}
WorkerServiceImpl* WorkerServiceImpl::GetInstance() {
diff --git a/content/public/browser/worker_service.h b/content/public/browser/worker_service.h
index 7ce2bf4..83a8bd8 100644
--- a/content/public/browser/worker_service.h
+++ b/content/public/browser/worker_service.h
@@ -26,6 +26,9 @@ class WorkerService {
// Returns the WorkerService singleton.
CONTENT_EXPORT static WorkerService* GetInstance();
+ // Determines whether embedded SharedWorker is enabled.
+ CONTENT_EXPORT static bool EmbeddedSharedWorkerEnabled();
+
// Terminates the given worker. Returns true if the process was found.
virtual bool TerminateWorker(int process_id, int route_id) = 0;
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 47b965d..19c602b 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -430,6 +430,9 @@ const char kEnableDelegatedRenderer[] = "enable-delegated-renderer";
// Enables restarting interrupted downloads.
const char kEnableDownloadResumption[] = "enable-download-resumption";
+// Enables running the SharedWorker inside the renderer process.
+const char kEnableEmbeddedSharedWorker[] = "enable-embedded-shared-worker";
+
// Enables support for Encrypted Media Extensions (e.g. MediaKeys).
const char kEnableEncryptedMedia[] = "enable-encrypted-media";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 2c6c369..6b80911 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -126,6 +126,7 @@ CONTENT_EXPORT extern const char kEnableCompositingForTransition[];
CONTENT_EXPORT extern const char kEnableDeferredImageDecoding[];
CONTENT_EXPORT extern const char kEnableDelegatedRenderer[];
CONTENT_EXPORT extern const char kEnableDownloadResumption[];
+CONTENT_EXPORT extern const char kEnableEmbeddedSharedWorker[];
CONTENT_EXPORT extern const char kEnableEncryptedMedia[];
CONTENT_EXPORT extern const char kEnableExperimentalCanvasFeatures[];
CONTENT_EXPORT extern const char kEnableExperimentalWebPlatformFeatures[];