diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 183d79c43fffdd..11a8ec6d1af1f7 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6559,12 +6559,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Easy Unlock allows you to unlock your Chromebook when in proximity to your phone. - - Disable In-renderer Shared Worker. - - - Disable In-Renderer Shared Worker to run Shared Worker in a legacy dedicated worker process. - Apps file associations. diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index fa4a16c7095722..90091d8fdac70e 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1790,13 +1790,6 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kEnableEasyUnlock) }, #endif - { - "disable-embedded-shared-worker", - IDS_FLAGS_DISABLE_EMBEDDED_SHARED_WORKER_NAME, - IDS_FLAGS_DISABLE_EMBEDDED_SHARED_WORKER_DESCRIPTION, - kOsDesktop, - SINGLE_VALUE_TYPE(switches::kDisableEmbeddedSharedWorker) - }, #if defined(OS_CHROMEOS) { "enable-filemanager-mtp", diff --git a/chrome/browser/devtools/devtools_targets_ui.cc b/chrome/browser/devtools/devtools_targets_ui.cc index 9e3b8359ce54c1..e2161c0845d2e0 100644 --- a/chrome/browser/devtools/devtools_targets_ui.cc +++ b/chrome/browser/devtools/devtools_targets_ui.cc @@ -246,19 +246,12 @@ class WorkerObserver // WorkerTargetsUIHandler ----------------------------------------------------- class WorkerTargetsUIHandler - : public DevToolsTargetsUIHandler, - public content::BrowserChildProcessObserver { + : public DevToolsTargetsUIHandler { public: explicit WorkerTargetsUIHandler(const Callback& callback); virtual ~WorkerTargetsUIHandler(); private: - // content::BrowserChildProcessObserver overrides. - virtual void BrowserChildProcessHostConnected( - const content::ChildProcessData& data) OVERRIDE; - virtual void BrowserChildProcessHostDisconnected( - const content::ChildProcessData& data) OVERRIDE; - void UpdateTargets(const DevToolsTargetImpl::List& targets); scoped_refptr observer_; @@ -269,26 +262,12 @@ WorkerTargetsUIHandler::WorkerTargetsUIHandler(const Callback& callback) observer_(new WorkerObserver()) { observer_->Start(base::Bind(&WorkerTargetsUIHandler::UpdateTargets, base::Unretained(this))); - BrowserChildProcessObserver::Add(this); } WorkerTargetsUIHandler::~WorkerTargetsUIHandler() { - BrowserChildProcessObserver::Remove(this); observer_->Stop(); } -void WorkerTargetsUIHandler::BrowserChildProcessHostConnected( - const content::ChildProcessData& data) { - if (data.process_type == content::PROCESS_TYPE_WORKER) - observer_->Enumerate(); -} - -void WorkerTargetsUIHandler::BrowserChildProcessHostDisconnected( - const content::ChildProcessData& data) { - if (data.process_type == content::PROCESS_TYPE_WORKER) - observer_->Enumerate(); -} - void WorkerTargetsUIHandler::UpdateTargets( const DevToolsTargetImpl::List& targets) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 7c74e231cc7b60..878462d84ec813 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -472,10 +472,6 @@ void MemoryDetails::UpdateHistograms() { UMA_HISTOGRAM_MEMORY_KB("Memory.Plugin", sample); plugin_count++; continue; - case content::PROCESS_TYPE_WORKER: - UMA_HISTOGRAM_MEMORY_KB("Memory.Worker", sample); - worker_count++; - continue; case content::PROCESS_TYPE_UTILITY: UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample); other_count++; @@ -584,9 +580,6 @@ void MemoryDetails::UpdateSwapHistograms() { case content::PROCESS_TYPE_PLUGIN: UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Plugin", sample); continue; - case content::PROCESS_TYPE_WORKER: - UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Worker", sample); - continue; case content::PROCESS_TYPE_UTILITY: UMA_HISTOGRAM_MEMORY_KB("Memory.Swap.Utility", sample); continue; diff --git a/chrome/browser/metrics/profiler_metrics_provider.cc b/chrome/browser/metrics/profiler_metrics_provider.cc index 3e73e8652eb062..a843a4d45a62fa 100644 --- a/chrome/browser/metrics/profiler_metrics_provider.cc +++ b/chrome/browser/metrics/profiler_metrics_provider.cc @@ -27,8 +27,6 @@ ProfilerEventProto::TrackedObject::ProcessType AsProtobufProcessType( return ProfilerEventProto::TrackedObject::RENDERER; case content::PROCESS_TYPE_PLUGIN: return ProfilerEventProto::TrackedObject::PLUGIN; - case content::PROCESS_TYPE_WORKER: - return ProfilerEventProto::TrackedObject::WORKER; case content::PROCESS_TYPE_UTILITY: return ProfilerEventProto::TrackedObject::UTILITY; case content::PROCESS_TYPE_ZYGOTE: diff --git a/chrome/browser/performance_monitor/process_metrics_history.cc b/chrome/browser/performance_monitor/process_metrics_history.cc index f9ca171e903c21..7c724e0b618cf3 100644 --- a/chrome/browser/performance_monitor/process_metrics_history.cc +++ b/chrome/browser/performance_monitor/process_metrics_history.cc @@ -114,13 +114,6 @@ void ProcessMetricsHistory::RunPerformanceTriggers() { if (min_cpu_usage_ > kHighCPUUtilizationThreshold) UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PluginProcess", true); break; - case content::PROCESS_TYPE_WORKER: - UMA_HISTOGRAM_CUSTOM_COUNTS( - "PerformanceMonitor.AverageCPU.WorkerProcess", average_cpu_usage, - kHistogramMin, kHistogramMax, kHistogramBucketCount); - if (min_cpu_usage_ > kHighCPUUtilizationThreshold) - UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.WorkerProcess", true); - break; case content::PROCESS_TYPE_GPU: UMA_HISTOGRAM_CUSTOM_COUNTS( "PerformanceMonitor.AverageCPU.GPUProcess", average_cpu_usage, diff --git a/chrome/browser/task_manager/child_process_resource_provider.cc b/chrome/browser/task_manager/child_process_resource_provider.cc index eb0510c56d243f..dbc31eed0ecb3c 100644 --- a/chrome/browser/task_manager/child_process_resource_provider.cc +++ b/chrome/browser/task_manager/child_process_resource_provider.cc @@ -193,10 +193,6 @@ base::string16 ChildProcessResource::GetLocalizedTitle() const { case content::PROCESS_TYPE_MAX: NOTREACHED(); break; - - case content::PROCESS_TYPE_WORKER: - NOTREACHED() << "Workers are not handled by this provider."; - break; case content::PROCESS_TYPE_UNKNOWN: NOTREACHED() << "Need localized name for child process type."; } @@ -259,9 +255,6 @@ void ChildProcessResourceProvider::BrowserChildProcessHostConnected( const content::ChildProcessData& data) { DCHECK(updating_); - // Workers are handled by WorkerResourceProvider. - if (data.process_type == content::PROCESS_TYPE_WORKER) - return; if (resources_.count(data.handle)) { // The case may happen that we have added a child_process_info as part of // the iteration performed during StartUpdating() call but the notification @@ -277,8 +270,6 @@ void ChildProcessResourceProvider:: const content::ChildProcessData& data) { DCHECK(updating_); - if (data.process_type == content::PROCESS_TYPE_WORKER) - return; ChildProcessMap::iterator iter = resources_.find(data.handle); if (iter == resources_.end()) { // ChildProcessData disconnection notifications are asynchronous, so we @@ -322,8 +313,6 @@ void ChildProcessResourceProvider::RetrieveChildProcessData() { // Only add processes which are already started, since we need their handle. if (iter.GetData().handle == base::kNullProcessHandle) continue; - if (iter.GetData().process_type == content::PROCESS_TYPE_WORKER) - continue; child_processes.push_back(iter.GetData()); } // Now notify the UI thread that we have retrieved information about child diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 8ae32cd0015c1b..ba76c794054503 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -27,7 +27,6 @@ #include "chrome/browser/task_manager/resource_provider.h" #include "chrome/browser/task_manager/tab_contents_information.h" #include "chrome/browser/task_manager/web_contents_resource_provider.h" -#include "chrome/browser/task_manager/worker_resource_provider.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -271,11 +270,6 @@ TaskManagerModel::TaskManagerModel(TaskManager* task_manager) task_manager, scoped_ptr( new task_manager::GuestInformation()))); - - // We don't need to show the worker processes if "embedded-shared-worker" flag - // is enabled. - if (!content::WorkerService::EmbeddedSharedWorkerEnabled()) - AddResourceProvider(new task_manager::WorkerResourceProvider(task_manager)); } void TaskManagerModel::AddObserver(TaskManagerModelObserver* observer) { diff --git a/chrome/browser/task_manager/worker_resource_provider.cc b/chrome/browser/task_manager/worker_resource_provider.cc deleted file mode 100644 index f9e702ea2e163f..00000000000000 --- a/chrome/browser/task_manager/worker_resource_provider.cc +++ /dev/null @@ -1,359 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/task_manager/worker_resource_provider.h" - -#include - -#include "base/basictypes.h" -#include "base/strings/string16.h" -#include "base/strings/utf_string_conversions.h" -#include "chrome/browser/devtools/devtools_window.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/task_manager/resource_provider.h" -#include "chrome/browser/task_manager/task_manager.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/child_process_data.h" -#include "content/public/browser/devtools_agent_host.h" -#include "content/public/browser/worker_service.h" -#include "content/public/common/process_type.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image_skia.h" - -using content::BrowserThread; -using content::DevToolsAgentHost; -using content::WorkerService; - -namespace task_manager { - -// Objects of this class are created on the IO thread and then passed to the UI -// thread where they are passed to the task manager. All methods must be called -// only on the UI thread. Destructor may be called on any thread. -class SharedWorkerResource : public Resource { - public: - SharedWorkerResource(const GURL& url, - const base::string16& name, - int process_id, - int routing_id, - base::ProcessHandle process_handle); - virtual ~SharedWorkerResource(); - - bool Matches(int process_id, int routing_id) const; - - void UpdateProcessHandle(base::ProcessHandle handle); - base::ProcessHandle handle() const { return handle_; } - int process_id() const { return process_id_; } - - private: - // Resource methods: - virtual base::string16 GetTitle() const OVERRIDE; - virtual base::string16 GetProfileName() const OVERRIDE; - virtual gfx::ImageSkia GetIcon() const OVERRIDE; - virtual base::ProcessHandle GetProcess() const OVERRIDE; - virtual int GetUniqueChildProcessId() const OVERRIDE; - virtual Type GetType() const OVERRIDE; - virtual bool CanInspect() const OVERRIDE; - virtual void Inspect() const OVERRIDE; - - virtual bool SupportNetworkUsage() const OVERRIDE; - virtual void SetSupportNetworkUsage() OVERRIDE; - - int process_id_; - int routing_id_; - base::string16 title_; - base::ProcessHandle handle_; - - static gfx::ImageSkia* default_icon_; - - DISALLOW_COPY_AND_ASSIGN(SharedWorkerResource); -}; - -gfx::ImageSkia* SharedWorkerResource::default_icon_ = NULL; - -SharedWorkerResource::SharedWorkerResource( - const GURL& url, - const base::string16& name, - int process_id, - int routing_id, - base::ProcessHandle process_handle) - : process_id_(process_id), - routing_id_(routing_id), - handle_(process_handle) { - title_ = base::UTF8ToUTF16(url.spec()); - if (!name.empty()) - title_ += base::ASCIIToUTF16(" (") + name + base::ASCIIToUTF16(")"); -} - -SharedWorkerResource::~SharedWorkerResource() { -} - -bool SharedWorkerResource::Matches(int process_id, - int routing_id) const { - return process_id_ == process_id && routing_id_ == routing_id; -} - -void SharedWorkerResource::UpdateProcessHandle(base::ProcessHandle handle) { - handle_ = handle; -} - -base::string16 SharedWorkerResource::GetTitle() const { - return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title_); -} - -base::string16 SharedWorkerResource::GetProfileName() const { - return base::string16(); -} - -gfx::ImageSkia SharedWorkerResource::GetIcon() const { - if (!default_icon_) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON); - // TODO(jabdelmalek): use different icon for web workers. - } - return *default_icon_; -} - -base::ProcessHandle SharedWorkerResource::GetProcess() const { - return handle_; -} - -int SharedWorkerResource::GetUniqueChildProcessId() const { - return process_id_; -} - -Resource::Type SharedWorkerResource::GetType() const { - return WORKER; -} - -bool SharedWorkerResource::CanInspect() const { - return true; -} - -void SharedWorkerResource::Inspect() const { - // TODO(yurys): would be better to get profile from one of the tabs connected - // to the worker. - Profile* profile = ProfileManager::GetLastUsedProfile(); - if (!profile) - return; - scoped_refptr agent_host( - DevToolsAgentHost::GetForWorker(process_id_, routing_id_)); - DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host.get()); -} - -bool SharedWorkerResource::SupportNetworkUsage() const { - return false; -} - -void SharedWorkerResource::SetSupportNetworkUsage() { -} - - -// This class is needed to ensure that all resources in WorkerResourceList are -// deleted if corresponding task is posted to but not executed on the UI -// thread. -class WorkerResourceProvider::WorkerResourceListHolder { - public: - WorkerResourceListHolder() { - } - - ~WorkerResourceListHolder() { - STLDeleteElements(&resources_); - } - - WorkerResourceList* resources() { - return &resources_; - } - - private: - WorkerResourceList resources_; -}; - - -WorkerResourceProvider:: - WorkerResourceProvider(TaskManager* task_manager) - : updating_(false), - task_manager_(task_manager) { -} - -WorkerResourceProvider::~WorkerResourceProvider() { - DeleteAllResources(); -} - -Resource* WorkerResourceProvider::GetResource( - int origin_pid, - int child_id, - int route_id) { - return NULL; -} - -void WorkerResourceProvider::StartUpdating() { - DCHECK(!updating_); - updating_ = true; - // Get existing workers. - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, base::Bind( - &WorkerResourceProvider::StartObservingWorkers, - this)); - - BrowserChildProcessObserver::Add(this); -} - -void WorkerResourceProvider::StopUpdating() { - DCHECK(updating_); - updating_ = false; - launching_workers_.clear(); - DeleteAllResources(); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, base::Bind( - &WorkerResourceProvider::StopObservingWorkers, - this)); - - BrowserChildProcessObserver::Remove(this); -} - -void WorkerResourceProvider::BrowserChildProcessHostConnected( - const content::ChildProcessData& data) { - DCHECK(updating_); - - if (data.process_type != content::PROCESS_TYPE_WORKER) - return; - - ProcessIdToWorkerResources::iterator it(launching_workers_.find(data.id)); - if (it == launching_workers_.end()) - return; - WorkerResourceList& resources = it->second; - for (WorkerResourceList::iterator r = resources.begin(); - r != resources.end(); ++r) { - (*r)->UpdateProcessHandle(data.handle); - task_manager_->AddResource(*r); - } - launching_workers_.erase(it); -} - -void WorkerResourceProvider::BrowserChildProcessHostDisconnected( - const content::ChildProcessData& data) { - DCHECK(updating_); - - if (data.process_type != content::PROCESS_TYPE_WORKER) - return; - - // Worker process may be destroyed before WorkerMsg_TerminateWorkerContex - // message is handled and WorkerDestroyed is fired. In this case we won't - // get WorkerDestroyed notification and have to clear resources for such - // workers here when the worker process has been destroyed. - for (WorkerResourceList::iterator it = resources_.begin(); - it != resources_.end();) { - if ((*it)->process_id() == data.id) { - task_manager_->RemoveResource(*it); - delete *it; - it = resources_.erase(it); - } else { - ++it; - } - } - DCHECK(!ContainsKey(launching_workers_, data.id)); -} - -void WorkerResourceProvider::WorkerCreated( - const GURL& url, - const base::string16& name, - int process_id, - int route_id) { - SharedWorkerResource* resource = new SharedWorkerResource( - url, name, process_id, route_id, base::kNullProcessHandle); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerResourceProvider::NotifyWorkerCreated, - this, base::Owned(new WorkerResourceHolder(resource)))); -} - -void WorkerResourceProvider::WorkerDestroyed(int process_id, int route_id) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::Bind( - &WorkerResourceProvider::NotifyWorkerDestroyed, - this, process_id, route_id)); -} - -void WorkerResourceProvider::NotifyWorkerCreated( - WorkerResourceHolder* resource_holder) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!updating_) - return; - AddResource(resource_holder->release()); -} - -void WorkerResourceProvider::NotifyWorkerDestroyed( - int process_id, int routing_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!updating_) - return; - for (WorkerResourceList::iterator it = resources_.begin(); - it !=resources_.end(); ++it) { - if ((*it)->Matches(process_id, routing_id)) { - task_manager_->RemoveResource(*it); - delete *it; - resources_.erase(it); - return; - } - } -} - -void WorkerResourceProvider::StartObservingWorkers() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - scoped_ptr holder(new WorkerResourceListHolder); - std::vector worker_info = - WorkerService::GetInstance()->GetWorkers(); - - for (size_t i = 0; i < worker_info.size(); ++i) { - holder->resources()->push_back(new SharedWorkerResource( - worker_info[i].url, worker_info[i].name, worker_info[i].process_id, - worker_info[i].route_id, worker_info[i].handle)); - } - - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &WorkerResourceProvider::AddWorkerResourceList, - this, base::Owned(holder.release()))); - - WorkerService::GetInstance()->AddObserver(this); -} - -void WorkerResourceProvider::StopObservingWorkers() { - WorkerService::GetInstance()->RemoveObserver(this); -} - -void WorkerResourceProvider::AddWorkerResourceList( - WorkerResourceListHolder* resource_list_holder) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!updating_) - return; - WorkerResourceList* resources = resource_list_holder->resources(); - for (WorkerResourceList::iterator it = resources->begin(); - it !=resources->end(); ++it) { - AddResource(*it); - } - resources->clear(); -} - -void WorkerResourceProvider::AddResource(SharedWorkerResource* resource) { - DCHECK(updating_); - resources_.push_back(resource); - if (resource->handle() == base::kNullProcessHandle) { - int process_id = resource->process_id(); - launching_workers_[process_id].push_back(resource); - } else { - task_manager_->AddResource(resource); - } -} - -void WorkerResourceProvider::DeleteAllResources() { - STLDeleteElements(&resources_); -} - -} // namespace task_manager diff --git a/chrome/browser/task_manager/worker_resource_provider.h b/chrome/browser/task_manager/worker_resource_provider.h deleted file mode 100644 index 25df691a8fec34..00000000000000 --- a/chrome/browser/task_manager/worker_resource_provider.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ -#define CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/memory/singleton.h" -#include "chrome/browser/task_manager/resource_provider.h" -#include "content/public/browser/browser_child_process_observer.h" -#include "content/public/browser/worker_service_observer.h" - -class TaskManager; - -namespace task_manager { - -class SharedWorkerResource; - -class WorkerResourceProvider : public ResourceProvider, - public content::BrowserChildProcessObserver, - private content::WorkerServiceObserver { - public: - explicit WorkerResourceProvider(TaskManager* task_manager); - - private: - class WorkerResourceListHolder; - typedef std::vector WorkerResourceList; - typedef scoped_ptr WorkerResourceHolder; - typedef std::map ProcessIdToWorkerResources; - - virtual ~WorkerResourceProvider(); - - // ResourceProvider implementation. - virtual Resource* GetResource(int origin_pid, - int child_id, - int route_id) OVERRIDE; - virtual void StartUpdating() OVERRIDE; - virtual void StopUpdating() OVERRIDE; - - // content::BrowserChildProcessObserver implementation. - virtual void BrowserChildProcessHostConnected( - const content::ChildProcessData& data) OVERRIDE; - virtual void BrowserChildProcessHostDisconnected( - const content::ChildProcessData& data) OVERRIDE; - - // content::WorkerServiceObserver implementation. - virtual void WorkerCreated(const GURL& url, - const base::string16& name, - int process_id, - int route_id) OVERRIDE; - virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE; - - void NotifyWorkerCreated(WorkerResourceHolder* resource_holder); - void NotifyWorkerDestroyed(int process_id, int routing_id); - - void StartObservingWorkers(); - void StopObservingWorkers(); - - void AddWorkerResourceList(WorkerResourceListHolder* resource_list_holder); - void AddResource(SharedWorkerResource* resource); - void DeleteAllResources(); - - bool updating_; - TaskManager* task_manager_; - WorkerResourceList resources_; - // Map from worker process id to the list of its workers. This list contains - // entries for worker processes which has not launched yet but for which we - // have already received WorkerCreated event. We don't add such workers to - // the task manager until the process is launched. - ProcessIdToWorkerResources launching_workers_; - - DISALLOW_COPY_AND_ASSIGN(WorkerResourceProvider); -}; - -} // namespace task_manager - -#endif // CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d1857329bfa1a7..74593e5a4ceb6f 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -34,7 +34,6 @@ 'utility', '../content/content.gyp:content_gpu', '../content/content.gyp:content_ppapi_plugin', - '../content/content.gyp:content_worker', '../third_party/WebKit/public/blink_devtools.gyp:blink_devtools_frontend_resources', ], }], diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 40a6b30301c5f5..35f9994358e4fd 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1739,8 +1739,6 @@ 'browser/task_manager/web_contents_information.h', 'browser/task_manager/web_contents_resource_provider.cc', 'browser/task_manager/web_contents_resource_provider.h', - 'browser/task_manager/worker_resource_provider.cc', - 'browser/task_manager/worker_resource_provider.h', ], 'chrome_browser_spellchecker_sources': [ 'browser/spellchecker/feedback.cc', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index 33384cd132ef6c..4840963bbe8cdd 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -244,7 +244,6 @@ 'dependencies': [ '<@(chromium_child_dependencies)', '../content/content.gyp:content_app_both', - '../content/content.gyp:content_worker', ], 'dependencies!': [ '../content/content.gyp:content_app_browser', @@ -339,7 +338,6 @@ 'dependencies': [ '<@(chromium_child_dependencies)', '../content/content.gyp:content_app_child', - '../content/content.gyp:content_worker', 'chrome_version_resources', 'policy_path_parser', ], diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index ae1e3a20c5e3b4..f12f3493e5d7b8 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -301,7 +301,6 @@ '../content/content.gyp:content_ppapi_plugin', '../content/content.gyp:content_renderer', '../content/content.gyp:content_utility', - '../content/content.gyp:content_worker', '../components/components.gyp:autofill_core_test_support', '../components/components.gyp:captive_portal_test_support', '../components/components.gyp:sessions_test_support', diff --git a/content/BUILD.gn b/content/BUILD.gn index 6c6427074c9824..973a33404e0fe9 100644 --- a/content/BUILD.gn +++ b/content/BUILD.gn @@ -23,7 +23,6 @@ content_components = [ "//content/public/renderer", "//content/renderer", "//content/utility", - "//content/worker", ] if (is_component_build) { diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 69eb8c28fd9229..f8f9a42e61baef 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -121,7 +121,6 @@ extern int PpapiBrokerMain(const MainFunctionParams&); #endif extern int RendererMain(const content::MainFunctionParams&); extern int UtilityMain(const MainFunctionParams&); -extern int WorkerMain(const MainFunctionParams&); } // namespace content namespace content { @@ -296,7 +295,6 @@ int RunZygote(const MainFunctionParams& main_function_params, ContentMainDelegate* delegate) { static const MainFunction kMainFunctions[] = { { switches::kRendererProcess, RendererMain }, - { switches::kWorkerProcess, WorkerMain }, #if defined(ENABLE_PLUGINS) { switches::kPpapiPluginProcess, PpapiPluginMain }, #endif @@ -386,7 +384,6 @@ int RunNamedProcessTypeMain( #if !defined(OS_LINUX) { switches::kPluginProcess, PluginMain }, #endif - { switches::kWorkerProcess, WorkerMain }, { switches::kPpapiPluginProcess, PpapiPluginMain }, { switches::kPpapiBrokerProcess, PpapiBrokerMain }, #endif // ENABLE_PLUGINS diff --git a/content/browser/devtools/embedded_worker_devtools_manager.cc b/content/browser/devtools/embedded_worker_devtools_manager.cc index 3ba61aafeea20e..0d9b7e9cd34444 100644 --- a/content/browser/devtools/embedded_worker_devtools_manager.cc +++ b/content/browser/devtools/embedded_worker_devtools_manager.cc @@ -17,6 +17,15 @@ namespace content { +// Called on the UI thread. +// static +scoped_refptr DevToolsAgentHost::GetForWorker( + int worker_process_id, + int worker_route_id) { + return EmbeddedWorkerDevToolsManager::GetInstance() + ->GetDevToolsAgentHostForWorker(worker_process_id, worker_route_id); +} + namespace { bool SendMessageToWorker( diff --git a/content/browser/devtools/embedded_worker_devtools_manager_unittest.cc b/content/browser/devtools/embedded_worker_devtools_manager_unittest.cc index 69b230524256e2..f9fa31af0c1178 100644 --- a/content/browser/devtools/embedded_worker_devtools_manager_unittest.cc +++ b/content/browser/devtools/embedded_worker_devtools_manager_unittest.cc @@ -10,7 +10,7 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/devtools/devtools_manager_impl.h" #include "content/browser/shared_worker/shared_worker_instance.h" -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_client_host.h" #include "content/public/test/test_browser_context.h" diff --git a/content/browser/devtools/worker_devtools_manager.cc b/content/browser/devtools/worker_devtools_manager.cc deleted file mode 100644 index 0658c353c64ce4..00000000000000 --- a/content/browser/devtools/worker_devtools_manager.cc +++ /dev/null @@ -1,453 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/devtools/worker_devtools_manager.h" - -#include -#include - -#include "base/bind.h" -#include "base/lazy_instance.h" -#include "content/browser/devtools/devtools_manager_impl.h" -#include "content/browser/devtools/devtools_protocol.h" -#include "content/browser/devtools/devtools_protocol_constants.h" -#include "content/browser/devtools/embedded_worker_devtools_manager.h" -#include "content/browser/devtools/ipc_devtools_agent_host.h" -#include "content/browser/devtools/worker_devtools_message_filter.h" -#include "content/browser/worker_host/worker_service_impl.h" -#include "content/common/devtools_messages.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/child_process_data.h" -#include "content/public/common/process_type.h" - -namespace content { - -// Called on the UI thread. -// static -scoped_refptr DevToolsAgentHost::GetForWorker( - int worker_process_id, - int worker_route_id) { - if (WorkerService::EmbeddedSharedWorkerEnabled()) { - return EmbeddedWorkerDevToolsManager::GetInstance() - ->GetDevToolsAgentHostForWorker(worker_process_id, worker_route_id); - } else { - return WorkerDevToolsManager::GetDevToolsAgentHostForWorker( - worker_process_id, worker_route_id); - } -} - -namespace { - -typedef std::map AgentHosts; -base::LazyInstance::Leaky g_agent_map = LAZY_INSTANCE_INITIALIZER; -base::LazyInstance::Leaky g_orphan_map = LAZY_INSTANCE_INITIALIZER; - -} // namespace - -struct WorkerDevToolsManager::TerminatedInspectedWorker { - TerminatedInspectedWorker(WorkerId id, - const GURL& url, - const base::string16& name) - : old_worker_id(id), - worker_url(url), - worker_name(name) {} - WorkerId old_worker_id; - GURL worker_url; - base::string16 worker_name; -}; - - -class WorkerDevToolsManager::WorkerDevToolsAgentHost - : public IPCDevToolsAgentHost { - public: - explicit WorkerDevToolsAgentHost(WorkerId worker_id) - : has_worker_id_(false) { - SetWorkerId(worker_id, false); - } - - void SetWorkerId(WorkerId worker_id, bool reattach) { - worker_id_ = worker_id; - if (!has_worker_id_) - AddRef(); // Balanced in ResetWorkerId. - has_worker_id_ = true; - g_agent_map.Get()[worker_id_] = this; - - BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - base::Bind( - &ConnectToWorker, - worker_id.first, - worker_id.second)); - - if (reattach) - Reattach(state_); - } - - void ResetWorkerId() { - g_agent_map.Get().erase(worker_id_); - has_worker_id_ = false; - Release(); // Balanced in SetWorkerId. - } - - void SaveAgentRuntimeState(const std::string& state) { - state_ = state; - } - - void ConnectionFailed() { - NotifyCloseListener(); - // Object can be deleted here. - } - - private: - virtual ~WorkerDevToolsAgentHost(); - - static void ConnectToWorker( - int worker_process_id, - int worker_route_id) { - WorkerDevToolsManager::GetInstance()->ConnectDevToolsAgentHostToWorker( - worker_process_id, worker_route_id); - } - - static void ForwardToWorkerDevToolsAgent( - int worker_process_id, - int worker_route_id, - IPC::Message* message) { - WorkerDevToolsManager::GetInstance()->ForwardToWorkerDevToolsAgent( - worker_process_id, worker_route_id, *message); - } - - // IPCDevToolsAgentHost implementation. - virtual void SendMessageToAgent(IPC::Message* message) OVERRIDE { - if (!has_worker_id_) { - delete message; - return; - } - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind( - &WorkerDevToolsAgentHost::ForwardToWorkerDevToolsAgent, - worker_id_.first, - worker_id_.second, - base::Owned(message))); - } - - virtual void OnClientAttached() OVERRIDE {} - virtual void OnClientDetached() OVERRIDE {} - - bool has_worker_id_; - WorkerId worker_id_; - std::string state_; - - DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost); -}; - - -class WorkerDevToolsManager::DetachedClientHosts { - public: - static void WorkerReloaded(WorkerId old_id, WorkerId new_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - AgentHosts::iterator it = g_orphan_map.Get().find(old_id); - if (it != g_orphan_map.Get().end()) { - it->second->SetWorkerId(new_id, true); - g_orphan_map.Get().erase(old_id); - return; - } - RemovePendingWorkerData(old_id); - } - - static void WorkerDestroyed(WorkerId id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - AgentHosts::iterator it = g_agent_map.Get().find(id); - if (it == g_agent_map.Get().end()) { - RemovePendingWorkerData(id); - return; - } - - WorkerDevToolsAgentHost* agent = it->second; - DevToolsManagerImpl* devtools_manager = DevToolsManagerImpl::GetInstance(); - if (!agent->IsAttached()) { - // Agent has no client hosts -> delete it. - RemovePendingWorkerData(id); - return; - } - - // Client host is debugging this worker agent host. - std::string notification = DevToolsProtocol::CreateNotification( - devtools::Worker::disconnectedFromWorker::kName, NULL)->Serialize(); - devtools_manager->DispatchOnInspectorFrontend(agent, notification); - g_orphan_map.Get()[id] = agent; - agent->ResetWorkerId(); - } - - static void RemovePendingWorkerData(WorkerId id) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&RemoveInspectedWorkerDataOnIOThread, id)); - } - - private: - DetachedClientHosts() {} - ~DetachedClientHosts() {} - - static void RemoveInspectedWorkerDataOnIOThread(WorkerId id) { - WorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData(id); - } -}; - -struct WorkerDevToolsManager::InspectedWorker { - InspectedWorker(WorkerProcessHost* host, int route_id, const GURL& url, - const base::string16& name) - : host(host), - route_id(route_id), - worker_url(url), - worker_name(name) {} - WorkerProcessHost* const host; - int const route_id; - GURL worker_url; - base::string16 worker_name; -}; - -// static -WorkerDevToolsManager* WorkerDevToolsManager::GetInstance() { - DCHECK(!WorkerService::EmbeddedSharedWorkerEnabled()); - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return Singleton::get(); -} - -// static -DevToolsAgentHost* WorkerDevToolsManager::GetDevToolsAgentHostForWorker( - int worker_process_id, - int worker_route_id) { - DCHECK(!WorkerService::EmbeddedSharedWorkerEnabled()); - WorkerId id(worker_process_id, worker_route_id); - AgentHosts::iterator it = g_agent_map.Get().find(id); - if (it == g_agent_map.Get().end()) - return new WorkerDevToolsAgentHost(id); - return it->second; -} - -WorkerDevToolsManager::WorkerDevToolsManager() { -} - -WorkerDevToolsManager::~WorkerDevToolsManager() { -} - -bool WorkerDevToolsManager::WorkerCreated( - WorkerProcessHost* worker, - const WorkerProcessHost::WorkerInstance& instance) { - for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); - it != terminated_workers_.end(); ++it) { - if (instance.Matches(it->worker_url, it->worker_name, - instance.partition(), - instance.resource_context())) { - WorkerId new_worker_id(worker->GetData().id, instance.worker_route_id()); - paused_workers_[new_worker_id] = it->old_worker_id; - terminated_workers_.erase(it); - return true; - } - } - return false; -} - -void WorkerDevToolsManager::WorkerDestroyed( - WorkerProcessHost* worker, - int worker_route_id) { - InspectedWorkersList::iterator it = FindInspectedWorker( - worker->GetData().id, - worker_route_id); - if (it == inspected_workers_.end()) - return; - - WorkerId worker_id(worker->GetData().id, worker_route_id); - terminated_workers_.push_back(TerminatedInspectedWorker( - worker_id, - it->worker_url, - it->worker_name)); - inspected_workers_.erase(it); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&DetachedClientHosts::WorkerDestroyed, worker_id)); -} - -void WorkerDevToolsManager::WorkerContextStarted(WorkerProcessHost* process, - int worker_route_id) { - WorkerId new_worker_id(process->GetData().id, worker_route_id); - PausedWorkers::iterator it = paused_workers_.find(new_worker_id); - if (it == paused_workers_.end()) - return; - - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &DetachedClientHosts::WorkerReloaded, - it->second, - new_worker_id)); - paused_workers_.erase(it); -} - -void WorkerDevToolsManager::RemoveInspectedWorkerData( - const WorkerId& id) { - for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); - it != terminated_workers_.end(); ++it) { - if (it->old_worker_id == id) { - terminated_workers_.erase(it); - return; - } - } - - for (PausedWorkers::iterator it = paused_workers_.begin(); - it != paused_workers_.end(); ++it) { - if (it->second == id) { - SendResumeToWorker(it->first); - paused_workers_.erase(it); - return; - } - } -} - -WorkerDevToolsManager::InspectedWorkersList::iterator -WorkerDevToolsManager::FindInspectedWorker( - int host_id, int route_id) { - InspectedWorkersList::iterator it = inspected_workers_.begin(); - while (it != inspected_workers_.end()) { - if (it->host->GetData().id == host_id && it->route_id == route_id) - break; - ++it; - } - return it; -} - -static WorkerProcessHost* FindWorkerProcess(int worker_process_id) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (iter.GetData().id == worker_process_id) - return *iter; - } - return NULL; -} - -void WorkerDevToolsManager::ConnectDevToolsAgentHostToWorker( - int worker_process_id, - int worker_route_id) { - if (WorkerProcessHost* process = FindWorkerProcess(worker_process_id)) { - const WorkerProcessHost::Instances& instances = process->instances(); - for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); - i != instances.end(); ++i) { - if (i->worker_route_id() == worker_route_id) { - DCHECK(FindInspectedWorker(worker_process_id, worker_route_id) == - inspected_workers_.end()); - inspected_workers_.push_back( - InspectedWorker(process, worker_route_id, i->url(), i->name())); - return; - } - } - } - NotifyConnectionFailedOnIOThread(worker_process_id, worker_route_id); -} - -void WorkerDevToolsManager::ForwardToDevToolsClient( - int worker_process_id, - int worker_route_id, - const std::string& message) { - if (FindInspectedWorker(worker_process_id, worker_route_id) == - inspected_workers_.end()) { - NOTREACHED(); - return; - } - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &ForwardToDevToolsClientOnUIThread, - worker_process_id, - worker_route_id, - message)); -} - -void WorkerDevToolsManager::SaveAgentRuntimeState(int worker_process_id, - int worker_route_id, - const std::string& state) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &SaveAgentRuntimeStateOnUIThread, - worker_process_id, - worker_route_id, - state)); -} - -void WorkerDevToolsManager::ForwardToWorkerDevToolsAgent( - int worker_process_id, - int worker_route_id, - const IPC::Message& message) { - InspectedWorkersList::iterator it = FindInspectedWorker( - worker_process_id, - worker_route_id); - if (it == inspected_workers_.end()) - return; - IPC::Message* msg = new IPC::Message(message); - msg->set_routing_id(worker_route_id); - it->host->Send(msg); -} - -// static -void WorkerDevToolsManager::ForwardToDevToolsClientOnUIThread( - int worker_process_id, - int worker_route_id, - const std::string& message) { - AgentHosts::iterator it = g_agent_map.Get().find(WorkerId(worker_process_id, - worker_route_id)); - if (it == g_agent_map.Get().end()) - return; - DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend(it->second, - message); -} - -// static -void WorkerDevToolsManager::SaveAgentRuntimeStateOnUIThread( - int worker_process_id, - int worker_route_id, - const std::string& state) { - AgentHosts::iterator it = g_agent_map.Get().find(WorkerId(worker_process_id, - worker_route_id)); - if (it == g_agent_map.Get().end()) - return; - it->second->SaveAgentRuntimeState(state); -} - -// static -void WorkerDevToolsManager::NotifyConnectionFailedOnIOThread( - int worker_process_id, - int worker_route_id) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &WorkerDevToolsManager::NotifyConnectionFailedOnUIThread, - worker_process_id, - worker_route_id)); -} - -// static -void WorkerDevToolsManager::NotifyConnectionFailedOnUIThread( - int worker_process_id, - int worker_route_id) { - AgentHosts::iterator it = g_agent_map.Get().find(WorkerId(worker_process_id, - worker_route_id)); - if (it != g_agent_map.Get().end()) - it->second->ConnectionFailed(); -} - -// static -void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { - if (WorkerProcessHost* process = FindWorkerProcess(id.first)) - process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); -} - -WorkerDevToolsManager::WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { - DetachedClientHosts::RemovePendingWorkerData(worker_id_); - g_agent_map.Get().erase(worker_id_); - g_orphan_map.Get().erase(worker_id_); -} - -} // namespace content diff --git a/content/browser/devtools/worker_devtools_manager.h b/content/browser/devtools/worker_devtools_manager.h deleted file mode 100644 index 73916c30fe2bd1..00000000000000 --- a/content/browser/devtools/worker_devtools_manager.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ -#define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ - -#include -#include -#include - -#include "base/basictypes.h" -#include "base/memory/singleton.h" -#include "content/browser/worker_host/worker_process_host.h" -#include "content/common/content_export.h" - -namespace content { - -class DevToolsAgentHost; - -// All methods are supposed to be called on the IO thread. -// This class is not used when "enable-embedded-shared-worker" flag is set. -class WorkerDevToolsManager { - public: - typedef std::pair WorkerId; - class WorkerDevToolsAgentHost; - - // Returns the WorkerDevToolsManager singleton. - static WorkerDevToolsManager* GetInstance(); - - // Called on the UI thread. - static DevToolsAgentHost* GetDevToolsAgentHostForWorker( - int worker_process_id, - int worker_route_id); - - void ForwardToDevToolsClient(int worker_process_id, - int worker_route_id, - const std::string& message); - void SaveAgentRuntimeState(int worker_process_id, - int worker_route_id, - const std::string& state); - - // Called on the IO thread. - // Returns true when the worker must be paused on start. - bool WorkerCreated(WorkerProcessHost* process, - const WorkerProcessHost::WorkerInstance& instance); - void WorkerDestroyed(WorkerProcessHost* process, int worker_route_id); - void WorkerContextStarted(WorkerProcessHost* process, int worker_route_id); - - private: - friend struct DefaultSingletonTraits; - class DetachedClientHosts; - struct InspectedWorker; - typedef std::list InspectedWorkersList; - - WorkerDevToolsManager(); - virtual ~WorkerDevToolsManager(); - - void RemoveInspectedWorkerData(const WorkerId& id); - InspectedWorkersList::iterator FindInspectedWorker(int host_id, int route_id); - - void ConnectDevToolsAgentHostToWorker(int worker_process_id, - int worker_route_id); - void ForwardToWorkerDevToolsAgent(int worker_process_host_id, - int worker_route_id, - const IPC::Message& message); - static void ForwardToDevToolsClientOnUIThread( - int worker_process_id, - int worker_route_id, - const std::string& message); - static void SaveAgentRuntimeStateOnUIThread( - int worker_process_id, - int worker_route_id, - const std::string& state); - static void NotifyConnectionFailedOnIOThread(int worker_process_id, - int worker_route_id); - static void NotifyConnectionFailedOnUIThread(int worker_process_id, - int worker_route_id); - static void SendResumeToWorker(const WorkerId& id); - - InspectedWorkersList inspected_workers_; - - struct TerminatedInspectedWorker; - typedef std::list TerminatedInspectedWorkers; - // List of terminated workers for which there may be a devtools client on - // the UI thread. Worker entry is added into this list when inspected worker - // is terminated and will be removed in one of two cases: - // - shared worker with the same URL and name is started(in wich case we will - // try to reattach existing DevTools client to the new worker). - // - DevTools client which was inspecting terminated worker is closed on the - // UI thread and and WorkerDevToolsManager is notified about that on the IO - // thread. - TerminatedInspectedWorkers terminated_workers_; - - typedef std::map PausedWorkers; - // Map from old to new worker id for the inspected workers that have been - // terminated and started again in paused state. Worker data will be removed - // from this list in one of two cases: - // - DevTools client is closed on the UI thread, WorkerDevToolsManager was - // notified about that on the IO thread and sent "resume" message to the - // worker. - // - Existing DevTools client was reattached to the new worker. - PausedWorkers paused_workers_; - - DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ diff --git a/content/browser/devtools/worker_devtools_message_filter.cc b/content/browser/devtools/worker_devtools_message_filter.cc deleted file mode 100644 index 23c068b540583c..00000000000000 --- a/content/browser/devtools/worker_devtools_message_filter.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/devtools/worker_devtools_message_filter.h" - -#include "content/browser/devtools/worker_devtools_manager.h" -#include "content/common/devtools_messages.h" -#include "content/common/worker_messages.h" - -namespace content { - -WorkerDevToolsMessageFilter::WorkerDevToolsMessageFilter( - int worker_process_host_id) - : BrowserMessageFilter(DevToolsMsgStart), - worker_process_host_id_(worker_process_host_id), - current_routing_id_(0) { -} - -WorkerDevToolsMessageFilter::~WorkerDevToolsMessageFilter() { -} - -bool WorkerDevToolsMessageFilter::OnMessageReceived( - const IPC::Message& message) { - bool handled = true; - current_routing_id_ = message.routing_id(); - IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsMessageFilter, message) - IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, - OnDispatchOnInspectorFrontend) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, - OnSaveAgentRumtimeState) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void WorkerDevToolsMessageFilter::OnDispatchOnInspectorFrontend( - const std::string& message) { - WorkerDevToolsManager::GetInstance()->ForwardToDevToolsClient( - worker_process_host_id_, current_routing_id_, message); -} - -void WorkerDevToolsMessageFilter::OnSaveAgentRumtimeState( - const std::string& state) { - WorkerDevToolsManager::GetInstance()->SaveAgentRuntimeState( - worker_process_host_id_, current_routing_id_, state); -} - -} // namespace content diff --git a/content/browser/devtools/worker_devtools_message_filter.h b/content/browser/devtools/worker_devtools_message_filter.h deleted file mode 100644 index c80658e8dbfa5e..00000000000000 --- a/content/browser/devtools/worker_devtools_message_filter.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MESSAGE_FILTER_H_ - -#include "base/callback_forward.h" -#include "content/public/browser/browser_message_filter.h" - -namespace content { - -class WorkerDevToolsMessageFilter : public BrowserMessageFilter { - public: - explicit WorkerDevToolsMessageFilter(int worker_process_host_id); - - private: - virtual ~WorkerDevToolsMessageFilter(); - - // BrowserMessageFilter implementation. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - // Message handlers. - void OnDispatchOnInspectorFrontend(const std::string& message); - void OnSaveAgentRumtimeState(const std::string& state); - - int worker_process_host_id_; - int current_routing_id_; - - DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MESSAGE_FILTER_H_ diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc index 2957728545e30a..41bae2d3be287a 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -53,7 +53,6 @@ #include "content/browser/streams/stream.h" #include "content/browser/streams/stream_context.h" #include "content/browser/streams/stream_registry.h" -#include "content/browser/worker_host/worker_service_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/appcache_interfaces.h" #include "content/common/resource_messages.h" diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc index 18f9c300a4c910..8a130b9fcb633a 100644 --- a/content/browser/loader/resource_dispatcher_host_unittest.cc +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc @@ -23,7 +23,6 @@ #include "content/browser/loader/resource_loader.h" #include "content/browser/loader/resource_message_filter.h" #include "content/browser/loader/resource_request_info_impl.h" -#include "content/browser/worker_host/worker_service_impl.h" #include "content/common/appcache_interfaces.h" #include "content/common/child_process_host_impl.h" #include "content/common/resource_messages.h" @@ -778,8 +777,6 @@ class ResourceDispatcherHostTest : public testing::Test, ResourceDispatcherHostImpl::Get()->CancelRequestsForContext( browser_context_->GetResourceContext()); - WorkerServiceImpl::GetInstance()->PerformTeardownForTesting(); - browser_context_.reset(); base::RunLoop().RunUntilIdle(); } diff --git a/content/browser/loader/resource_request_info_impl.cc b/content/browser/loader/resource_request_info_impl.cc index 03d925ee7869dc..8db5e3445e8e9b 100644 --- a/content/browser/loader/resource_request_info_impl.cc +++ b/content/browser/loader/resource_request_info_impl.cc @@ -6,9 +6,9 @@ #include "content/browser/loader/global_routing_id.h" #include "content/browser/loader/resource_message_filter.h" -#include "content/browser/worker_host/worker_service_impl.h" #include "content/common/net/url_request_user_data.h" #include "content/public/browser/global_request_id.h" +#include "content/public/common/process_type.h" #include "net/url_request/url_request.h" namespace content { @@ -206,18 +206,7 @@ bool ResourceRequestInfoImpl::WasIgnoredByHandler() const { bool ResourceRequestInfoImpl::GetAssociatedRenderFrame( int* render_process_id, int* render_frame_id) const { - // If the request is from the worker process, find a content that owns the - // worker. - if (process_type_ == PROCESS_TYPE_WORKER) { - // Need to display some related UI for this network request - pick an - // arbitrary parent to do so. - if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( - child_id_, render_process_id, render_frame_id)) { - *render_process_id = -1; - *render_frame_id = -1; - return false; - } - } else if (process_type_ == PROCESS_TYPE_PLUGIN) { + if (process_type_ == PROCESS_TYPE_PLUGIN) { *render_process_id = origin_pid_; *render_frame_id = render_frame_id_; } else { diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index d87691083825ea..be63ff21b13972 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -99,14 +99,13 @@ #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/shared_worker/worker_storage_partition.h" #include "content/browser/speech/speech_recognition_dispatcher_host.h" #include "content/browser/storage_partition_impl.h" #include "content/browser/streams/stream_context.h" #include "content/browser/tracing/trace_message_filter.h" #include "content/browser/vibration/vibration_message_filter.h" #include "content/browser/webui/web_ui_controller_factory_registry.h" -#include "content/browser/worker_host/worker_message_filter.h" -#include "content/browser/worker_host/worker_storage_partition.h" #include "content/common/child_process_host_impl.h" #include "content/common/child_process_messages.h" #include "content/common/content_switches_internal.h" @@ -834,37 +833,19 @@ void RenderProcessHostImpl::CreateMessageFilters() { storage_partition_impl_->GetServiceWorkerContext()); AddFilter(service_worker_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(), - storage_partition_impl_->GetServiceWorkerContext()), - 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(), - storage_partition_impl_->GetServiceWorkerContext()), - message_port_message_filter_)); - } + 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(), + storage_partition_impl_->GetServiceWorkerContext()), + message_port_message_filter_)); #if defined(ENABLE_WEBRTC) p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost( diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc index 844f60b2734b84..c0960e6faec62a 100644 --- a/content/browser/shared_worker/shared_worker_host.cc +++ b/content/browser/shared_worker/shared_worker_host.cc @@ -12,7 +12,7 @@ #include "content/browser/shared_worker/shared_worker_instance.h" #include "content/browser/shared_worker/shared_worker_message_filter.h" #include "content/browser/shared_worker/shared_worker_service_impl.h" -#include "content/browser/worker_host/worker_document_set.h" +#include "content/browser/shared_worker/worker_document_set.h" #include "content/common/view_messages.h" #include "content/common/worker_messages.h" #include "content/public/browser/browser_thread.h" diff --git a/content/browser/shared_worker/shared_worker_host.h b/content/browser/shared_worker/shared_worker_host.h index a956c99559d52e..f0b46892e7a414 100644 --- a/content/browser/shared_worker/shared_worker_host.h +++ b/content/browser/shared_worker/shared_worker_host.h @@ -13,7 +13,7 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "content/browser/shared_worker/shared_worker_message_filter.h" -#include "content/browser/worker_host/worker_document_set.h" +#include "content/browser/shared_worker/worker_document_set.h" class GURL; diff --git a/content/browser/shared_worker/shared_worker_instance.h b/content/browser/shared_worker/shared_worker_instance.h index 2785c409d57442..b7c5fdb2d70599 100644 --- a/content/browser/shared_worker/shared_worker_instance.h +++ b/content/browser/shared_worker/shared_worker_instance.h @@ -8,7 +8,7 @@ #include #include "base/basictypes.h" -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include "content/common/content_export.h" #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" #include "url/gurl.h" diff --git a/content/browser/shared_worker/shared_worker_instance_unittest.cc b/content/browser/shared_worker/shared_worker_instance_unittest.cc index 83e51c171b358e..a05461a92b861c 100644 --- a/content/browser/shared_worker/shared_worker_instance_unittest.cc +++ b/content/browser/shared_worker/shared_worker_instance_unittest.cc @@ -7,7 +7,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "content/browser/shared_worker/shared_worker_instance.h" -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include "content/public/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/content/browser/shared_worker/shared_worker_message_filter.cc b/content/browser/shared_worker/shared_worker_message_filter.cc index 61ef510e5cc301..c1fb8936124ea2 100644 --- a/content/browser/shared_worker/shared_worker_message_filter.cc +++ b/content/browser/shared_worker/shared_worker_message_filter.cc @@ -4,7 +4,6 @@ #include "content/browser/shared_worker/shared_worker_message_filter.h" -#include "content/browser/devtools/worker_devtools_manager.h" #include "content/browser/message_port_message_filter.h" #include "content/browser/shared_worker/shared_worker_service_impl.h" #include "content/common/devtools_messages.h" diff --git a/content/browser/shared_worker/shared_worker_message_filter.h b/content/browser/shared_worker/shared_worker_message_filter.h index f6129d7354c848..ee2a07b617808e 100644 --- a/content/browser/shared_worker/shared_worker_message_filter.h +++ b/content/browser/shared_worker/shared_worker_message_filter.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_MESSAGE_FILTER_H_ -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include "content/common/content_export.h" #include "content/public/browser/browser_message_filter.h" diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc index 3c4b78b4686f85..b67522d855314f 100644 --- a/content/browser/shared_worker/shared_worker_service_impl.cc +++ b/content/browser/shared_worker/shared_worker_service_impl.cc @@ -16,13 +16,18 @@ #include "content/browser/shared_worker/shared_worker_host.h" #include "content/browser/shared_worker/shared_worker_instance.h" #include "content/browser/shared_worker/shared_worker_message_filter.h" -#include "content/browser/worker_host/worker_document_set.h" +#include "content/browser/shared_worker/worker_document_set.h" #include "content/common/view_messages.h" #include "content/common/worker_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/worker_service_observer.h" namespace content { + +WorkerService* WorkerService::GetInstance() { + return SharedWorkerServiceImpl::GetInstance(); +} + namespace { class ScopedWorkerDependencyChecker { diff --git a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc index e08da83efb242b..f429189ee865e2 100644 --- a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc +++ b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc @@ -16,7 +16,7 @@ #include "content/browser/message_port_message_filter.h" #include "content/browser/shared_worker/shared_worker_message_filter.h" #include "content/browser/shared_worker/shared_worker_service_impl.h" -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include "content/common/message_port_messages.h" #include "content/common/view_messages.h" #include "content/common/worker_messages.h" diff --git a/content/browser/shared_worker/worker_browsertest.cc b/content/browser/shared_worker/worker_browsertest.cc new file mode 100644 index 00000000000000..b7fc51ee361ae1 --- /dev/null +++ b/content/browser/shared_worker/worker_browsertest.cc @@ -0,0 +1,146 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/bind.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" +#include "base/strings/utf_string_conversions.h" +#include "base/sys_info.h" +#include "base/test/test_timeouts.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/common/content_paths.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/content_browser_test.h" +#include "content/public/test/content_browser_test_utils.h" +#include "content/public/test/test_utils.h" +#include "content/shell/browser/shell.h" +#include "content/shell/browser/shell_content_browser_client.h" +#include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" +#include "net/base/test_data_directory.h" +#include "net/test/spawned_test_server/spawned_test_server.h" +#include "url/gurl.h" + +namespace content { + +class WorkerTest : public ContentBrowserTest { + public: + WorkerTest() {} + + GURL GetTestURL(const std::string& test_case, const std::string& query) { + base::FilePath test_file_path = GetTestFilePath( + "workers", test_case.c_str()); + return GetFileUrlWithQuery(test_file_path, query); + } + + void RunTest(Shell* window, + const std::string& test_case, + const std::string& query) { + GURL url = GetTestURL(test_case, query); + const base::string16 expected_title = base::ASCIIToUTF16("OK"); + TitleWatcher title_watcher(window->web_contents(), expected_title); + NavigateToURL(window, url); + base::string16 final_title = title_watcher.WaitAndGetTitle(); + EXPECT_EQ(expected_title, final_title); + } + + void RunTest(const std::string& test_case, const std::string& query) { + RunTest(shell(), test_case, query); + } + + static void QuitUIMessageLoop(base::Callback callback) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); + } + + void NavigateAndWaitForAuth(const GURL& url) { + ShellContentBrowserClient* browser_client = + ShellContentBrowserClient::Get(); + scoped_refptr runner = new MessageLoopRunner(); + browser_client->resource_dispatcher_host_delegate()-> + set_login_request_callback( + base::Bind(&QuitUIMessageLoop, runner->QuitClosure())); + shell()->LoadURL(url); + runner->Run(); + } +}; + +IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) { + RunTest("single_worker.html", std::string()); +} + +IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) { + RunTest("multi_worker.html", std::string()); +} + +IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) { + RunTest("single_worker.html", "shared=true"); +} + +// http://crbug.com/96435 +IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleSharedWorkers) { + RunTest("multi_worker.html", "shared=true"); +} + +// Incognito windows should not share workers with non-incognito windows +// http://crbug.com/30021 +IN_PROC_BROWSER_TEST_F(WorkerTest, IncognitoSharedWorkers) { + // Load a non-incognito tab and have it create a shared worker + RunTest("incognito_worker.html", std::string()); + + // Incognito worker should not share with non-incognito + RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); +} + +// Make sure that auth dialog is displayed from worker context. +// http://crbug.com/33344 +IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) { + ASSERT_TRUE(test_server()->Start()); + GURL url = test_server()->GetURL("files/workers/worker_auth.html"); + + NavigateAndWaitForAuth(url); +} + +// Make sure that auth dialog is displayed from shared worker context. +// http://crbug.com/33344 +IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) { + ASSERT_TRUE(test_server()->Start()); + GURL url = test_server()->GetURL("files/workers/shared_worker_auth.html"); + NavigateAndWaitForAuth(url); +} + +IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { + // Launch WebSocket server. + net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, + net::SpawnedTestServer::kLocalhost, + net::GetWebSocketTestDataDirectory()); + ASSERT_TRUE(ws_server.Start()); + + // Generate test URL. + std::string scheme("http"); + GURL::Replacements replacements; + replacements.SetSchemeStr(scheme); + GURL url = ws_server.GetURL( + "websocket_shared_worker.html").ReplaceComponents(replacements); + + // Run test. + Shell* window = shell(); + const base::string16 expected_title = base::ASCIIToUTF16("OK"); + TitleWatcher title_watcher(window->web_contents(), expected_title); + NavigateToURL(window, url); + base::string16 final_title = title_watcher.WaitAndGetTitle(); + EXPECT_EQ(expected_title, final_title); +} + +IN_PROC_BROWSER_TEST_F(WorkerTest, PassMessagePortToSharedWorker) { + RunTest("pass_messageport_to_sharedworker.html", ""); +} + +IN_PROC_BROWSER_TEST_F(WorkerTest, + PassMessagePortToSharedWorkerDontWaitForConnect) { + RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); +} + +} // namespace content diff --git a/content/browser/worker_host/worker_document_set.cc b/content/browser/shared_worker/worker_document_set.cc similarity index 95% rename from content/browser/worker_host/worker_document_set.cc rename to content/browser/shared_worker/worker_document_set.cc index 3031493783e8b1..f3ef7d2636d392 100644 --- a/content/browser/worker_host/worker_document_set.cc +++ b/content/browser/shared_worker/worker_document_set.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/worker_host/worker_document_set.h" +#include "content/browser/shared_worker/worker_document_set.h" #include "base/logging.h" diff --git a/content/browser/worker_host/worker_document_set.h b/content/browser/shared_worker/worker_document_set.h similarity index 93% rename from content/browser/worker_host/worker_document_set.h rename to content/browser/shared_worker/worker_document_set.h index e497aa80e53768..54ae9e93daabd3 100644 --- a/content/browser/worker_host/worker_document_set.h +++ b/content/browser/shared_worker/worker_document_set.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_DOCUMENT_SET_H_ -#define CONTENT_BROWSER_WORKER_HOST_WORKER_DOCUMENT_SET_H_ +#ifndef CONTENT_BROWSER_SHARED_WORKER_WORKER_DOCUMENT_SET_H_ +#define CONTENT_BROWSER_SHARED_WORKER_WORKER_DOCUMENT_SET_H_ #include @@ -93,4 +93,4 @@ class WorkerDocumentSet : public base::RefCounted { } // namespace content -#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_DOCUMENT_SET_H_ +#endif // CONTENT_BROWSER_SHARED_WORKER_WORKER_DOCUMENT_SET_H_ diff --git a/content/browser/worker_host/worker_storage_partition.cc b/content/browser/shared_worker/worker_storage_partition.cc similarity index 96% rename from content/browser/worker_host/worker_storage_partition.cc rename to content/browser/shared_worker/worker_storage_partition.cc index e7a5f40660c821..efe2f187dc3621 100644 --- a/content/browser/worker_host/worker_storage_partition.cc +++ b/content/browser/shared_worker/worker_storage_partition.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/worker_host/worker_storage_partition.h" +#include "content/browser/shared_worker/worker_storage_partition.h" #include diff --git a/content/browser/worker_host/worker_storage_partition.h b/content/browser/shared_worker/worker_storage_partition.h similarity index 94% rename from content/browser/worker_host/worker_storage_partition.h rename to content/browser/shared_worker/worker_storage_partition.h index aebd683c3f533e..0053c4fc00fb00 100644 --- a/content/browser/worker_host/worker_storage_partition.h +++ b/content/browser/shared_worker/worker_storage_partition.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ -#define CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ +#ifndef CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ +#define CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ #include "base/memory/ref_counted.h" #include "content/common/content_export.h" @@ -131,4 +131,4 @@ class CONTENT_EXPORT WorkerStoragePartitionId { } // namespace content -#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ +#endif // CONTENT_BROWSER_SHARED_WORKERT_WORKER_STORAGE_PARTITION_H_ diff --git a/content/browser/worker_host/OWNERS b/content/browser/worker_host/OWNERS deleted file mode 100644 index 61fc3fd49ea0fd..00000000000000 --- a/content/browser/worker_host/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -atwilson@chromium.org -kinuko@chromium.org -horo@chromium.org diff --git a/content/browser/worker_host/test/OWNERS b/content/browser/worker_host/test/OWNERS deleted file mode 100644 index ea496eb775d2ff..00000000000000 --- a/content/browser/worker_host/test/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -dimich@chromium.org -jianli@chromium.org -levin@chromium.org -dslomov@chromium.org diff --git a/content/browser/worker_host/test/worker_browsertest.cc b/content/browser/worker_host/test/worker_browsertest.cc deleted file mode 100644 index 861977c1005eb2..00000000000000 --- a/content/browser/worker_host/test/worker_browsertest.cc +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/bind.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/path_service.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "base/strings/utf_string_conversions.h" -#include "base/sys_info.h" -#include "base/test/test_timeouts.h" -#include "content/browser/worker_host/worker_process_host.h" -#include "content/browser/worker_host/worker_service_impl.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/common/content_paths.h" -#include "content/public/test/browser_test_utils.h" -#include "content/public/test/content_browser_test.h" -#include "content/public/test/content_browser_test_utils.h" -#include "content/public/test/test_utils.h" -#include "content/shell/browser/shell.h" -#include "content/shell/browser/shell_content_browser_client.h" -#include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" -#include "net/base/test_data_directory.h" -#include "net/test/spawned_test_server/spawned_test_server.h" -#include "url/gurl.h" - -namespace content { - -class WorkerTest : public ContentBrowserTest { - public: - WorkerTest() {} - - GURL GetTestURL(const std::string& test_case, const std::string& query) { - base::FilePath test_file_path = GetTestFilePath( - "workers", test_case.c_str()); - return GetFileUrlWithQuery(test_file_path, query); - } - - void RunTest(Shell* window, - const std::string& test_case, - const std::string& query) { - GURL url = GetTestURL(test_case, query); - const base::string16 expected_title = base::ASCIIToUTF16("OK"); - TitleWatcher title_watcher(window->web_contents(), expected_title); - NavigateToURL(window, url); - base::string16 final_title = title_watcher.WaitAndGetTitle(); - EXPECT_EQ(expected_title, final_title); - } - - void RunTest(const std::string& test_case, const std::string& query) { - RunTest(shell(), test_case, query); - } - - static void CountWorkerProcesses(int *cur_process_count) { - *cur_process_count = 0; - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) - (*cur_process_count)++; - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure()); - } - - bool WaitForWorkerProcessCount(int count) { - int cur_process_count; - for (int i = 0; i < 100; ++i) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&CountWorkerProcesses, &cur_process_count)); - - RunMessageLoop(); - if (cur_process_count == count) - return true; - - // Sometimes the worker processes can take a while to shut down on the - // bots, so use a longer timeout period to avoid spurious failures. - base::PlatformThread::Sleep(TestTimeouts::action_max_timeout() / 100); - } - - EXPECT_EQ(cur_process_count, count); - return false; - } - - static void QuitUIMessageLoop(base::Callback callback) { - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); - } - - void NavigateAndWaitForAuth(const GURL& url) { - ShellContentBrowserClient* browser_client = - ShellContentBrowserClient::Get(); - scoped_refptr runner = new MessageLoopRunner(); - browser_client->resource_dispatcher_host_delegate()-> - set_login_request_callback( - base::Bind(&QuitUIMessageLoop, runner->QuitClosure())); - shell()->LoadURL(url); - runner->Run(); - } -}; - -IN_PROC_BROWSER_TEST_F(WorkerTest, SingleWorker) { - RunTest("single_worker.html", std::string()); -} - -IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleWorkers) { - RunTest("multi_worker.html", std::string()); -} - -IN_PROC_BROWSER_TEST_F(WorkerTest, SingleSharedWorker) { - RunTest("single_worker.html", "shared=true"); -} - -// http://crbug.com/96435 -IN_PROC_BROWSER_TEST_F(WorkerTest, MultipleSharedWorkers) { - RunTest("multi_worker.html", "shared=true"); -} - -// Incognito windows should not share workers with non-incognito windows -// http://crbug.com/30021 -IN_PROC_BROWSER_TEST_F(WorkerTest, IncognitoSharedWorkers) { - // Load a non-incognito tab and have it create a shared worker - RunTest("incognito_worker.html", std::string()); - - // Incognito worker should not share with non-incognito - RunTest(CreateOffTheRecordBrowser(), "incognito_worker.html", std::string()); -} - -// Make sure that auth dialog is displayed from worker context. -// http://crbug.com/33344 -IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerHttpAuth) { - ASSERT_TRUE(test_server()->Start()); - GURL url = test_server()->GetURL("files/workers/worker_auth.html"); - - NavigateAndWaitForAuth(url); -} - -// Make sure that auth dialog is displayed from shared worker context. -// http://crbug.com/33344 -IN_PROC_BROWSER_TEST_F(WorkerTest, SharedWorkerHttpAuth) { - ASSERT_TRUE(test_server()->Start()); - GURL url = test_server()->GetURL("files/workers/shared_worker_auth.html"); - NavigateAndWaitForAuth(url); -} - -#if defined(OS_LINUX) -// This test is flaky inside the Linux SUID sandbox. -// http://crbug.com/130116 -IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitPerPage) { -#else -IN_PROC_BROWSER_TEST_F(WorkerTest, LimitPerPage) { -#endif - // There is no limitation of SharedWorker if EmbeddedSharedWorker is enabled. - if (WorkerService::EmbeddedSharedWorkerEnabled()) - return; - int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate; - std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1); - - GURL url = GetTestURL("many_shared_workers.html", query); - NavigateToURL(shell(), url); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); -} - - -#if defined(OS_LINUX) || defined(OS_MACOSX) -// This test is flaky inside the Linux SUID sandbox: http://crbug.com/130116 -// Also flaky on Mac: http://crbug.com/295193 -IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_LimitTotal) { -#else -// http://crbug.com/36800 -IN_PROC_BROWSER_TEST_F(WorkerTest, LimitTotal) { -#endif - // There is no limitation of SharedWorker if EmbeddedSharedWorker is enabled. - if (WorkerService::EmbeddedSharedWorkerEnabled()) - return; - if (base::SysInfo::AmountOfPhysicalMemoryMB() < 8192) { - VLOG(0) << "WorkerTest.LimitTotal not running because it needs 8 GB RAM."; - return; - } - - int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate; - int total_workers = WorkerServiceImpl::kMaxWorkersWhenSeparate; - - std::string query = base::StringPrintf("?count=%d", max_workers_per_tab); - GURL url = GetTestURL("many_shared_workers.html", query); - NavigateToURL(shell(), - GURL(url.spec() + base::StringPrintf("&client_id=0"))); - - // Adding 1 so that we cause some workers to be queued. - int tab_count = (total_workers / max_workers_per_tab) + 1; - for (int i = 1; i < tab_count; ++i) { - NavigateToURL( - CreateBrowser(), - GURL(url.spec() + base::StringPrintf("&client_id=%d", i))); - } - - // Check that we didn't create more than the max number of workers. - ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); - - // Now close a page and check that the queued workers were started. - url = GURL(GetTestUrl("google", "google.html")); - NavigateToURL(shell(), url); - - ASSERT_TRUE(WaitForWorkerProcessCount(total_workers)); -} - -// Flaky, http://crbug.com/59786. -IN_PROC_BROWSER_TEST_F(WorkerTest, WorkerClose) { - RunTest("worker_close.html", std::string()); - ASSERT_TRUE(WaitForWorkerProcessCount(0)); -} - -// Flaky, http://crbug.com/70861. -// Times out regularly on Windows debug bots. See http://crbug.com/212339 . -// Times out on Mac as well. -IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerShutdown) { - // Tests to make sure that queued shared workers are started up when shared - // workers shut down. - int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate; - std::string query = base::StringPrintf("?count=%d", max_workers_per_tab); - RunTest("queued_shared_worker_shutdown.html", query); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); -} - -// Flaky, http://crbug.com/69881. -// Sometimes triggers -// Check failed: message_ports_[message_port_id].queued_messages.empty(). -IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_MultipleTabsQueuedSharedWorker) { - // Tests to make sure that only one instance of queued shared workers are - // started up even when those instances are on multiple tabs. - int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate; - std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1); - GURL url = GetTestURL("many_shared_workers.html", query); - NavigateToURL(shell(), url); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); - - // Create same set of workers in new tab (leaves one worker queued from this - // tab). - url = GetTestURL("many_shared_workers.html", query); - NavigateToURL(CreateBrowser(), url); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); - - // Now shutdown one of the shared workers - this will fire both queued - // workers, but only one instance should be started. - url = GetTestURL("shutdown_shared_worker.html", "?id=0"); - NavigateToURL(CreateBrowser(), url); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); -} - -// Flaky: http://crbug.com/48148 -IN_PROC_BROWSER_TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTab) { - // Tests to make sure that queued shared workers are started up when - // an instance is launched from another tab. - int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate; - std::string query = base::StringPrintf("?count=%d", max_workers_per_tab + 1); - GURL url = GetTestURL("many_shared_workers.html", query); - NavigateToURL(shell(), url); - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab)); - - // First window has hit its limit. Now launch second window which creates - // the same worker that was queued in the first window, to ensure it gets - // connected to the first window too. - query = base::StringPrintf("?id=%d", max_workers_per_tab); - url = GetTestURL("single_shared_worker.html", query); - NavigateToURL(CreateBrowser(), url); - - ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); -} - -IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { - // Launch WebSocket server. - net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, - net::SpawnedTestServer::kLocalhost, - net::GetWebSocketTestDataDirectory()); - ASSERT_TRUE(ws_server.Start()); - - // Generate test URL. - std::string scheme("http"); - GURL::Replacements replacements; - replacements.SetSchemeStr(scheme); - GURL url = ws_server.GetURL( - "websocket_shared_worker.html").ReplaceComponents(replacements); - - // Run test. - Shell* window = shell(); - const base::string16 expected_title = base::ASCIIToUTF16("OK"); - TitleWatcher title_watcher(window->web_contents(), expected_title); - NavigateToURL(window, url); - base::string16 final_title = title_watcher.WaitAndGetTitle(); - EXPECT_EQ(expected_title, final_title); -} - -IN_PROC_BROWSER_TEST_F(WorkerTest, PassMessagePortToSharedWorker) { - RunTest("pass_messageport_to_sharedworker.html", ""); -} - -IN_PROC_BROWSER_TEST_F(WorkerTest, - PassMessagePortToSharedWorkerDontWaitForConnect) { - RunTest("pass_messageport_to_sharedworker_dont_wait_for_connect.html", ""); -} - -} // namespace content diff --git a/content/browser/worker_host/worker_message_filter.cc b/content/browser/worker_host/worker_message_filter.cc deleted file mode 100644 index 62348b5ff0b1b3..00000000000000 --- a/content/browser/worker_host/worker_message_filter.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/worker_host/worker_message_filter.h" - -#include "content/browser/message_port_message_filter.h" -#include "content/browser/worker_host/worker_service_impl.h" -#include "content/common/view_messages.h" -#include "content/common/worker_messages.h" -#include "content/public/browser/resource_context.h" - -namespace content { - -WorkerMessageFilter::WorkerMessageFilter( - int render_process_id, - ResourceContext* resource_context, - const WorkerStoragePartition& partition, - MessagePortMessageFilter* message_port_message_filter) - : BrowserMessageFilter(ViewMsgStart), - render_process_id_(render_process_id), - resource_context_(resource_context), - partition_(partition), - message_port_message_filter_(message_port_message_filter) { - // Note: This constructor is called on both IO or UI thread. - DCHECK(resource_context); -} - -WorkerMessageFilter::~WorkerMessageFilter() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -} - -void WorkerMessageFilter::OnChannelClosing() { - WorkerServiceImpl::GetInstance()->OnWorkerMessageFilterClosing(this); -} - -bool WorkerMessageFilter::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WorkerMessageFilter, message) - // Worker messages. - // Only sent from renderer for now, until we have nested workers. - IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWorker, OnCreateWorker) - IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker, OnForwardToWorker) - // Only sent from renderer. - IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentDetached, OnDocumentDetached) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - - return handled; -} - -int WorkerMessageFilter::GetNextRoutingID() { - return message_port_message_filter_->GetNextRoutingID(); -} - -void WorkerMessageFilter::OnCreateWorker( - const ViewHostMsg_CreateWorker_Params& params, - int* route_id) { - bool url_error = false; - *route_id = GetNextRoutingID(); - WorkerServiceImpl::GetInstance()->CreateWorker( - params, *route_id, this, resource_context_, partition_, &url_error); - if (url_error) - *route_id = MSG_ROUTING_NONE; -} - -void WorkerMessageFilter::OnForwardToWorker(const IPC::Message& message) { - WorkerServiceImpl::GetInstance()->ForwardToWorker(message, this); -} - -void WorkerMessageFilter::OnDocumentDetached(unsigned long long document_id) { - WorkerServiceImpl::GetInstance()->DocumentDetached(document_id, this); -} - -} // namespace content diff --git a/content/browser/worker_host/worker_message_filter.h b/content/browser/worker_host/worker_message_filter.h deleted file mode 100644 index ab9bade8e64f34..00000000000000 --- a/content/browser/worker_host/worker_message_filter.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_ - -#include "base/callback.h" -#include "content/browser/worker_host/worker_storage_partition.h" -#include "content/public/browser/browser_message_filter.h" - -class ResourceDispatcherHost; -struct ViewHostMsg_CreateWorker_Params; - -namespace content { -class MessagePortMessageFilter; -class ResourceContext; - -class WorkerMessageFilter : public BrowserMessageFilter { - public: - WorkerMessageFilter(int render_process_id, - ResourceContext* resource_context, - const WorkerStoragePartition& partition, - MessagePortMessageFilter* message_port_filter); - - // BrowserMessageFilter implementation. - virtual void OnChannelClosing() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - - int GetNextRoutingID(); - int render_process_id() const { return render_process_id_; } - - MessagePortMessageFilter* message_port_message_filter() const { - return message_port_message_filter_; - } - - private: - virtual ~WorkerMessageFilter(); - - // Message handlers. - void OnCreateWorker(const ViewHostMsg_CreateWorker_Params& params, - int* route_id); - void OnForwardToWorker(const IPC::Message& message); - void OnDocumentDetached(unsigned long long document_id); - - int render_process_id_; - ResourceContext* const resource_context_; - WorkerStoragePartition partition_; - - MessagePortMessageFilter* message_port_message_filter_; - DISALLOW_IMPLICIT_CONSTRUCTORS(WorkerMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_MESSAGE_FILTER_H_ diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc deleted file mode 100644 index 960baf693e0d31..00000000000000 --- a/content/browser/worker_host/worker_process_host.cc +++ /dev/null @@ -1,845 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/worker_host/worker_process_host.h" - -#include -#include -#include - -#include "base/base_switches.h" -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/callback.h" -#include "base/command_line.h" -#include "base/message_loop/message_loop.h" -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" -#include "content/browser/appcache/appcache_dispatcher_host.h" -#include "content/browser/appcache/chrome_appcache_service.h" -#include "content/browser/browser_child_process_host_impl.h" -#include "content/browser/child_process_security_policy_impl.h" -#include "content/browser/devtools/worker_devtools_manager.h" -#include "content/browser/devtools/worker_devtools_message_filter.h" -#include "content/browser/fileapi/fileapi_message_filter.h" -#include "content/browser/frame_host/render_frame_host_delegate.h" -#include "content/browser/frame_host/render_frame_host_impl.h" -#include "content/browser/indexed_db/indexed_db_dispatcher_host.h" -#include "content/browser/loader/resource_message_filter.h" -#include "content/browser/message_port_message_filter.h" -#include "content/browser/message_port_service.h" -#include "content/browser/mime_registry_message_filter.h" -#include "content/browser/quota_dispatcher_host.h" -#include "content/browser/renderer_host/database_message_filter.h" -#include "content/browser/renderer_host/file_utilities_message_filter.h" -#include "content/browser/renderer_host/render_view_host_delegate.h" -#include "content/browser/renderer_host/render_view_host_impl.h" -#include "content/browser/renderer_host/socket_stream_dispatcher_host.h" -#include "content/browser/renderer_host/websocket_dispatcher_host.h" -#include "content/browser/resource_context_impl.h" -#include "content/browser/worker_host/worker_message_filter.h" -#include "content/browser/worker_host/worker_service_impl.h" -#include "content/common/child_process_host_impl.h" -#include "content/common/view_messages.h" -#include "content/common/worker_messages.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/content_browser_client.h" -#include "content/public/browser/user_metrics.h" -#include "content/public/common/content_switches.h" -#include "content/public/common/resource_type.h" -#include "content/public/common/result_codes.h" -#include "content/public/common/sandboxed_process_launcher_delegate.h" -#include "ipc/ipc_switches.h" -#include "net/base/mime_util.h" -#include "net/base/registry_controlled_domains/registry_controlled_domain.h" -#include "net/url_request/url_request_context_getter.h" -#include "ui/base/ui_base_switches.h" -#include "webkit/browser/fileapi/file_system_context.h" -#include "webkit/browser/fileapi/sandbox_file_system_backend.h" - -#if defined(OS_WIN) -#include "content/common/sandbox_win.h" -#endif - -namespace content { -namespace { - -// NOTE: changes to this class need to be reviewed by the security team. -class WorkerSandboxedProcessLauncherDelegate - : public content::SandboxedProcessLauncherDelegate { - public: - WorkerSandboxedProcessLauncherDelegate(ChildProcessHost* host, - bool debugging_child) -#if defined(OS_POSIX) - : ipc_fd_(host->TakeClientFileDescriptor()), - debugging_child_(debugging_child) -#endif // OS_POSIX - {} - - virtual ~WorkerSandboxedProcessLauncherDelegate() {} - -#if defined(OS_WIN) - virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, - bool* success) { - AddBaseHandleClosePolicy(policy); - } -#elif defined(OS_POSIX) - virtual bool ShouldUseZygote() OVERRIDE { - return !debugging_child_; - } - virtual int GetIpcFd() OVERRIDE { - return ipc_fd_; - } -#endif // OS_WIN - - private: -#if defined(OS_POSIX) - int ipc_fd_; - bool debugging_child_; -#endif // OS_POSIX -}; - -// Notifies RenderViewHost that one or more worker objects crashed. -void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) { - RenderFrameHostImpl* host = - RenderFrameHostImpl::FromID(render_process_unique_id, render_frame_id); - if (host) - host->delegate()->WorkerCrashed(host); -} - -void WorkerCreatedCallback(int render_process_id, - int render_frame_id, - int worker_process_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - RenderFrameHost* render_frame_host = - RenderFrameHost::FromID(render_process_id, render_frame_id); - if (!render_frame_host) - return; - SiteInstance* site_instance = render_frame_host->GetSiteInstance(); - GetContentClient()->browser()->WorkerProcessCreated(site_instance, - worker_process_id); -} - -void WorkerTerminatedCallback(int render_process_id, - int render_frame_id, - int worker_process_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - RenderFrameHost* render_frame_host = - RenderFrameHost::FromID(render_process_id, render_frame_id); - if (!render_frame_host) - return; - SiteInstance* site_instance = render_frame_host->GetSiteInstance(); - GetContentClient()->browser()->WorkerProcessTerminated(site_instance, - worker_process_id); -} - -} // namespace - -WorkerProcessHost::WorkerProcessHost( - ResourceContext* resource_context, - const WorkerStoragePartition& partition) - : resource_context_(resource_context), - partition_(partition), - process_launched_(false), - weak_factory_(this) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DCHECK(resource_context_); - process_.reset( - new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); -} - -WorkerProcessHost::~WorkerProcessHost() { - // If we crashed, tell the RenderViewHosts. - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (!i->load_failed()) { - const WorkerDocumentSet::DocumentInfoSet& parents = - i->worker_document_set()->documents(); - for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter = - parents.begin(); parent_iter != parents.end(); ++parent_iter) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerCrashCallback, parent_iter->render_process_id(), - parent_iter->render_frame_id())); - } - } - WorkerServiceImpl::GetInstance()->NotifyWorkerDestroyed( - this, i->worker_route_id()); - } - - ChildProcessSecurityPolicyImpl::GetInstance()->Remove( - process_->GetData().id); -} - -bool WorkerProcessHost::Send(IPC::Message* message) { - return process_->Send(message); -} - -bool WorkerProcessHost::Init(int render_process_id, int render_frame_id) { - std::string channel_id = process_->GetHost()->CreateChannel(); - if (channel_id.empty()) - return false; - -#if defined(OS_LINUX) - int flags = ChildProcessHost::CHILD_ALLOW_SELF; -#else - int flags = ChildProcessHost::CHILD_NORMAL; -#endif - - base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); - if (exe_path.empty()) - return false; - - CommandLine* cmd_line = new CommandLine(exe_path); - cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kWorkerProcess); - cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); - std::string locale = GetContentClient()->browser()->GetApplicationLocale(); - cmd_line->AppendSwitchASCII(switches::kLang, locale); - - static const char* const kSwitchNames[] = { - switches::kDisableApplicationCache, - switches::kDisableDatabases, -#if defined(OS_WIN) - switches::kDisableDesktopNotifications, -#endif - switches::kDisableFileSystem, - switches::kDisableSeccompFilterSandbox, - switches::kEnableExperimentalWebPlatformFeatures, - switches::kEnablePreciseMemoryInfo, -#if defined(OS_MACOSX) - switches::kEnableSandboxLogging, -#endif - switches::kJavaScriptFlags, - switches::kNoSandbox - }; - cmd_line->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), kSwitchNames, - arraysize(kSwitchNames)); - -bool debugging_child = false; -#if defined(OS_POSIX) - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kWaitForDebuggerChildren)) { - // Look to pass-on the kWaitForDebugger flag. - std::string value = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kWaitForDebuggerChildren); - if (value.empty() || value == switches::kWorkerProcess) { - cmd_line->AppendSwitch(switches::kWaitForDebugger); - debugging_child = true; - } - } -#endif - - process_->Launch( - new WorkerSandboxedProcessLauncherDelegate(process_->GetHost(), - debugging_child), - cmd_line); - - ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker( - process_->GetData().id, render_process_id); - CreateMessageFilters(render_process_id); - - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerCreatedCallback, - render_process_id, - render_frame_id, - process_->GetData().id)); - return true; -} - -void WorkerProcessHost::CreateMessageFilters(int render_process_id) { - ChromeBlobStorageContext* blob_storage_context = - GetChromeBlobStorageContextForResourceContext(resource_context_); - StreamContext* stream_context = - GetStreamContextForResourceContext(resource_context_); - - net::URLRequestContextGetter* url_request_context = - partition_.url_request_context(); - - ResourceMessageFilter::GetContextsCallback get_contexts_callback( - base::Bind(&WorkerProcessHost::GetContexts, - base::Unretained(this))); - - ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( - process_->GetData().id, PROCESS_TYPE_WORKER, - partition_.appcache_service(), - blob_storage_context, - partition_.filesystem_context(), - partition_.service_worker_context(), - get_contexts_callback); - process_->AddFilter(resource_message_filter); - - MessagePortMessageFilter* message_port_message_filter = - new MessagePortMessageFilter( - base::Bind(&WorkerServiceImpl::next_worker_route_id, - base::Unretained(WorkerServiceImpl::GetInstance()))); - process_->AddFilter(message_port_message_filter); - worker_message_filter_ = new WorkerMessageFilter(render_process_id, - resource_context_, - partition_, - message_port_message_filter); - process_->AddFilter(worker_message_filter_.get()); - process_->AddFilter(new AppCacheDispatcherHost( - partition_.appcache_service(), process_->GetData().id)); - process_->AddFilter(new FileAPIMessageFilter( - process_->GetData().id, - url_request_context, - partition_.filesystem_context(), - blob_storage_context, - stream_context)); - process_->AddFilter(new FileUtilitiesMessageFilter( - process_->GetData().id)); - process_->AddFilter(new MimeRegistryMessageFilter()); - process_->AddFilter(new DatabaseMessageFilter(partition_.database_tracker())); - process_->AddFilter(new QuotaDispatcherHost( - process_->GetData().id, - partition_.quota_manager(), - GetContentClient()->browser()->CreateQuotaPermissionContext())); - - SocketStreamDispatcherHost::GetRequestContextCallback - request_context_callback( - base::Bind(&WorkerProcessHost::GetRequestContext, - base::Unretained(this))); - - SocketStreamDispatcherHost* socket_stream_dispatcher_host = - new SocketStreamDispatcherHost( - render_process_id, - request_context_callback, - resource_context_); - socket_stream_dispatcher_host_ = socket_stream_dispatcher_host; - process_->AddFilter(socket_stream_dispatcher_host); - - WebSocketDispatcherHost::GetRequestContextCallback - websocket_request_context_callback( - base::Bind(&WorkerProcessHost::GetRequestContext, - base::Unretained(this), - ResourceType::SUB_RESOURCE)); - - process_->AddFilter(new WebSocketDispatcherHost( - render_process_id, websocket_request_context_callback)); - - process_->AddFilter(new WorkerDevToolsMessageFilter(process_->GetData().id)); - process_->AddFilter( - new IndexedDBDispatcherHost(process_->GetData().id, - url_request_context, - partition_.indexed_db_context(), - blob_storage_context)); -} - -void WorkerProcessHost::CreateWorker(const WorkerInstance& instance, - bool pause_on_start) { - ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( - process_->GetData().id, instance.url()); - - instances_.push_back(instance); - - WorkerProcessMsg_CreateWorker_Params params; - params.url = instance.url(); - params.name = instance.name(); - params.content_security_policy = instance.content_security_policy(); - params.security_policy_type = instance.security_policy_type(); - params.pause_on_start = pause_on_start; - params.route_id = instance.worker_route_id(); - Send(new WorkerProcessMsg_CreateWorker(params)); - - UpdateTitle(); - - // Walk all pending filters and let them know the worker has been created - // (could be more than one in the case where we had to queue up worker - // creation because the worker process limit was reached). - for (WorkerInstance::FilterList::const_iterator i = - instance.filters().begin(); - i != instance.filters().end(); ++i) { - i->filter()->Send(new ViewMsg_WorkerCreated(i->route_id())); - } -} - -bool WorkerProcessHost::FilterMessage(const IPC::Message& message, - WorkerMessageFilter* filter) { - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (!i->closed() && i->HasFilter(filter, message.routing_id())) { - RelayMessage(message, filter, &(*i)); - return true; - } - } - - return false; -} - -void WorkerProcessHost::OnProcessLaunched() { - process_launched_ = true; - - WorkerServiceImpl::GetInstance()->NotifyWorkerProcessCreated(); -} - -bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WorkerProcessHost, message) - IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, - OnWorkerContextClosed) - IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextDestroyed, - OnWorkerContextDestroyed) - IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoaded, - OnWorkerScriptLoaded) - IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoadFailed, - OnWorkerScriptLoadFailed) - IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerConnected, - OnWorkerConnected) - IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) - IPC_MESSAGE_HANDLER_DELAY_REPLY( - WorkerProcessHostMsg_RequestFileSystemAccessSync, - OnRequestFileSystemAccess) - IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) - IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, - OnForceKillWorkerProcess) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - - return handled; -} - -// Sent to notify the browser process when a worker context invokes close(), so -// no new connections are sent to shared workers. -void WorkerProcessHost::OnWorkerContextClosed(int worker_route_id) { - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (i->worker_route_id() == worker_route_id) { - // Set the closed flag - this will stop any further messages from - // being sent to the worker (messages can still be sent from the worker, - // for exception reporting, etc). - i->set_closed(true); - break; - } - } -} - -void WorkerProcessHost::OnWorkerContextDestroyed(int worker_route_id) { - WorkerServiceImpl::GetInstance()->NotifyWorkerDestroyed( - this, worker_route_id); - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (i->worker_route_id() == worker_route_id) { - instances_.erase(i); - UpdateTitle(); - return; - } - } -} - -void WorkerProcessHost::OnWorkerScriptLoaded(int worker_route_id) { - WorkerDevToolsManager::GetInstance()->WorkerContextStarted(this, - worker_route_id); -} - -void WorkerProcessHost::OnWorkerScriptLoadFailed(int worker_route_id) { - bool shutdown = true; - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (i->worker_route_id() != worker_route_id) { - shutdown = false; - continue; - } - i->set_load_failed(true); - for (WorkerInstance::FilterList::const_iterator j = i->filters().begin(); - j != i->filters().end(); ++j) { - j->filter()->Send(new ViewMsg_WorkerScriptLoadFailed(j->route_id())); - } - } - if (shutdown) { - base::KillProcess( - process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); - } -} - -void WorkerProcessHost::OnWorkerConnected(int message_port_id, - int worker_route_id) { - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - if (i->worker_route_id() != worker_route_id) - continue; - for (WorkerInstance::FilterList::const_iterator j = i->filters().begin(); - j != i->filters().end(); ++j) { - if (j->message_port_id() != message_port_id) - continue; - j->filter()->Send(new ViewMsg_WorkerConnected(j->route_id())); - return; - } - } -} - -void WorkerProcessHost::OnAllowDatabase(int worker_route_id, - const GURL& url, - const base::string16& name, - const base::string16& display_name, - unsigned long estimated_size, - bool* result) { - *result = GetContentClient()->browser()->AllowWorkerDatabase( - url, name, display_name, estimated_size, resource_context_, - GetRenderFrameIDsForWorker(worker_route_id)); -} - -void WorkerProcessHost::OnRequestFileSystemAccess(int worker_route_id, - const GURL& url, - IPC::Message* reply_msg) { - GetContentClient()->browser()->AllowWorkerFileSystem( - url, - resource_context_, - GetRenderFrameIDsForWorker(worker_route_id), - base::Bind(&WorkerProcessHost::OnRequestFileSystemAccessResponse, - weak_factory_.GetWeakPtr(), - base::Passed(scoped_ptr(reply_msg)))); -} - -void WorkerProcessHost::OnRequestFileSystemAccessResponse( - scoped_ptr reply_msg, - bool allowed) { - WorkerProcessHostMsg_RequestFileSystemAccessSync::WriteReplyParams( - reply_msg.get(), - allowed); - Send(reply_msg.release()); -} - -void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, - const GURL& url, - const base::string16& name, - bool* result) { - *result = GetContentClient()->browser()->AllowWorkerIndexedDB( - url, name, resource_context_, - GetRenderFrameIDsForWorker(worker_route_id)); -} - -void WorkerProcessHost::OnForceKillWorkerProcess() { - if (process_ && process_launched_) - base::KillProcess( - process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); - else - RecordAction(base::UserMetricsAction("WorkerProcess_BadProcessToKill")); -} - -void WorkerProcessHost::RelayMessage( - const IPC::Message& message, - WorkerMessageFilter* incoming_filter, - WorkerInstance* instance) { - if (message.type() == WorkerMsg_Connect::ID) { - // Crack the SharedWorker Connect message to setup routing for the port. - WorkerMsg_Connect::Param params; - if (!WorkerMsg_Connect::Read(&message, ¶ms)) - return; - - int sent_message_port_id = params.a; - int new_routing_id = params.b; - new_routing_id = worker_message_filter_->GetNextRoutingID(); - MessagePortService::GetInstance()->UpdateMessagePort( - sent_message_port_id, - worker_message_filter_->message_port_message_filter(), - new_routing_id); - - instance->SetMessagePortID(incoming_filter, - message.routing_id(), - sent_message_port_id); - // Resend the message with the new routing id. - worker_message_filter_->Send(new WorkerMsg_Connect( - instance->worker_route_id(), sent_message_port_id, new_routing_id)); - - // Send any queued messages for the sent port. - MessagePortService::GetInstance()->SendQueuedMessagesIfPossible( - sent_message_port_id); - } else { - IPC::Message* new_message = new IPC::Message(message); - new_message->set_routing_id(instance->worker_route_id()); - worker_message_filter_->Send(new_message); - return; - } -} - -void WorkerProcessHost::ShutdownSocketStreamDispatcherHostIfNecessary() { - if (!instances_.size() && socket_stream_dispatcher_host_.get()) { - // We can assume that this object is going to delete, because - // currently a WorkerInstance will never be added to a WorkerProcessHost - // once it is initialized. - - // SocketStreamDispatcherHost should be notified now that the worker - // process will shutdown soon. - socket_stream_dispatcher_host_->Shutdown(); - socket_stream_dispatcher_host_ = NULL; - } -} - -void WorkerProcessHost::FilterShutdown(WorkerMessageFilter* filter) { - for (Instances::iterator i = instances_.begin(); i != instances_.end();) { - bool shutdown = false; - i->RemoveFilters(filter); - - int render_frame_id = 0; - const WorkerDocumentSet::DocumentInfoSet& documents = - i->worker_document_set()->documents(); - for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = - documents.begin(); doc != documents.end(); ++doc) { - if (doc->filter() == filter) { - render_frame_id = doc->render_frame_id(); - break; - } - } - i->worker_document_set()->RemoveAll(filter); - if (i->worker_document_set()->IsEmpty()) { - shutdown = true; - } - if (shutdown) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerTerminatedCallback, - filter->render_process_id(), - render_frame_id, - process_->GetData().id)); - Send(new WorkerMsg_TerminateWorkerContext(i->worker_route_id())); - i = instances_.erase(i); - } else { - ++i; - } - } - ShutdownSocketStreamDispatcherHostIfNecessary(); -} - -bool WorkerProcessHost::CanShutdown() { - return instances_.empty(); -} - -void WorkerProcessHost::UpdateTitle() { - std::set titles; - for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { - // Allow the embedder first crack at special casing the title. - std::string title = GetContentClient()->browser()-> - GetWorkerProcessTitle(i->url(), resource_context_); - - if (title.empty()) { - title = net::registry_controlled_domains::GetDomainAndRegistry( - i->url(), - net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); - } - - // Use the host name if the domain is empty, i.e. localhost or IP address. - if (title.empty()) - title = i->url().host(); - - // If the host name is empty, i.e. file url, use the path. - if (title.empty()) - title = i->url().path(); - titles.insert(title); - } - - std::string display_title; - for (std::set::iterator i = titles.begin(); - i != titles.end(); ++i) { - if (!display_title.empty()) - display_title += ", "; - display_title += *i; - } - - process_->SetName(base::UTF8ToUTF16(display_title)); -} - -void WorkerProcessHost::DocumentDetached(WorkerMessageFilter* filter, - unsigned long long document_id) { - // Walk all instances and remove the document from their document set. - for (Instances::iterator i = instances_.begin(); i != instances_.end();) { - int render_frame_id = 0; - const WorkerDocumentSet::DocumentInfoSet& documents = - i->worker_document_set()->documents(); - for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = - documents.begin(); doc != documents.end(); ++doc) { - if (doc->filter() == filter && doc->document_id() == document_id) { - render_frame_id = doc->render_frame_id(); - break; - } - } - i->worker_document_set()->Remove(filter, document_id); - if (i->worker_document_set()->IsEmpty()) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerTerminatedCallback, - filter->render_process_id(), - render_frame_id, - process_->GetData().id)); - // This worker has no more associated documents - shut it down. - Send(new WorkerMsg_TerminateWorkerContext(i->worker_route_id())); - i = instances_.erase(i); - } else { - ++i; - } - } - ShutdownSocketStreamDispatcherHostIfNecessary(); -} - -void WorkerProcessHost::TerminateWorker(int worker_route_id) { - Send(new WorkerMsg_TerminateWorkerContext(worker_route_id)); -} - -void WorkerProcessHost::SetBackgrounded(bool backgrounded) { - process_->SetBackgrounded(backgrounded); -} - -const ChildProcessData& WorkerProcessHost::GetData() { - return process_->GetData(); -} - -std::vector > WorkerProcessHost::GetRenderFrameIDsForWorker( - int worker_route_id) { - std::vector > result; - WorkerProcessHost::Instances::const_iterator i; - for (i = instances_.begin(); i != instances_.end(); ++i) { - if (i->worker_route_id() != worker_route_id) - continue; - const WorkerDocumentSet::DocumentInfoSet& documents = - i->worker_document_set()->documents(); - for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = - documents.begin(); doc != documents.end(); ++doc) { - result.push_back( - std::make_pair(doc->render_process_id(), doc->render_frame_id())); - } - break; - } - return result; -} - -void WorkerProcessHost::GetContexts(const ResourceHostMsg_Request& request, - ResourceContext** resource_context, - net::URLRequestContext** request_context) { - *resource_context = resource_context_; - *request_context = partition_.url_request_context()->GetURLRequestContext(); -} - -net::URLRequestContext* WorkerProcessHost::GetRequestContext( - ResourceType::Type resource_type) { - return partition_.url_request_context()->GetURLRequestContext(); -} - -WorkerProcessHost::WorkerInstance::WorkerInstance( - const GURL& url, - const base::string16& name, - const base::string16& content_security_policy, - blink::WebContentSecurityPolicyType security_policy_type, - int worker_route_id, - int render_frame_id, - ResourceContext* resource_context, - const WorkerStoragePartition& partition) - : url_(url), - closed_(false), - name_(name), - content_security_policy_(content_security_policy), - security_policy_type_(security_policy_type), - worker_route_id_(worker_route_id), - render_frame_id_(render_frame_id), - worker_document_set_(new WorkerDocumentSet()), - resource_context_(resource_context), - partition_(partition), - load_failed_(false) { - DCHECK(resource_context_); -} - -WorkerProcessHost::WorkerInstance::~WorkerInstance() { -} - -void WorkerProcessHost::WorkerInstance::SetMessagePortID( - WorkerMessageFilter* filter, - int route_id, - int message_port_id) { - for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { - if (i->filter() == filter && i->route_id() == route_id) { - i->set_message_port_id(message_port_id); - return; - } - } -} - -// Compares an instance based on the algorithm in the WebWorkers spec - an -// instance matches if the origins of the URLs match, and: -// a) the names are non-empty and equal -// -or- -// b) the names are both empty, and the urls are equal -bool WorkerProcessHost::WorkerInstance::Matches( - const GURL& match_url, - const base::string16& match_name, - const WorkerStoragePartition& partition, - ResourceContext* resource_context) const { - // Only match open shared workers. - if (closed_) - return false; - - // ResourceContext equivalence is being used as a proxy to ensure we only - // matched shared workers within the same BrowserContext. - if (resource_context_ != resource_context) - return false; - - // We must be in the same storage partition otherwise sharing will violate - // isolation. - if (!partition_.Equals(partition)) - return false; - - if (url_.GetOrigin() != match_url.GetOrigin()) - return false; - - if (name_.empty() && match_name.empty()) - return url_ == match_url; - - return name_ == match_name; -} - -void WorkerProcessHost::WorkerInstance::AddFilter(WorkerMessageFilter* filter, - int route_id) { - CHECK(filter); - if (!HasFilter(filter, route_id)) { - FilterInfo info(filter, route_id); - filters_.push_back(info); - } -} - -void WorkerProcessHost::WorkerInstance::RemoveFilter( - WorkerMessageFilter* filter, int route_id) { - for (FilterList::iterator i = filters_.begin(); i != filters_.end();) { - if (i->filter() == filter && i->route_id() == route_id) - i = filters_.erase(i); - else - ++i; - } - // Should not be duplicate copies in the filter set. - DCHECK(!HasFilter(filter, route_id)); -} - -void WorkerProcessHost::WorkerInstance::RemoveFilters( - WorkerMessageFilter* filter) { - for (FilterList::iterator i = filters_.begin(); i != filters_.end();) { - if (i->filter() == filter) - i = filters_.erase(i); - else - ++i; - } -} - -bool WorkerProcessHost::WorkerInstance::HasFilter( - WorkerMessageFilter* filter, int route_id) const { - for (FilterList::const_iterator i = filters_.begin(); i != filters_.end(); - ++i) { - if (i->filter() == filter && i->route_id() == route_id) - return true; - } - return false; -} - -bool WorkerProcessHost::WorkerInstance::FrameIsParent( - int render_process_id, int render_frame_id) const { - const WorkerDocumentSet::DocumentInfoSet& parents = - worker_document_set()->documents(); - for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter = - parents.begin(); - parent_iter != parents.end(); ++parent_iter) { - if (parent_iter->render_process_id() == render_process_id && - parent_iter->render_frame_id() == render_frame_id) { - return true; - } - } - return false; -} - -WorkerProcessHost::WorkerInstance::FilterInfo -WorkerProcessHost::WorkerInstance::GetFilter() const { - DCHECK(NumFilters() == 1); - return *filters_.begin(); -} - -} // namespace content diff --git a/content/browser/worker_host/worker_process_host.h b/content/browser/worker_host/worker_process_host.h deleted file mode 100644 index 48e5607b8fc47d..00000000000000 --- a/content/browser/worker_host/worker_process_host.h +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ -#define CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ - -#include -#include -#include - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "content/browser/worker_host/worker_document_set.h" -#include "content/browser/worker_host/worker_storage_partition.h" -#include "content/common/content_export.h" -#include "content/public/browser/browser_child_process_host_delegate.h" -#include "content/public/browser/browser_child_process_host_iterator.h" -#include "content/public/common/process_type.h" -#include "content/public/common/resource_type.h" -#include "ipc/ipc_sender.h" -#include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" -#include "url/gurl.h" - -struct ResourceHostMsg_Request; - -namespace fileapi { -class FileSystemContext; -} // namespace fileapi - -namespace net { -class URLRequestContext; -} - -namespace webkit_database { -class DatabaseTracker; -} // namespace webkit_database - -namespace content { -class BrowserChildProcessHostImpl; -class IndexedDBContextImpl; -class ResourceContext; -class SocketStreamDispatcherHost; -class WorkerMessageFilter; -class WorkerServiceImpl; - -// The WorkerProcessHost is the interface that represents the browser side of -// the browser <-> worker communication channel. There will be one -// WorkerProcessHost per worker process. Currently each worker runs in its own -// process, but that may change. However, we do assume (by storing a -// net::URLRequestContext) that a WorkerProcessHost serves a single -// BrowserContext. -class WorkerProcessHost : public BrowserChildProcessHostDelegate, - public IPC::Sender { - public: - // Contains information about each worker instance, needed to forward messages - // between the renderer and worker processes. - class WorkerInstance { - public: - WorkerInstance(const GURL& url, - const base::string16& name, - const base::string16& content_security_policy, - blink::WebContentSecurityPolicyType security_policy_type, - int worker_route_id, - int render_frame_id, - ResourceContext* resource_context, - const WorkerStoragePartition& partition); - ~WorkerInstance(); - - // Unique identifier for a worker client. - class FilterInfo { - public: - FilterInfo(WorkerMessageFilter* filter, int route_id) - : filter_(filter), route_id_(route_id), message_port_id_(0) { } - WorkerMessageFilter* filter() const { return filter_; } - int route_id() const { return route_id_; } - int message_port_id() const { return message_port_id_; } - void set_message_port_id(int id) { message_port_id_ = id; } - - private: - WorkerMessageFilter* filter_; - int route_id_; - int message_port_id_; - }; - - // APIs to manage the filter list for a given instance. - void AddFilter(WorkerMessageFilter* filter, int route_id); - void RemoveFilter(WorkerMessageFilter* filter, int route_id); - void RemoveFilters(WorkerMessageFilter* filter); - bool HasFilter(WorkerMessageFilter* filter, int route_id) const; - bool FrameIsParent(int render_process_id, int render_frame_id) const; - int NumFilters() const { return filters_.size(); } - void SetMessagePortID(WorkerMessageFilter* filter, - int route_id, - int message_port_id); - // Returns the single filter (must only be one). - FilterInfo GetFilter() const; - - typedef std::list FilterList; - const FilterList& filters() const { return filters_; } - - // Checks if this WorkerInstance matches the passed url/name params - // (per the comparison algorithm in the WebWorkers spec). This API only - // applies to shared workers. - bool Matches( - const GURL& url, - const base::string16& name, - const WorkerStoragePartition& partition, - ResourceContext* resource_context) const; - - // Shares the passed instance's WorkerDocumentSet with this instance. This - // instance's current WorkerDocumentSet is dereferenced (and freed if this - // is the only reference) as a result. - void ShareDocumentSet(const WorkerInstance& instance) { - worker_document_set_ = instance.worker_document_set_; - }; - - // Accessors - bool closed() const { return closed_; } - void set_closed(bool closed) { closed_ = closed; } - const GURL& url() const { return url_; } - const base::string16 name() const { return name_; } - const base::string16 content_security_policy() const { - return content_security_policy_; - } - blink::WebContentSecurityPolicyType security_policy_type() const { - return security_policy_type_; - } - int worker_route_id() const { return worker_route_id_; } - int render_frame_id() const { return render_frame_id_; } - WorkerDocumentSet* worker_document_set() const { - return worker_document_set_.get(); - } - ResourceContext* resource_context() const { - return resource_context_; - } - const WorkerStoragePartition& partition() const { - return partition_; - } - void set_load_failed(bool failed) { load_failed_ = failed; } - bool load_failed() { return load_failed_; } - - private: - // Set of all filters (clients) associated with this worker. - GURL url_; - bool closed_; - base::string16 name_; - base::string16 content_security_policy_; - blink::WebContentSecurityPolicyType security_policy_type_; - int worker_route_id_; - int render_frame_id_; - FilterList filters_; - scoped_refptr worker_document_set_; - ResourceContext* const resource_context_; - WorkerStoragePartition partition_; - bool load_failed_; - }; - - WorkerProcessHost(ResourceContext* resource_context, - const WorkerStoragePartition& partition); - virtual ~WorkerProcessHost(); - - // IPC::Sender implementation: - virtual bool Send(IPC::Message* message) OVERRIDE; - - // Starts the process. Returns true iff it succeeded. - // |render_process_id| and |render_frame_id| are the renderer process and the - // renderer frame responsible for starting this worker. - bool Init(int render_process_id, int render_frame_id); - - // Creates a worker object in the process. - void CreateWorker(const WorkerInstance& instance, bool pause_on_start); - - // Returns true iff the given message from a renderer process was forwarded to - // the worker. - bool FilterMessage(const IPC::Message& message, WorkerMessageFilter* filter); - - void FilterShutdown(WorkerMessageFilter* filter); - - // Shuts down any shared workers that are no longer referenced by active - // documents. - void DocumentDetached(WorkerMessageFilter* filter, - unsigned long long document_id); - - // Terminates the given worker, i.e. based on a UI action. - CONTENT_EXPORT void TerminateWorker(int worker_route_id); - - // Callers can reduce the WorkerProcess' priority. - void SetBackgrounded(bool backgrounded); - - CONTENT_EXPORT const ChildProcessData& GetData(); - - typedef std::list Instances; - const Instances& instances() const { return instances_; } - - ResourceContext* resource_context() const { - return resource_context_; - } - - bool process_launched() const { return process_launched_; } - - protected: - friend class WorkerServiceImpl; - - Instances& mutable_instances() { return instances_; } - - private: - // BrowserChildProcessHostDelegate implementation: - virtual void OnProcessLaunched() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - - // Creates and adds the message filters. - void CreateMessageFilters(int render_process_id); - - void OnWorkerContextClosed(int worker_route_id); - void OnWorkerContextDestroyed(int worker_route_id); - void OnWorkerScriptLoaded(int worker_route_id); - void OnWorkerScriptLoadFailed(int worker_route_id); - void OnWorkerConnected(int message_port_id, int worker_route_id); - void OnAllowDatabase(int worker_route_id, - const GURL& url, - const base::string16& name, - const base::string16& display_name, - unsigned long estimated_size, - bool* result); - void OnRequestFileSystemAccess(int worker_route_id, - const GURL& url, - IPC::Message* reply_msg); - void OnRequestFileSystemAccessResponse(scoped_ptr reply_msg, - bool allowed); - void OnAllowIndexedDB(int worker_route_id, - const GURL& url, - const base::string16& name, - bool* result); - void OnForceKillWorkerProcess(); - - // Relays a message to the given endpoint. Takes care of parsing the message - // if it contains a message port and sending it a valid route id. - void RelayMessage(const IPC::Message& message, - WorkerMessageFilter* incoming_filter, - WorkerInstance* instance); - - void ShutdownSocketStreamDispatcherHostIfNecessary(); - - virtual bool CanShutdown() OVERRIDE; - - // Updates the title shown in the task manager. - void UpdateTitle(); - - // Return a vector of all the render process/render frame IDs that use the - // given worker. - std::vector > GetRenderFrameIDsForWorker(int route_id); - - // Callbacks for ResourceMessageFilter and SocketStreamDispatcherHost. - void GetContexts(const ResourceHostMsg_Request& request, - ResourceContext** resource_context, - net::URLRequestContext** request_context); - net::URLRequestContext* GetRequestContext(ResourceType::Type resource_type); - - Instances instances_; - - ResourceContext* const resource_context_; - WorkerStoragePartition partition_; - - // A reference to the filter associated with this worker process. We need to - // keep this around since we'll use it when forward messages to the worker - // process. - scoped_refptr worker_message_filter_; - - scoped_ptr process_; - bool process_launched_; - - scoped_refptr socket_stream_dispatcher_host_; - - base::WeakPtrFactory weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); -}; - -class WorkerProcessHostIterator - : public BrowserChildProcessHostTypeIterator { - public: - WorkerProcessHostIterator() - : BrowserChildProcessHostTypeIterator( - PROCESS_TYPE_WORKER) { - } -}; - -} // namespace content - -#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ diff --git a/content/browser/worker_host/worker_service_impl.cc b/content/browser/worker_host/worker_service_impl.cc deleted file mode 100644 index 4636777e1ce5f9..00000000000000 --- a/content/browser/worker_host/worker_service_impl.cc +++ /dev/null @@ -1,600 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/worker_host/worker_service_impl.h" - -#include - -#include "base/command_line.h" -#include "base/logging.h" -#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" -#include "content/common/worker_messages.h" -#include "content/public/browser/child_process_data.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/render_widget_host.h" -#include "content/public/browser/render_widget_host_iterator.h" -#include "content/public/browser/render_widget_host_view.h" -#include "content/public/browser/resource_context.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/worker_service_observer.h" -#include "content/public/common/content_switches.h" -#include "content/public/common/process_type.h" - -namespace content { - -namespace { -void AddRenderFrameID(std::set >* visible_frame_ids, - RenderFrameHost* rfh) { - visible_frame_ids->insert( - std::pair(rfh->GetProcess()->GetID(), - rfh->GetRoutingID())); -} -} - -const int WorkerServiceImpl::kMaxWorkersWhenSeparate = 64; -const int WorkerServiceImpl::kMaxWorkersPerFrameWhenSeparate = 16; - -class WorkerPrioritySetter - : public NotificationObserver, - public base::RefCountedThreadSafe { - public: - WorkerPrioritySetter(); - - // Posts a task to the UI thread to register to receive notifications. - void Initialize(); - - // Invoked by WorkerServiceImpl when a worker process is created. - void NotifyWorkerProcessCreated(); - - private: - friend class base::RefCountedThreadSafe; - friend struct BrowserThread::DeleteOnThread; - friend class base::DeleteHelper; - virtual ~WorkerPrioritySetter(); - - // Posts a task to perform a worker priority update. - void PostTaskToGatherAndUpdateWorkerPriorities(); - - // Gathers up a list of the visible tabs and then updates priorities for - // all the shared workers. - void GatherVisibleIDsAndUpdateWorkerPriorities(); - - // Registers as an observer to receive notifications about - // widgets being shown. - void RegisterObserver(); - - // Sets priorities for shared workers given a set of visible frames (as a - // std::set of std::pair ids. - void UpdateWorkerPrioritiesFromVisibleSet( - const std::set >* visible); - - // Called to refresh worker priorities when focus changes between tabs. - void OnRenderWidgetVisibilityChanged(std::pair); - - // NotificationObserver implementation. - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) OVERRIDE; - - NotificationRegistrar registrar_; -}; - -WorkerPrioritySetter::WorkerPrioritySetter() { -} - -WorkerPrioritySetter::~WorkerPrioritySetter() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); -} - -void WorkerPrioritySetter::Initialize() { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&WorkerPrioritySetter::RegisterObserver, this)); -} - -void WorkerPrioritySetter::NotifyWorkerProcessCreated() { - PostTaskToGatherAndUpdateWorkerPriorities(); -} - -void WorkerPrioritySetter::PostTaskToGatherAndUpdateWorkerPriorities() { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities, - this)); -} - -void WorkerPrioritySetter::GatherVisibleIDsAndUpdateWorkerPriorities() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::set >* visible_frame_ids = - new std::set >(); - - // Gather up all the visible renderer process/view pairs - scoped_ptr widgets( - RenderWidgetHost::GetRenderWidgetHosts()); - while (RenderWidgetHost* widget = widgets->GetNextHost()) { - if (widget->GetProcess()->VisibleWidgetCount() == 0) - continue; - if (!widget->IsRenderView()) - continue; - - RenderWidgetHostView* widget_view = widget->GetView(); - if (!widget_view || !widget_view->IsShowing()) - continue; - RenderViewHost* rvh = RenderViewHost::From(widget); - WebContents* web_contents = WebContents::FromRenderViewHost(rvh); - if (!web_contents) - continue; - web_contents->ForEachFrame( - base::Bind(&AddRenderFrameID, visible_frame_ids)); - } - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet, - this, base::Owned(visible_frame_ids))); -} - -void WorkerPrioritySetter::UpdateWorkerPrioritiesFromVisibleSet( - const std::set >* visible_frame_ids) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (!iter->process_launched()) - continue; - bool throttle = true; - - for (WorkerProcessHost::Instances::const_iterator instance = - iter->instances().begin(); instance != iter->instances().end(); - ++instance) { - - // This code assumes one worker per process - WorkerProcessHost::Instances::const_iterator first_instance = - iter->instances().begin(); - if (first_instance == iter->instances().end()) - continue; - - WorkerDocumentSet::DocumentInfoSet::const_iterator info = - first_instance->worker_document_set()->documents().begin(); - - for (; info != first_instance->worker_document_set()->documents().end(); - ++info) { - std::pair id( - info->render_process_id(), info->render_frame_id()); - if (visible_frame_ids->find(id) != visible_frame_ids->end()) { - throttle = false; - break; - } - } - - if (!throttle ) { - break; - } - } - - iter->SetBackgrounded(throttle); - } -} - -void WorkerPrioritySetter::OnRenderWidgetVisibilityChanged( - std::pair id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - std::set > visible_frame_ids; - - visible_frame_ids.insert(id); - - UpdateWorkerPrioritiesFromVisibleSet(&visible_frame_ids); -} - -void WorkerPrioritySetter::RegisterObserver() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - registrar_.Add(this, NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, - NotificationService::AllBrowserContextsAndSources()); - registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CREATED, - NotificationService::AllBrowserContextsAndSources()); -} - -void WorkerPrioritySetter::Observe(int type, - const NotificationSource& source, const NotificationDetails& details) { - if (type == NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED) { - bool visible = *Details(details).ptr(); - - if (visible) { - int render_widget_id = - Source(source).ptr()->GetRoutingID(); - int render_process_pid = - Source(source).ptr()->GetProcess()->GetID(); - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&WorkerPrioritySetter::OnRenderWidgetVisibilityChanged, - this, std::pair(render_process_pid, render_widget_id))); - } - } - else if (type == NOTIFICATION_RENDERER_PROCESS_CREATED) { - PostTaskToGatherAndUpdateWorkerPriorities(); - } -} - -WorkerService* WorkerService::GetInstance() { - if (EmbeddedSharedWorkerEnabled()) - return SharedWorkerServiceImpl::GetInstance(); - else - return WorkerServiceImpl::GetInstance(); -} - -bool WorkerService::EmbeddedSharedWorkerEnabled() { - static bool disabled = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableEmbeddedSharedWorker); - return !disabled; -} - -WorkerServiceImpl* WorkerServiceImpl::GetInstance() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - return Singleton::get(); -} - -WorkerServiceImpl::WorkerServiceImpl() - : priority_setter_(new WorkerPrioritySetter()), - next_worker_route_id_(0) { - priority_setter_->Initialize(); -} - -WorkerServiceImpl::~WorkerServiceImpl() { - // The observers in observers_ can't be used here because they might be - // gone already. -} - -void WorkerServiceImpl::PerformTeardownForTesting() { - priority_setter_ = NULL; -} - -void WorkerServiceImpl::OnWorkerMessageFilterClosing( - WorkerMessageFilter* filter) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - iter->FilterShutdown(filter); - } - - // See if that process had any queued workers. - for (WorkerProcessHost::Instances::iterator i = queued_workers_.begin(); - i != queued_workers_.end();) { - i->RemoveFilters(filter); - if (i->NumFilters() == 0) { - i = queued_workers_.erase(i); - } else { - ++i; - } - } - - // Either a worker proceess has shut down, in which case we can start one of - // the queued workers, or a renderer has shut down, in which case it doesn't - // affect anything. We call this function in both scenarios because then we - // don't have to keep track which filters are from worker processes. - TryStartingQueuedWorker(); -} - -void WorkerServiceImpl::CreateWorker( - const ViewHostMsg_CreateWorker_Params& params, - int route_id, - WorkerMessageFilter* filter, - ResourceContext* resource_context, - const WorkerStoragePartition& partition, - bool* url_mismatch) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - *url_mismatch = false; - WorkerProcessHost::WorkerInstance* existing_instance = - FindSharedWorkerInstance( - params.url, params.name, partition, resource_context); - if (existing_instance) { - if (params.url != existing_instance->url()) { - *url_mismatch = true; - return; - } - if (existing_instance->load_failed()) { - filter->Send(new ViewMsg_WorkerScriptLoadFailed(route_id)); - return; - } - existing_instance->AddFilter(filter, route_id); - existing_instance->worker_document_set()->Add( - filter, params.document_id, filter->render_process_id(), - params.render_frame_route_id); - filter->Send(new ViewMsg_WorkerCreated(route_id)); - return; - } - for (WorkerProcessHost::Instances::iterator i = queued_workers_.begin(); - i != queued_workers_.end(); ++i) { - if (i->Matches(params.url, params.name, partition, resource_context) && - params.url != i->url()) { - *url_mismatch = true; - return; - } - } - - // Generate a unique route id for the browser-worker communication that's - // unique among all worker processes. That way when the worker process sends - // a wrapped IPC message through us, we know which WorkerProcessHost to give - // it to. - WorkerProcessHost::WorkerInstance instance( - params.url, - params.name, - params.content_security_policy, - params.security_policy_type, - next_worker_route_id(), - params.render_frame_route_id, - resource_context, - partition); - instance.AddFilter(filter, route_id); - instance.worker_document_set()->Add( - filter, params.document_id, filter->render_process_id(), - params.render_frame_route_id); - - CreateWorkerFromInstance(instance); -} - -void WorkerServiceImpl::ForwardToWorker(const IPC::Message& message, - WorkerMessageFilter* filter) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (iter->FilterMessage(message, filter)) - return; - } - - // TODO(jabdelmalek): tell filter that callee is gone -} - -void WorkerServiceImpl::DocumentDetached(unsigned long long document_id, - WorkerMessageFilter* filter) { - // Any associated shared workers can be shut down. - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) - iter->DocumentDetached(filter, document_id); - - // Remove any queued shared workers for this document. - for (WorkerProcessHost::Instances::iterator iter = queued_workers_.begin(); - iter != queued_workers_.end();) { - - iter->worker_document_set()->Remove(filter, document_id); - if (iter->worker_document_set()->IsEmpty()) { - iter = queued_workers_.erase(iter); - continue; - } - ++iter; - } -} - -bool WorkerServiceImpl::CreateWorkerFromInstance( - WorkerProcessHost::WorkerInstance instance) { - if (!CanCreateWorkerProcess(instance)) { - queued_workers_.push_back(instance); - return true; - } - - // Remove any queued instances of this worker and copy over the filter to - // this instance. - for (WorkerProcessHost::Instances::iterator iter = queued_workers_.begin(); - iter != queued_workers_.end();) { - if (iter->Matches(instance.url(), instance.name(), - instance.partition(), instance.resource_context())) { - DCHECK(iter->NumFilters() == 1); - DCHECK_EQ(instance.url(), iter->url()); - WorkerProcessHost::WorkerInstance::FilterInfo filter_info = - iter->GetFilter(); - instance.AddFilter(filter_info.filter(), filter_info.route_id()); - iter = queued_workers_.erase(iter); - } else { - ++iter; - } - } - - WorkerMessageFilter* first_filter = instance.filters().begin()->filter(); - WorkerProcessHost* worker = new WorkerProcessHost( - instance.resource_context(), instance.partition()); - // TODO(atwilson): This won't work if the message is from a worker process. - // We don't support that yet though (this message is only sent from - // renderers) but when we do, we'll need to add code to pass in the current - // worker's document set for nested workers. - if (!worker->Init(first_filter->render_process_id(), - instance.render_frame_id())) { - delete worker; - return false; - } - - worker->CreateWorker( - instance, - WorkerDevToolsManager::GetInstance()->WorkerCreated(worker, instance)); - FOR_EACH_OBSERVER( - WorkerServiceObserver, observers_, - WorkerCreated(instance.url(), instance.name(), worker->GetData().id, - instance.worker_route_id())); - return true; -} - -bool WorkerServiceImpl::CanCreateWorkerProcess( - const WorkerProcessHost::WorkerInstance& instance) { - // Worker can be fired off if *any* parent has room. - const WorkerDocumentSet::DocumentInfoSet& parents = - instance.worker_document_set()->documents(); - - for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter = - parents.begin(); - parent_iter != parents.end(); ++parent_iter) { - bool hit_total_worker_limit = false; - if (FrameCanCreateWorkerProcess(parent_iter->render_process_id(), - parent_iter->render_frame_id(), - &hit_total_worker_limit)) { - return true; - } - // Return false if already at the global worker limit (no need to continue - // checking parent tabs). - if (hit_total_worker_limit) - return false; - } - // If we've reached here, none of the parent tabs is allowed to create an - // instance. - return false; -} - -bool WorkerServiceImpl::FrameCanCreateWorkerProcess( - int render_process_id, - int render_frame_id, - bool* hit_total_worker_limit) { - int total_workers = 0; - int workers_per_tab = 0; - *hit_total_worker_limit = false; - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - for (WorkerProcessHost::Instances::const_iterator cur_instance = - iter->instances().begin(); - cur_instance != iter->instances().end(); ++cur_instance) { - total_workers++; - if (total_workers >= kMaxWorkersWhenSeparate) { - *hit_total_worker_limit = true; - return false; - } - if (cur_instance->FrameIsParent(render_process_id, render_frame_id)) { - workers_per_tab++; - if (workers_per_tab >= kMaxWorkersPerFrameWhenSeparate) - return false; - } - } - } - - return true; -} - -void WorkerServiceImpl::TryStartingQueuedWorker() { - if (queued_workers_.empty()) - return; - - for (WorkerProcessHost::Instances::iterator i = queued_workers_.begin(); - i != queued_workers_.end();) { - if (CanCreateWorkerProcess(*i)) { - WorkerProcessHost::WorkerInstance instance = *i; - queued_workers_.erase(i); - CreateWorkerFromInstance(instance); - - // CreateWorkerFromInstance can modify the queued_workers_ list when it - // coalesces queued instances after starting a shared worker, so we - // have to rescan the list from the beginning (our iterator is now - // invalid). This is not a big deal as having any queued workers will be - // rare in practice so the list will be small. - i = queued_workers_.begin(); - } else { - ++i; - } - } -} - -bool WorkerServiceImpl::GetRendererForWorker(int worker_process_id, - int* render_process_id, - int* render_frame_id) const { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (iter.GetData().id != worker_process_id) - continue; - - // This code assumes one worker per process, see function comment in header! - WorkerProcessHost::Instances::const_iterator first_instance = - iter->instances().begin(); - if (first_instance == iter->instances().end()) - return false; - - WorkerDocumentSet::DocumentInfoSet::const_iterator info = - first_instance->worker_document_set()->documents().begin(); - *render_process_id = info->render_process_id(); - *render_frame_id = info->render_frame_id(); - return true; - } - return false; -} - -const WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindWorkerInstance( - int worker_process_id) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (iter.GetData().id != worker_process_id) - continue; - - WorkerProcessHost::Instances::const_iterator instance = - iter->instances().begin(); - return instance == iter->instances().end() ? NULL : &*instance; - } - return NULL; -} - -bool WorkerServiceImpl::TerminateWorker(int process_id, int route_id) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - if (iter.GetData().id == process_id) { - iter->TerminateWorker(route_id); - return true; - } - } - return false; -} - -std::vector WorkerServiceImpl::GetWorkers() { - std::vector results; - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - const WorkerProcessHost::Instances& instances = (*iter)->instances(); - for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); - i != instances.end(); ++i) { - WorkerService::WorkerInfo info; - info.url = i->url(); - info.name = i->name(); - info.route_id = i->worker_route_id(); - info.process_id = iter.GetData().id; - info.handle = iter.GetData().handle; - results.push_back(info); - } - } - return results; -} - -void WorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - observers_.AddObserver(observer); -} - -void WorkerServiceImpl::RemoveObserver(WorkerServiceObserver* observer) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - observers_.RemoveObserver(observer); -} - -void WorkerServiceImpl::NotifyWorkerDestroyed( - WorkerProcessHost* process, - int worker_route_id) { - WorkerDevToolsManager::GetInstance()->WorkerDestroyed( - process, worker_route_id); - FOR_EACH_OBSERVER(WorkerServiceObserver, observers_, - WorkerDestroyed(process->GetData().id, worker_route_id)); -} - -void WorkerServiceImpl::NotifyWorkerProcessCreated() { - priority_setter_->NotifyWorkerProcessCreated(); -} - -WorkerProcessHost::WorkerInstance* WorkerServiceImpl::FindSharedWorkerInstance( - const GURL& url, - const base::string16& name, - const WorkerStoragePartition& partition, - ResourceContext* resource_context) { - for (WorkerProcessHostIterator iter; !iter.Done(); ++iter) { - for (WorkerProcessHost::Instances::iterator instance_iter = - iter->mutable_instances().begin(); - instance_iter != iter->mutable_instances().end(); - ++instance_iter) { - if (instance_iter->Matches(url, name, partition, resource_context)) - return &(*instance_iter); - } - } - return NULL; -} - -} // namespace content diff --git a/content/browser/worker_host/worker_service_impl.h b/content/browser/worker_host/worker_service_impl.h deleted file mode 100644 index 133c0a38e1a8a9..00000000000000 --- a/content/browser/worker_host/worker_service_impl.h +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ -#define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/singleton.h" -#include "base/observer_list.h" -#include "base/threading/non_thread_safe.h" -#include "content/browser/worker_host/worker_process_host.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/worker_service.h" - -class GURL; -struct ViewHostMsg_CreateWorker_Params; - -namespace content { -class ResourceContext; -class WorkerServiceObserver; -class WorkerStoragePartition; -class WorkerPrioritySetter; - -class CONTENT_EXPORT WorkerServiceImpl - : public NON_EXPORTED_BASE(WorkerService) { - public: - // Returns the WorkerServiceImpl singleton. - static WorkerServiceImpl* GetInstance(); - - // Releases the priority setter to avoid memory leak error. - void PerformTeardownForTesting(); - - // WorkerService implementation: - virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; - virtual std::vector GetWorkers() OVERRIDE; - virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; - virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; - - // These methods correspond to worker related IPCs. - void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, - int route_id, - WorkerMessageFilter* filter, - ResourceContext* resource_context, - const WorkerStoragePartition& worker_partition, - bool* url_mismatch); - void ForwardToWorker(const IPC::Message& message, - WorkerMessageFilter* filter); - void DocumentDetached(unsigned long long document_id, - WorkerMessageFilter* filter); - - void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter); - - int next_worker_route_id() { return ++next_worker_route_id_; } - - // Given a worker's process id, return the IDs of the renderer process and - // render frame that created it. For shared workers, this returns the first - // parent. - // TODO(dimich): This code assumes there is 1 worker per worker process, which - // is how it is today until V8 can run in separate threads. - bool GetRendererForWorker(int worker_process_id, - int* render_process_id, - int* render_frame_id) const; - const WorkerProcessHost::WorkerInstance* FindWorkerInstance( - int worker_process_id); - - void NotifyWorkerDestroyed( - WorkerProcessHost* process, - int worker_route_id); - - void NotifyWorkerProcessCreated(); - - // Used when we run each worker in a separate process. - static const int kMaxWorkersWhenSeparate; - static const int kMaxWorkersPerFrameWhenSeparate; - - private: - friend struct DefaultSingletonTraits; - - WorkerServiceImpl(); - virtual ~WorkerServiceImpl(); - - // Given a WorkerInstance, create an associated worker process. - bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); - - // Checks if we can create a worker process based on the process limit when - // we're using a strategy of one process per core. - bool CanCreateWorkerProcess( - const WorkerProcessHost::WorkerInstance& instance); - - // Checks if the frame associated with the passed RenderFrame can create a - // worker process based on the process limit when we're using a strategy of - // one worker per process. - bool FrameCanCreateWorkerProcess( - int render_process_id, int render_frame_id, bool* hit_total_worker_limit); - - // Tries to see if any of the queued workers can be created. - void TryStartingQueuedWorker(); - - WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( - const GURL& url, - const base::string16& name, - const WorkerStoragePartition& worker_partition, - ResourceContext* resource_context); - - scoped_refptr priority_setter_; - - int next_worker_route_id_; - - WorkerProcessHost::Instances queued_workers_; - - ObserverList observers_; - - DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ diff --git a/content/common/process_type.cc b/content/common/process_type.cc index c4e293b0c7b035..d3c6894242f7dc 100644 --- a/content/common/process_type.cc +++ b/content/common/process_type.cc @@ -17,8 +17,6 @@ std::string GetProcessTypeNameInEnglish(int type) { return "Tab"; case PROCESS_TYPE_PLUGIN: return "Plug-in"; - case PROCESS_TYPE_WORKER: - return "Web Worker"; case PROCESS_TYPE_UTILITY: return "Utility"; case PROCESS_TYPE_ZYGOTE: diff --git a/content/content.gyp b/content/content.gyp index 6d4fb7e6c9cffd..a961753b5349cf 100644 --- a/content/content.gyp +++ b/content/content.gyp @@ -58,7 +58,6 @@ 'content_ppapi_plugin', 'content_renderer', 'content_utility', - 'content_worker', ], }], ], @@ -253,19 +252,6 @@ 'content_common', ], }, - { - # GN version: //content/worker - 'target_name': 'content_worker', - 'type': 'static_library', - 'variables': { 'enable_wexit_time_destructors': 1, }, - 'includes': [ - 'content_worker.gypi', - ], - 'dependencies': [ - 'content_child', - 'content_common', - ], - }, ], }], ], @@ -296,7 +282,6 @@ 'content_ppapi_plugin.gypi', 'content_renderer.gypi', 'content_utility.gypi', - 'content_worker.gypi', ], 'msvs_settings': { 'VCLinkerTool': { @@ -371,11 +356,6 @@ 'dependencies': ['content'], 'export_dependent_settings': ['content'], }, - { - 'target_name': 'content_worker', - 'type': 'none', - 'dependencies': ['content'], - }, ], }], ['OS == "android"', { diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 5f8148c24022c6..5dfc779cf427f5 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -445,10 +445,6 @@ 'browser/devtools/renderer_overrides_handler.h', 'browser/devtools/tethering_handler.h', 'browser/devtools/tethering_handler.cc', - 'browser/devtools/worker_devtools_manager.cc', - 'browser/devtools/worker_devtools_manager.h', - 'browser/devtools/worker_devtools_message_filter.cc', - 'browser/devtools/worker_devtools_message_filter.h', 'browser/device_monitor_mac.h', 'browser/device_monitor_mac.mm', 'browser/device_monitor_udev.cc', @@ -1177,6 +1173,10 @@ 'browser/shared_worker/shared_worker_message_filter.h', 'browser/shared_worker/shared_worker_service_impl.cc', 'browser/shared_worker/shared_worker_service_impl.h', + 'browser/shared_worker/worker_document_set.cc', + 'browser/shared_worker/worker_document_set.h', + 'browser/shared_worker/worker_storage_partition.cc', + 'browser/shared_worker/worker_storage_partition.h', 'browser/signed_certificate_timestamp_store_impl.cc', 'browser/signed_certificate_timestamp_store_impl.h', 'browser/site_instance_impl.cc', @@ -1327,16 +1327,6 @@ 'browser/webui/web_ui_impl.cc', 'browser/webui/web_ui_impl.h', 'browser/webui/web_ui_message_handler.cc', - 'browser/worker_host/worker_document_set.cc', - 'browser/worker_host/worker_document_set.h', - 'browser/worker_host/worker_message_filter.cc', - 'browser/worker_host/worker_message_filter.h', - 'browser/worker_host/worker_process_host.cc', - 'browser/worker_host/worker_process_host.h', - 'browser/worker_host/worker_service_impl.cc', - 'browser/worker_host/worker_service_impl.h', - 'browser/worker_host/worker_storage_partition.cc', - 'browser/worker_host/worker_storage_partition.h', 'browser/zygote_host/zygote_host_impl_linux.cc', 'browser/zygote_host/zygote_host_impl_linux.h', 'zygote/zygote_linux.cc', diff --git a/content/content_shell.gypi b/content/content_shell.gypi index 9c0c8a5db5effe..a78d8b8fd1bac7 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -35,7 +35,6 @@ 'content.gyp:content_ppapi_plugin', 'content.gyp:content_renderer', 'content.gyp:content_utility', - 'content.gyp:content_worker', 'content_resources.gyp:content_resources', 'content_shell_resources', 'copy_test_netscape_plugin', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 852ae80feff9fe..2651add351fe50 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -271,7 +271,6 @@ 'content.gyp:content_ppapi_plugin', 'content.gyp:content_renderer', 'content.gyp:content_utility', - 'content.gyp:content_worker', '../cc/cc.gyp:cc', '../cc/cc_tests.gyp:cc_test_support', '../media/media.gyp:media', @@ -1158,6 +1157,7 @@ 'browser/security_exploit_browsertest.cc', 'browser/service_worker/service_worker_browsertest.cc', 'browser/session_history_browsertest.cc', + 'browser/shared_worker/worker_browsertest.cc', 'browser/site_per_process_browsertest.cc', 'browser/speech/speech_recognition_browsertest.cc', 'browser/tracing/tracing_controller_browsertest.cc', @@ -1168,7 +1168,6 @@ 'browser/web_contents/web_contents_view_aura_browsertest.cc', 'browser/webkit_browsertest.cc', 'browser/webui/web_ui_mojo_browsertest.cc', - 'browser/worker_host/test/worker_browsertest.cc', 'child/site_isolation_policy_browsertest.cc', 'renderer/accessibility/renderer_accessibility_browsertest.cc', 'renderer/browser_plugin/browser_plugin_browsertest.cc', diff --git a/content/content_worker.gypi b/content/content_worker.gypi deleted file mode 100644 index a04b662ec3436b..00000000000000 --- a/content/content_worker.gypi +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'dependencies': [ - '../base/base.gyp:base', - '../mojo/mojo.gyp:mojo_service_provider_bindings', - '../skia/skia.gyp:skia', - '../third_party/WebKit/public/blink.gyp:blink', - ], - 'sources': [ - 'worker/websharedworker_stub.cc', - 'worker/websharedworker_stub.h', - 'worker/websharedworkerclient_proxy.cc', - 'worker/websharedworkerclient_proxy.h', - 'worker/worker_main.cc', - 'worker/shared_worker_permission_client_proxy.cc', - 'worker/shared_worker_permission_client_proxy.h', - 'worker/worker_thread.cc', - 'worker/worker_thread.h', - 'worker/worker_webapplicationcachehost_impl.cc', - 'worker/worker_webapplicationcachehost_impl.h', - 'worker/worker_webkitplatformsupport_impl.cc', - 'worker/worker_webkitplatformsupport_impl.h', - ], - 'include_dirs': [ - '..', - ], -} diff --git a/content/public/browser/resource_request_details.cc b/content/public/browser/resource_request_details.cc index a5b91b90d05d6c..ad5f47e1734123 100644 --- a/content/public/browser/resource_request_details.cc +++ b/content/public/browser/resource_request_details.cc @@ -4,7 +4,6 @@ #include "content/public/browser/resource_request_details.h" -#include "content/browser/worker_host/worker_service_impl.h" #include "content/public/browser/resource_request_info.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" @@ -29,19 +28,7 @@ ResourceRequestDetails::ResourceRequestDetails(const net::URLRequest* request, http_response_code = request->response_info().headers.get() ? request->response_info().headers.get()->response_code() : -1; - - // If request is from the worker process on behalf of a renderer, use - // the renderer process id, since it consumes the notification response - // such as ssl state etc. - // TODO(atwilson): need to notify all associated renderers in the case - // of ssl state change (http://crbug.com/25357). For now, just notify - // the first one (works for dedicated workers and shared workers with - // a single process). - int worker_render_frame_id; - if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( - info->GetChildID(), &origin_child_id, &worker_render_frame_id)) { - origin_child_id = info->GetChildID(); - } + origin_child_id = info->GetChildID(); } ResourceRequestDetails::~ResourceRequestDetails() {} diff --git a/content/public/browser/worker_service.h b/content/public/browser/worker_service.h index 83a8bd83e0cb85..7ce2bf4ec1fd7e 100644 --- a/content/public/browser/worker_service.h +++ b/content/public/browser/worker_service.h @@ -26,9 +26,6 @@ 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 db429e3c852ccc..3a13a578bffbea 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -130,9 +130,6 @@ const char kDisableDirectNPAPIRequests[] = "disable-direct-npapi-requests"; extern const char kDisableDomainBlockingFor3DAPIs[] = "disable-domain-blocking-for-3d-apis"; -// Disable running the SharedWorker inside the renderer process. -const char kDisableEmbeddedSharedWorker[] = "disable-embedded-shared-worker"; - // Disable experimental WebGL support. const char kDisableExperimentalWebGL[] = "disable-webgl"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index d1cb11e6451369..c3ac61d487cbd4 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -47,7 +47,6 @@ extern const char kDisableDesktopNotifications[]; extern const char kDisableDirectNPAPIRequests[]; CONTENT_EXPORT extern const char kDisableDistanceFieldText[]; extern const char kDisableDomainBlockingFor3DAPIs[]; -CONTENT_EXPORT extern const char kDisableEmbeddedSharedWorker[]; CONTENT_EXPORT extern const char kDisableExperimentalWebGL[]; CONTENT_EXPORT extern const char kDisableFastTextAutosizing[]; CONTENT_EXPORT extern const char kDisableFileSystem[]; diff --git a/content/public/common/process_type.h b/content/public/common/process_type.h index 495bef31c64136..14696697857d02 100644 --- a/content/public/common/process_type.h +++ b/content/public/common/process_type.h @@ -20,7 +20,7 @@ enum ProcessType { PROCESS_TYPE_BROWSER, PROCESS_TYPE_RENDERER, PROCESS_TYPE_PLUGIN, - PROCESS_TYPE_WORKER, + PROCESS_TYPE_WORKER_DEPRECATED, PROCESS_TYPE_UTILITY, PROCESS_TYPE_ZYGOTE, PROCESS_TYPE_SANDBOX_HELPER, diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index 733a3d446b0518..59ae8fb0115ce5 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -208,7 +208,6 @@ static_library("content_shell_lib") { "//content/public/plugin", "//content/public/renderer", "//content/public/utility", - "//content/worker", "//content/test:layouttest_support", "//gin", "//gpu", diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 420d9ea37d6ee9..901cc48cd60cba 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn @@ -46,7 +46,6 @@ static_library("test_support") { "//content/ppapi_plugin", "//content/public/renderer", "//content/public/utility", - "//content/worker", "//cc", "//cc:test_support", "//media", diff --git a/content/worker/BUILD.gn b/content/worker/BUILD.gn deleted file mode 100644 index 3726aa806b10ca..00000000000000 --- a/content/worker/BUILD.gn +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -source_set("worker") { - visibility = "//content/*" - sources = [ - "websharedworker_stub.cc", - "websharedworker_stub.h", - "websharedworkerclient_proxy.cc", - "websharedworkerclient_proxy.h", - "worker_main.cc", - "shared_worker_permission_client_proxy.cc", - "shared_worker_permission_client_proxy.h", - "worker_thread.cc", - "worker_thread.h", - "worker_webapplicationcachehost_impl.cc", - "worker_webapplicationcachehost_impl.h", - "worker_webkitplatformsupport_impl.cc", - "worker_webkitplatformsupport_impl.h", - ] - - configs += [ "//content:content_implementation" ] - - deps = [ - "//base", - "//mojo/public/interfaces/service_provider", - "//skia", - "//third_party/WebKit/public:blink", - ] -} - diff --git a/content/worker/DEPS b/content/worker/DEPS deleted file mode 100644 index 6e9ea80333ccd8..00000000000000 --- a/content/worker/DEPS +++ /dev/null @@ -1,6 +0,0 @@ -include_rules = [ - "+content/child", - "+sandbox/win/src", - "+v8/include/v8.h", -] - diff --git a/content/worker/OWNERS b/content/worker/OWNERS deleted file mode 100644 index 61fc3fd49ea0fd..00000000000000 --- a/content/worker/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -atwilson@chromium.org -kinuko@chromium.org -horo@chromium.org diff --git a/content/worker/shared_worker_permission_client_proxy.cc b/content/worker/shared_worker_permission_client_proxy.cc deleted file mode 100644 index a7e0671bdacde1..00000000000000 --- a/content/worker/shared_worker_permission_client_proxy.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/shared_worker_permission_client_proxy.h" - -#include "content/child/thread_safe_sender.h" -#include "content/common/worker_messages.h" -#include "third_party/WebKit/public/platform/WebString.h" -#include "url/gurl.h" - -namespace content { - -SharedWorkerPermissionClientProxy::SharedWorkerPermissionClientProxy( - const GURL& origin_url, - bool is_unique_origin, - int routing_id, - ThreadSafeSender* thread_safe_sender) - : origin_url_(origin_url), - is_unique_origin_(is_unique_origin), - routing_id_(routing_id), - thread_safe_sender_(thread_safe_sender) { -} - -SharedWorkerPermissionClientProxy::~SharedWorkerPermissionClientProxy() { -} - -bool SharedWorkerPermissionClientProxy::allowDatabase( - const blink::WebString& name, - const blink::WebString& display_name, - unsigned long estimated_size) { - if (is_unique_origin_) - return false; - bool result = false; - thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowDatabase( - routing_id_, origin_url_, name, display_name, - estimated_size, &result)); - return result; -} - -bool SharedWorkerPermissionClientProxy::requestFileSystemAccessSync() { - if (is_unique_origin_) - return false; - bool result = false; - thread_safe_sender_->Send( - new WorkerProcessHostMsg_RequestFileSystemAccessSync( - routing_id_, origin_url_, &result)); - return result; -} - -bool SharedWorkerPermissionClientProxy::allowIndexedDB( - const blink::WebString& name) { - if (is_unique_origin_) - return false; - bool result = false; - thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowIndexedDB( - routing_id_, origin_url_, name, &result)); - return result; -} - -} // namespace content diff --git a/content/worker/shared_worker_permission_client_proxy.h b/content/worker/shared_worker_permission_client_proxy.h deleted file mode 100644 index 0240738347f1ac..00000000000000 --- a/content/worker/shared_worker_permission_client_proxy.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_ -#define CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_ - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "third_party/WebKit/public/web/WebWorkerPermissionClientProxy.h" -#include "url/gurl.h" - -namespace content { - -class ThreadSafeSender; - -// This proxy is created on the main renderer thread then passed onto -// the blink's worker thread. -class SharedWorkerPermissionClientProxy - : public blink::WebWorkerPermissionClientProxy { - public: - SharedWorkerPermissionClientProxy( - const GURL& origin_url, - bool is_unique_origin, - int routing_id, - ThreadSafeSender* thread_safe_sender); - virtual ~SharedWorkerPermissionClientProxy(); - - // WebWorkerPermissionClientProxy overrides. - virtual bool allowDatabase(const blink::WebString& name, - const blink::WebString& display_name, - unsigned long estimated_size); - virtual bool requestFileSystemAccessSync(); - virtual bool allowIndexedDB(const blink::WebString& name); - - private: - const GURL origin_url_; - const bool is_unique_origin_; - const int routing_id_; - scoped_refptr thread_safe_sender_; - - DISALLOW_COPY_AND_ASSIGN(SharedWorkerPermissionClientProxy); -}; - -} // namespace content - -#endif // CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_ diff --git a/content/worker/websharedworker_stub.cc b/content/worker/websharedworker_stub.cc deleted file mode 100644 index b33e707971a13d..00000000000000 --- a/content/worker/websharedworker_stub.cc +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/websharedworker_stub.h" - -#include "base/command_line.h" -#include "base/compiler_specific.h" -#include "content/child/child_process.h" -#include "content/child/child_thread.h" -#include "content/child/fileapi/file_system_dispatcher.h" -#include "content/child/shared_worker_devtools_agent.h" -#include "content/child/webmessageportchannel_impl.h" -#include "content/common/worker_messages.h" -#include "content/public/common/content_switches.h" -#include "content/worker/worker_thread.h" -#include "third_party/WebKit/public/platform/WebString.h" -#include "third_party/WebKit/public/platform/WebURL.h" -#include "third_party/WebKit/public/web/WebSharedWorker.h" - -namespace content { - -WebSharedWorkerStub::WebSharedWorkerStub( - const GURL& url, - const base::string16& name, - const base::string16& content_security_policy, - blink::WebContentSecurityPolicyType security_policy_type, - bool pause_on_start, - int route_id) - : route_id_(route_id), - client_(route_id, this), - running_(false), - url_(url) { - - WorkerThread* worker_thread = WorkerThread::current(); - DCHECK(worker_thread); - worker_thread->AddWorkerStub(this); - // Start processing incoming IPCs for this worker. - worker_thread->GetRouter()->AddRoute(route_id_, this); - - // TODO(atwilson): Add support for NaCl when they support MessagePorts. - impl_ = blink::WebSharedWorker::create(client()); - if (pause_on_start) { - // Pause worker context when it starts and wait until either DevTools client - // is attached or explicit resume notification is received. - impl_->pauseWorkerContextOnStart(); - } - - worker_devtools_agent_.reset(new SharedWorkerDevToolsAgent(route_id, impl_)); - client()->set_devtools_agent(worker_devtools_agent_.get()); - impl_->startWorkerContext(url_, name, - content_security_policy, security_policy_type); -} - -WebSharedWorkerStub::~WebSharedWorkerStub() { - impl_->clientDestroyed(); - WorkerThread* worker_thread = WorkerThread::current(); - DCHECK(worker_thread); - worker_thread->RemoveWorkerStub(this); - worker_thread->GetRouter()->RemoveRoute(route_id_); -} - -void WebSharedWorkerStub::Shutdown() { - // The worker has exited - free ourselves and the client. - delete this; -} - -void WebSharedWorkerStub::EnsureWorkerContextTerminates() { - client_.EnsureWorkerContextTerminates(); -} - -bool WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) { - if (worker_devtools_agent_->OnMessageReceived(message)) - return true; - - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerStub, message) - IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, - OnTerminateWorkerContext) - IPC_MESSAGE_HANDLER(WorkerMsg_Connect, OnConnect) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void WebSharedWorkerStub::OnChannelError() { - OnTerminateWorkerContext(); -} - -const GURL& WebSharedWorkerStub::url() { - return url_; -} - -void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) { - WebMessagePortChannelImpl* channel = - new WebMessagePortChannelImpl(routing_id, - sent_message_port_id, - base::MessageLoopProxy::current().get()); - if (running_) { - impl_->connect(channel); - WorkerThread::current()->Send( - new WorkerHostMsg_WorkerConnected(channel->message_port_id(), - route_id_)); - } else { - // If two documents try to load a SharedWorker at the same time, the - // WorkerMsg_Connect for one of the documents can come in before the - // worker is started. Just queue up the connect and deliver it once the - // worker starts. - pending_channels_.push_back(channel); - } -} - -void WebSharedWorkerStub::OnTerminateWorkerContext() { - running_ = false; - // Call the client to make sure context exits. - EnsureWorkerContextTerminates(); - // This may call "delete this" via WorkerScriptLoadFailed and Shutdown. - impl_->terminateWorkerContext(); -} - -void WebSharedWorkerStub::WorkerScriptLoaded() { - running_ = true; - // Process any pending connections. - for (PendingChannelList::const_iterator iter = pending_channels_.begin(); - iter != pending_channels_.end(); - ++iter) { - impl_->connect(*iter); - WorkerThread::current()->Send( - new WorkerHostMsg_WorkerConnected((*iter)->message_port_id(), - route_id_)); - } - pending_channels_.clear(); -} - -void WebSharedWorkerStub::WorkerScriptLoadFailed() { - for (PendingChannelList::const_iterator iter = pending_channels_.begin(); - iter != pending_channels_.end(); - ++iter) { - blink::WebMessagePortChannel* channel = *iter; - channel->destroy(); - } - pending_channels_.clear(); - Shutdown(); -} - -} // namespace content diff --git a/content/worker/websharedworker_stub.h b/content/worker/websharedworker_stub.h deleted file mode 100644 index c1a6287bfb7c3f..00000000000000 --- a/content/worker/websharedworker_stub.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ -#define CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ - -#include "base/memory/scoped_ptr.h" -#include "content/child/scoped_child_process_reference.h" -#include "content/worker/websharedworkerclient_proxy.h" -#include "content/worker/worker_webapplicationcachehost_impl.h" -#include "ipc/ipc_listener.h" -#include "third_party/WebKit/public/web/WebSharedWorker.h" -#include "url/gurl.h" - -namespace blink { -class WebSharedWorker; -} - -namespace content { - -class SharedWorkerDevToolsAgent; -class WebMessagePortChannelImpl; - -// This class creates a WebSharedWorker, and translates incoming IPCs to the -// appropriate WebSharedWorker APIs. -class WebSharedWorkerStub : public IPC::Listener { - public: - WebSharedWorkerStub(const GURL& url, - const base::string16& name, - const base::string16& content_security_policy, - blink::WebContentSecurityPolicyType security_policy_type, - bool pause_on_start, - int route_id); - - // IPC::Listener implementation. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void OnChannelError() OVERRIDE; - - // Invoked when the WebSharedWorkerClientProxy is shutting down. - void Shutdown(); - - void WorkerScriptLoaded(); - void WorkerScriptLoadFailed(); - - // Called after terminating the worker context to make sure that the worker - // actually terminates (is not stuck in an infinite loop). - void EnsureWorkerContextTerminates(); - - WebSharedWorkerClientProxy* client() { return &client_; } - - // Returns the script url of this worker. - const GURL& url(); - - - private: - virtual ~WebSharedWorkerStub(); - - void OnConnect(int sent_message_port_id, int routing_id); - - void OnTerminateWorkerContext(); - - ScopedChildProcessReference process_ref_; - - int route_id_; - - // WebSharedWorkerClient that responds to outgoing API calls - // from the worker object. - WebSharedWorkerClientProxy client_; - - blink::WebSharedWorker* impl_; - bool running_; - GURL url_; - scoped_ptr worker_devtools_agent_; - - typedef std::vector PendingChannelList; - PendingChannelList pending_channels_; - - DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub); -}; - -} // namespace content - -#endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_ diff --git a/content/worker/websharedworkerclient_proxy.cc b/content/worker/websharedworkerclient_proxy.cc deleted file mode 100644 index 486479a30d3084..00000000000000 --- a/content/worker/websharedworkerclient_proxy.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/websharedworkerclient_proxy.h" - -#include "base/bind.h" -#include "base/command_line.h" -#include "base/message_loop/message_loop.h" -#include "content/child/shared_worker_devtools_agent.h" -#include "content/child/webmessageportchannel_impl.h" -#include "content/common/worker_messages.h" -#include "content/public/common/content_switches.h" -#include "content/worker/shared_worker_permission_client_proxy.h" -#include "content/worker/websharedworker_stub.h" -#include "content/worker/worker_thread.h" -#include "content/worker/worker_webapplicationcachehost_impl.h" -#include "ipc/ipc_logging.h" -#include "third_party/WebKit/public/platform/WebString.h" -#include "third_party/WebKit/public/platform/WebURL.h" -#include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebFrame.h" -#include "third_party/WebKit/public/web/WebSecurityOrigin.h" - -using blink::WebApplicationCacheHost; -using blink::WebFrame; -using blink::WebMessagePortChannel; -using blink::WebMessagePortChannelArray; -using blink::WebSecurityOrigin; -using blink::WebString; -using blink::WebWorker; -using blink::WebSharedWorkerClient; - -namespace content { - -// How long to wait for worker to finish after it's been told to terminate. -#define kMaxTimeForRunawayWorkerSeconds 3 - -WebSharedWorkerClientProxy::WebSharedWorkerClientProxy( - int route_id, WebSharedWorkerStub* stub) - : route_id_(route_id), - appcache_host_id_(0), - stub_(stub), - weak_factory_(this), - devtools_agent_(NULL), - app_cache_host_(NULL) { -} - -WebSharedWorkerClientProxy::~WebSharedWorkerClientProxy() { -} - -void WebSharedWorkerClientProxy::workerContextClosed() { - Send(new WorkerHostMsg_WorkerContextClosed(route_id_)); -} - -void WebSharedWorkerClientProxy::workerContextDestroyed() { - Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_)); - // Tell the stub that the worker has shutdown - frees this object. - if (stub_) - stub_->Shutdown(); -} - -void WebSharedWorkerClientProxy::workerScriptLoaded() { - Send(new WorkerHostMsg_WorkerScriptLoaded(route_id_)); - if (stub_) - stub_->WorkerScriptLoaded(); -} - -void WebSharedWorkerClientProxy::workerScriptLoadFailed() { - Send(new WorkerHostMsg_WorkerScriptLoadFailed(route_id_)); - if (stub_) - stub_->WorkerScriptLoadFailed(); -} - -void WebSharedWorkerClientProxy::selectAppCacheID(long long app_cache_id) { - if (app_cache_host_) { - // app_cache_host_ could become stale as it's owned by blink's - // DocumentLoader. This method is assumed to be called while it's valid. - app_cache_host_->backend()->SelectCacheForSharedWorker( - app_cache_host_->host_id(), - app_cache_id); - } -} - -blink::WebNotificationPresenter* -WebSharedWorkerClientProxy::notificationPresenter() { - // TODO(johnnyg): Notifications are not yet hooked up to workers. - // Coming soon. - NOTREACHED(); - return NULL; -} - -WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost( - blink::WebApplicationCacheHostClient* client) { - DCHECK(!app_cache_host_); - app_cache_host_ = new WorkerWebApplicationCacheHostImpl(client); - // Remember the id of the instance we create so we have access to that - // value when creating nested dedicated workers in createWorker. - appcache_host_id_ = app_cache_host_->host_id(); - return app_cache_host_; -} - -blink::WebWorkerPermissionClientProxy* -WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( - const blink::WebSecurityOrigin& origin) { - return new SharedWorkerPermissionClientProxy( - GURL(origin.toString()), origin.isUnique(), route_id_, - ChildThread::current()->thread_safe_sender()); -} - -void WebSharedWorkerClientProxy::dispatchDevToolsMessage( - const WebString& message) { - if (devtools_agent_) - devtools_agent_->SendDevToolsMessage(message); -} - -void WebSharedWorkerClientProxy::saveDevToolsAgentState( - const blink::WebString& state) { - if (devtools_agent_) - devtools_agent_->SaveDevToolsAgentState(state); -} - -bool WebSharedWorkerClientProxy::Send(IPC::Message* message) { - return WorkerThread::current()->Send(message); -} - -void WebSharedWorkerClientProxy::EnsureWorkerContextTerminates() { - // This shuts down the process cleanly from the perspective of the browser - // process, and avoids the crashed worker infobar from appearing to the new - // page. It's ok to post several of theese, because the first executed task - // will exit the message loop and subsequent ones won't be executed. - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, - weak_factory_.GetWeakPtr()), - base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); -} - -} // namespace content diff --git a/content/worker/websharedworkerclient_proxy.h b/content/worker/websharedworkerclient_proxy.h deleted file mode 100644 index beb3086d756a5a..00000000000000 --- a/content/worker/websharedworkerclient_proxy.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_ -#define CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_ - -#include "base/basictypes.h" -#include "base/memory/weak_ptr.h" -#include "ipc/ipc_channel.h" -#include "third_party/WebKit/public/web/WebSharedWorkerClient.h" - -namespace blink { -class WebApplicationCacheHost; -class WebApplicationCacheHostClient; -class WebFrame; -class WebSecurityOrigin; -} - -namespace content { - -class SharedWorkerDevToolsAgent; -class WebSharedWorkerStub; -class WorkerWebApplicationCacheHostImpl; - -// This class receives IPCs from the renderer and calls the WebCore::Worker -// implementation (after the data types have been converted by glue code). It -// is also called by the worker code and converts these function calls into -// IPCs that are sent to the renderer, where they're converted back to function -// calls by WebWorkerProxy. -class WebSharedWorkerClientProxy : public blink::WebSharedWorkerClient { - public: - WebSharedWorkerClientProxy(int route_id, WebSharedWorkerStub* stub); - virtual ~WebSharedWorkerClientProxy(); - - // WebSharedWorkerClient implementation. - virtual void workerContextClosed(); - virtual void workerContextDestroyed(); - virtual void workerScriptLoaded(); - virtual void workerScriptLoadFailed(); - virtual void selectAppCacheID(long long app_cache_id); - - virtual blink::WebNotificationPresenter* notificationPresenter(); - - virtual blink::WebApplicationCacheHost* createApplicationCacheHost( - blink::WebApplicationCacheHostClient* client); - virtual blink::WebWorkerPermissionClientProxy* - createWorkerPermissionClientProxy( - const blink::WebSecurityOrigin& origin); - - virtual void dispatchDevToolsMessage(const blink::WebString&); - virtual void saveDevToolsAgentState(const blink::WebString&); - - void EnsureWorkerContextTerminates(); - - void set_devtools_agent(SharedWorkerDevToolsAgent* devtools_agent) { - devtools_agent_ = devtools_agent; - } - - private: - bool Send(IPC::Message* message); - - int route_id_; - int appcache_host_id_; - WebSharedWorkerStub* stub_; - base::WeakPtrFactory weak_factory_; - SharedWorkerDevToolsAgent* devtools_agent_; - WorkerWebApplicationCacheHostImpl* app_cache_host_; - - DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerClientProxy); -}; - -} // namespace content - -#endif // CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_ diff --git a/content/worker/worker_main.cc b/content/worker/worker_main.cc deleted file mode 100644 index 8cc8ed0f220791..00000000000000 --- a/content/worker/worker_main.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/base_switches.h" -#include "base/command_line.h" -#include "base/message_loop/message_loop.h" -#include "base/strings/string_util.h" -#include "base/threading/platform_thread.h" -#include "base/timer/hi_res_timer_manager.h" -#include "content/child/child_process.h" -#include "content/common/sandbox_linux/sandbox_linux.h" -#include "content/public/common/main_function_params.h" -#include "content/public/common/sandbox_init.h" -#include "content/worker/worker_thread.h" - -#if defined(OS_WIN) -#include "sandbox/win/src/sandbox.h" -#endif - -#if defined(OS_MACOSX) -#include "content/common/sandbox_mac.h" -#endif - -namespace content { - -// Mainline routine for running as the worker process. -int WorkerMain(const MainFunctionParams& parameters) { - // The main message loop of the worker process. - base::MessageLoop main_message_loop; - base::PlatformThread::SetName("CrWorkerMain"); - base::debug::TraceLog::GetInstance()->SetProcessName("Shared Web Worker"); - -#if defined(OS_WIN) - sandbox::TargetServices* target_services = - parameters.sandbox_info->target_services; - if (!target_services) - return false; - - // Cause advapi32 to load before the sandbox is turned on. - unsigned int dummy_rand; - rand_s(&dummy_rand); - // Warm up language subsystems before the sandbox is turned on. - ::GetUserDefaultLangID(); - ::GetUserDefaultLCID(); - - target_services->LowerToken(); -#elif defined(OS_MACOSX) - // Sandbox should already be activated at this point. - CHECK(Sandbox::SandboxIsCurrentlyActive()); -#elif defined(OS_LINUX) - // On Linux, the sandbox must be initialized early, before any thread is - // created. - LinuxSandbox::InitializeSandbox(); -#endif - - ChildProcess worker_process; - worker_process.set_main_thread(new WorkerThread()); - - base::HighResolutionTimerManager hi_res_timer_manager; - - const CommandLine& parsed_command_line = parameters.command_line; - if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { - ChildProcess::WaitForDebugger("Worker"); - } - - // Load the accelerator table from the browser executable and tell the - // message loop to use it when translating messages. - base::MessageLoop::current()->Run(); - - return 0; -} - -} // namespace content diff --git a/content/worker/worker_thread.cc b/content/worker/worker_thread.cc deleted file mode 100644 index 687637ba9ccf9d..00000000000000 --- a/content/worker/worker_thread.cc +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/worker_thread.h" - -#include "base/command_line.h" -#include "base/lazy_instance.h" -#include "base/threading/thread_local.h" -#include "content/child/appcache/appcache_dispatcher.h" -#include "content/child/appcache/appcache_frontend_impl.h" -#include "content/child/db_message_filter.h" -#include "content/child/indexed_db/indexed_db_message_filter.h" -#include "content/child/runtime_features.h" -#include "content/child/web_database_observer_impl.h" -#include "content/common/child_process_messages.h" -#include "content/common/worker_messages.h" -#include "content/public/common/content_switches.h" -#include "content/worker/websharedworker_stub.h" -#include "content/worker/worker_webkitplatformsupport_impl.h" -#include "ipc/ipc_sync_channel.h" -#include "third_party/WebKit/public/platform/WebBlobRegistry.h" -#include "third_party/WebKit/public/web/WebDatabase.h" -#include "third_party/WebKit/public/web/WebKit.h" -#include "third_party/WebKit/public/web/WebRuntimeFeatures.h" -#include "v8/include/v8.h" - -using blink::WebRuntimeFeatures; - -namespace content { - -static base::LazyInstance > lazy_tls = - LAZY_INSTANCE_INITIALIZER; - -WorkerThread::WorkerThread() { - lazy_tls.Pointer()->Set(this); - webkit_platform_support_.reset(new WorkerWebKitPlatformSupportImpl( - thread_safe_sender(), - sync_message_filter(), - quota_message_filter())); - - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kJavaScriptFlags)) { - std::string flags( - command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); - v8::V8::SetFlagsFromString(flags.c_str(), static_cast(flags.size())); - } - SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); - - blink::initialize(webkit_platform_support_.get()); - - appcache_dispatcher_.reset( - new AppCacheDispatcher(this, new AppCacheFrontendImpl())); - - db_message_filter_ = new DBMessageFilter(); - channel()->AddFilter(db_message_filter_.get()); - - indexed_db_message_filter_ = new IndexedDBMessageFilter( - thread_safe_sender()); - channel()->AddFilter(indexed_db_message_filter_->GetFilter()); - -} - -void WorkerThread::OnShutdown() { - // The worker process is to be shut down gracefully. Ask the browser - // process to shut it down forcefully instead and wait on the message, so that - // there are no races between threads when the process is shutting down. - Send(new WorkerProcessHostMsg_ForceKillWorker()); -} - -WorkerThread::~WorkerThread() { -} - -void WorkerThread::Shutdown() { - ChildThread::Shutdown(); - - if (webkit_platform_support_) { - webkit_platform_support_->web_database_observer_impl()-> - WaitForAllDatabasesToClose(); - } - - // Shutdown in reverse of the initialization order. - indexed_db_message_filter_ = NULL; - - channel()->RemoveFilter(db_message_filter_.get()); - db_message_filter_ = NULL; - - blink::shutdown(); - lazy_tls.Pointer()->Set(NULL); -} - -WorkerThread* WorkerThread::current() { - return lazy_tls.Pointer()->Get(); -} - -bool WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { - // Appcache messages are handled by a delegate. - if (appcache_dispatcher_->OnMessageReceived(msg)) - return true; - - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) - IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -bool WorkerThread::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) - IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) - IPC_MESSAGE_UNHANDLED(handled = ChildThread::OnMessageReceived(msg)) - IPC_END_MESSAGE_MAP() - return handled; -} - -void WorkerThread::OnCreateWorker( - const WorkerProcessMsg_CreateWorker_Params& params) { - // WebSharedWorkerStub own themselves. - new WebSharedWorkerStub( - params.url, - params.name, - params.content_security_policy, - params.security_policy_type, - params.pause_on_start, - params.route_id); -} - -// The browser process is likely dead. Terminate all workers. -void WorkerThread::OnChannelError() { - set_on_channel_error_called(true); - - for (WorkerStubsList::iterator it = worker_stubs_.begin(); - it != worker_stubs_.end(); ++it) { - (*it)->OnChannelError(); - } -} - -void WorkerThread::RemoveWorkerStub(WebSharedWorkerStub* stub) { - worker_stubs_.erase(stub); -} - -void WorkerThread::AddWorkerStub(WebSharedWorkerStub* stub) { - worker_stubs_.insert(stub); -} - -} // namespace content diff --git a/content/worker/worker_thread.h b/content/worker/worker_thread.h deleted file mode 100644 index 927cd9a2a61262..00000000000000 --- a/content/worker/worker_thread.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_WORKER_WORKER_THREAD_H_ -#define CONTENT_WORKER_WORKER_THREAD_H_ - -#include - -#include "content/child/child_thread.h" - -struct WorkerProcessMsg_CreateWorker_Params; - -namespace content { -class AppCacheDispatcher; -class DBMessageFilter; -class IndexedDBMessageFilter; -class WebSharedWorkerStub; -class WorkerWebKitPlatformSupportImpl; - -class WorkerThread : public ChildThread { - public: - WorkerThread(); - virtual ~WorkerThread(); - virtual void Shutdown() OVERRIDE; - - // Returns the one worker thread. - static WorkerThread* current(); - - // Invoked from stub constructors/destructors. Stubs own themselves. - void AddWorkerStub(WebSharedWorkerStub* stub); - void RemoveWorkerStub(WebSharedWorkerStub* stub); - - AppCacheDispatcher* appcache_dispatcher() { - return appcache_dispatcher_.get(); - } - - private: - virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; - virtual void OnChannelError() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; - - void OnCreateWorker(const WorkerProcessMsg_CreateWorker_Params& params); - void OnShutdown(); - - scoped_ptr webkit_platform_support_; - scoped_ptr appcache_dispatcher_; - scoped_refptr db_message_filter_; - scoped_refptr indexed_db_message_filter_; - - typedef std::set WorkerStubsList; - WorkerStubsList worker_stubs_; - - DISALLOW_COPY_AND_ASSIGN(WorkerThread); -}; - -} // namespace content - -#endif // CONTENT_WORKER_WORKER_THREAD_H_ diff --git a/content/worker/worker_webapplicationcachehost_impl.cc b/content/worker/worker_webapplicationcachehost_impl.cc deleted file mode 100644 index d591bb443eb938..00000000000000 --- a/content/worker/worker_webapplicationcachehost_impl.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/worker_webapplicationcachehost_impl.h" - -#include "content/child/appcache/appcache_dispatcher.h" -#include "content/worker/worker_thread.h" - -namespace content { - -WorkerWebApplicationCacheHostImpl::WorkerWebApplicationCacheHostImpl( - blink::WebApplicationCacheHostClient* client) - : WebApplicationCacheHostImpl(client, - WorkerThread::current()->appcache_dispatcher()->backend_proxy()) { -} - -void WorkerWebApplicationCacheHostImpl::willStartMainResourceRequest( - blink::WebURLRequest&, const blink::WebApplicationCacheHost*) { -} - -void WorkerWebApplicationCacheHostImpl::didReceiveResponseForMainResource( - const blink::WebURLResponse&) { -} - -void WorkerWebApplicationCacheHostImpl::didReceiveDataForMainResource( - const char*, int) { -} - -void WorkerWebApplicationCacheHostImpl::didFinishLoadingMainResource( - bool) { -} - -void WorkerWebApplicationCacheHostImpl::selectCacheWithoutManifest() { -} - -bool WorkerWebApplicationCacheHostImpl::selectCacheWithManifest( - const blink::WebURL&) { - return true; -} - -} // namespace content diff --git a/content/worker/worker_webapplicationcachehost_impl.h b/content/worker/worker_webapplicationcachehost_impl.h deleted file mode 100644 index e431e76eb2a883..00000000000000 --- a/content/worker/worker_webapplicationcachehost_impl.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ -#define CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ - -#include "content/child/appcache/web_application_cache_host_impl.h" - -namespace content { - -class WorkerWebApplicationCacheHostImpl : public WebApplicationCacheHostImpl { - public: - WorkerWebApplicationCacheHostImpl( - blink::WebApplicationCacheHostClient* client); - - // Main resource loading is different for workers. The main resource is - // loaded by the worker using WorkerScriptLoader. - // These overrides are stubbed out. - virtual void willStartMainResourceRequest( - blink::WebURLRequest&, const blink::WebApplicationCacheHost*); - virtual void didReceiveResponseForMainResource( - const blink::WebURLResponse&); - virtual void didReceiveDataForMainResource(const char* data, int len); - virtual void didFinishLoadingMainResource(bool success); - - // Cache selection is also different for workers. We know at construction - // time what cache to select and do so then. - // These overrides are stubbed out. - virtual void selectCacheWithoutManifest(); - virtual bool selectCacheWithManifest(const blink::WebURL& manifestURL); -}; - -} // namespace content - -#endif // CHROME_WORKER_WORKER_WEBAPPLICATIONCACHEHOST_IMPL_H_ diff --git a/content/worker/worker_webkitplatformsupport_impl.cc b/content/worker/worker_webkitplatformsupport_impl.cc deleted file mode 100644 index ec30e0fff87d99..00000000000000 --- a/content/worker/worker_webkitplatformsupport_impl.cc +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/worker/worker_webkitplatformsupport_impl.h" - -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" -#include "base/strings/utf_string_conversions.h" -#include "content/child/blink_glue.h" -#include "content/child/database_util.h" -#include "content/child/fileapi/webfilesystem_impl.h" -#include "content/child/indexed_db/webidbfactory_impl.h" -#include "content/child/quota_dispatcher.h" -#include "content/child/quota_message_filter.h" -#include "content/child/thread_safe_sender.h" -#include "content/child/web_database_observer_impl.h" -#include "content/child/webblobregistry_impl.h" -#include "content/child/webfileutilities_impl.h" -#include "content/child/webmessageportchannel_impl.h" -#include "content/common/file_utilities_messages.h" -#include "content/common/mime_registry_messages.h" -#include "content/worker/worker_thread.h" -#include "ipc/ipc_sync_message_filter.h" -#include "net/base/mime_util.h" -#include "third_party/WebKit/public/platform/WebBlobRegistry.h" -#include "third_party/WebKit/public/platform/WebFileInfo.h" -#include "third_party/WebKit/public/platform/WebString.h" -#include "third_party/WebKit/public/platform/WebURL.h" -#include "webkit/common/quota/quota_types.h" - -using blink::Platform; -using blink::WebBlobRegistry; -using blink::WebClipboard; -using blink::WebFileInfo; -using blink::WebFileSystem; -using blink::WebFileUtilities; -using blink::WebMessagePortChannel; -using blink::WebMimeRegistry; -using blink::WebSandboxSupport; -using blink::WebStorageNamespace; -using blink::WebString; -using blink::WebURL; - -namespace content { - -// TODO(kinuko): Probably this could be consolidated into -// RendererWebKitPlatformSupportImpl::FileUtilities. -class WorkerWebKitPlatformSupportImpl::FileUtilities - : public WebFileUtilitiesImpl { - public: - explicit FileUtilities(ThreadSafeSender* sender) - : thread_safe_sender_(sender) {} - virtual bool getFileInfo(const WebString& path, WebFileInfo& result); - private: - scoped_refptr thread_safe_sender_; -}; - -bool WorkerWebKitPlatformSupportImpl::FileUtilities::getFileInfo( - const WebString& path, - WebFileInfo& web_file_info) { - base::File::Info file_info; - base::File::Error status = base::File::FILE_ERROR_MAX; - if (!thread_safe_sender_.get() || - !thread_safe_sender_->Send(new FileUtilitiesMsg_GetFileInfo( - base::FilePath::FromUTF16Unsafe(path), &file_info, &status)) || - status != base::File::FILE_OK) { - return false; - } - FileInfoToWebFileInfo(file_info, &web_file_info); - web_file_info.platformPath = path; - return true; -} - -//------------------------------------------------------------------------------ - -WorkerWebKitPlatformSupportImpl::WorkerWebKitPlatformSupportImpl( - ThreadSafeSender* sender, - IPC::SyncMessageFilter* sync_message_filter, - QuotaMessageFilter* quota_message_filter) - : thread_safe_sender_(sender), - child_thread_loop_(base::MessageLoopProxy::current()), - sync_message_filter_(sync_message_filter), - quota_message_filter_(quota_message_filter) { - if (sender) { - blob_registry_.reset(new WebBlobRegistryImpl(sender)); - web_idb_factory_.reset(new WebIDBFactoryImpl(sender)); - web_database_observer_impl_.reset( - new WebDatabaseObserverImpl(sync_message_filter)); - } -} - -WorkerWebKitPlatformSupportImpl::~WorkerWebKitPlatformSupportImpl() { - WebFileSystemImpl::DeleteThreadSpecificInstance(); -} - -WebClipboard* WorkerWebKitPlatformSupportImpl::clipboard() { - NOTREACHED(); - return NULL; -} - -WebMimeRegistry* WorkerWebKitPlatformSupportImpl::mimeRegistry() { - return this; -} - -WebFileSystem* WorkerWebKitPlatformSupportImpl::fileSystem() { - return WebFileSystemImpl::ThreadSpecificInstance(child_thread_loop_.get()); -} - -WebFileUtilities* WorkerWebKitPlatformSupportImpl::fileUtilities() { - if (!file_utilities_) { - file_utilities_.reset(new FileUtilities(thread_safe_sender_.get())); - file_utilities_->set_sandbox_enabled(sandboxEnabled()); - } - return file_utilities_.get(); -} - -WebSandboxSupport* WorkerWebKitPlatformSupportImpl::sandboxSupport() { - NOTREACHED(); - return NULL; -} - -bool WorkerWebKitPlatformSupportImpl::sandboxEnabled() { - // Always return true because WebKit should always act as though the Sandbox - // is enabled for workers. See the comment in WebKitPlatformSupport for - // more info. - return true; -} - -unsigned long long WorkerWebKitPlatformSupportImpl::visitedLinkHash( - const char* canonical_url, - size_t length) { - NOTREACHED(); - return 0; -} - -bool WorkerWebKitPlatformSupportImpl::isLinkVisited( - unsigned long long link_hash) { - NOTREACHED(); - return false; -} - -void WorkerWebKitPlatformSupportImpl::createMessageChannel( - blink::WebMessagePortChannel** channel1, - blink::WebMessagePortChannel** channel2) { - WebMessagePortChannelImpl::CreatePair( - child_thread_loop_.get(), channel1, channel2); -} - -void WorkerWebKitPlatformSupportImpl::setCookies( - const WebURL& url, - const WebURL& first_party_for_cookies, - const WebString& value) { - NOTREACHED(); -} - -WebString WorkerWebKitPlatformSupportImpl::cookies( - const WebURL& url, const WebURL& first_party_for_cookies) { - // WebSocketHandshake may access cookies in worker process. - return WebString(); -} - -WebString WorkerWebKitPlatformSupportImpl::defaultLocale() { - NOTREACHED(); - return WebString(); -} - -WebStorageNamespace* -WorkerWebKitPlatformSupportImpl::createLocalStorageNamespace() { - NOTREACHED(); - return 0; -} - -void WorkerWebKitPlatformSupportImpl::dispatchStorageEvent( - const WebString& key, const WebString& old_value, - const WebString& new_value, const WebString& origin, - const blink::WebURL& url, bool is_local_storage) { - NOTREACHED(); -} - -Platform::FileHandle -WorkerWebKitPlatformSupportImpl::databaseOpenFile( - const WebString& vfs_file_name, int desired_flags) { - return DatabaseUtil::DatabaseOpenFile( - vfs_file_name, desired_flags, sync_message_filter_.get()); -} - -int WorkerWebKitPlatformSupportImpl::databaseDeleteFile( - const WebString& vfs_file_name, bool sync_dir) { - return DatabaseUtil::DatabaseDeleteFile( - vfs_file_name, sync_dir, sync_message_filter_.get()); -} - -long WorkerWebKitPlatformSupportImpl::databaseGetFileAttributes( - const WebString& vfs_file_name) { - return DatabaseUtil::DatabaseGetFileAttributes(vfs_file_name, - sync_message_filter_.get()); -} - -long long WorkerWebKitPlatformSupportImpl::databaseGetFileSize( - const WebString& vfs_file_name) { - return DatabaseUtil::DatabaseGetFileSize(vfs_file_name, - sync_message_filter_.get()); -} - -long long WorkerWebKitPlatformSupportImpl::databaseGetSpaceAvailableForOrigin( - const WebString& origin_identifier) { - return DatabaseUtil::DatabaseGetSpaceAvailable(origin_identifier, - sync_message_filter_.get()); -} - -blink::WebIDBFactory* WorkerWebKitPlatformSupportImpl::idbFactory() { - if (!web_idb_factory_) - web_idb_factory_.reset(new WebIDBFactoryImpl(thread_safe_sender_.get())); - return web_idb_factory_.get(); -} - -blink::WebDatabaseObserver* -WorkerWebKitPlatformSupportImpl::databaseObserver() { - return web_database_observer_impl_.get(); -} - -WebMimeRegistry::SupportsType -WorkerWebKitPlatformSupportImpl::supportsMIMEType( - const WebString&) { - return WebMimeRegistry::IsSupported; -} - -WebMimeRegistry::SupportsType -WorkerWebKitPlatformSupportImpl::supportsImageMIMEType( - const WebString&) { - NOTREACHED(); - return WebMimeRegistry::IsSupported; -} - -WebMimeRegistry::SupportsType -WorkerWebKitPlatformSupportImpl::supportsJavaScriptMIMEType(const WebString&) { - NOTREACHED(); - return WebMimeRegistry::IsSupported; -} - -WebMimeRegistry::SupportsType -WorkerWebKitPlatformSupportImpl::supportsMediaMIMEType( - const WebString&, const WebString&, const WebString&) { - NOTREACHED(); - return WebMimeRegistry::IsSupported; -} - -bool WorkerWebKitPlatformSupportImpl::supportsMediaSourceMIMEType( - const blink::WebString& mimeType, const blink::WebString& codecs) { - NOTREACHED(); - return false; -} - -bool WorkerWebKitPlatformSupportImpl::supportsEncryptedMediaMIMEType( - const blink::WebString& key_system, - const blink::WebString& mime_type, - const blink::WebString& codecs) { - NOTREACHED(); - return false; -} - -WebMimeRegistry::SupportsType -WorkerWebKitPlatformSupportImpl::supportsNonImageMIMEType( - const WebString&) { - NOTREACHED(); - return WebMimeRegistry::IsSupported; -} - -WebString WorkerWebKitPlatformSupportImpl::mimeTypeForExtension( - const WebString& file_extension) { - std::string mime_type; - thread_safe_sender_->Send(new MimeRegistryMsg_GetMimeTypeFromExtension( - base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type)); - return base::ASCIIToUTF16(mime_type); -} - -WebString WorkerWebKitPlatformSupportImpl::wellKnownMimeTypeForExtension( - const WebString& file_extension) { - std::string mime_type; - net::GetWellKnownMimeTypeFromExtension( - base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type); - return base::ASCIIToUTF16(mime_type); -} - -WebString WorkerWebKitPlatformSupportImpl::mimeTypeFromFile( - const WebString& file_path) { - std::string mime_type; - thread_safe_sender_->Send( - new MimeRegistryMsg_GetMimeTypeFromFile( - base::FilePath::FromUTF16Unsafe(file_path), - &mime_type)); - return base::ASCIIToUTF16(mime_type); -} - -WebBlobRegistry* WorkerWebKitPlatformSupportImpl::blobRegistry() { - return blob_registry_.get(); -} - -void WorkerWebKitPlatformSupportImpl::queryStorageUsageAndQuota( - const blink::WebURL& storage_partition, - blink::WebStorageQuotaType type, - blink::WebStorageQuotaCallbacks callbacks) { - if (!thread_safe_sender_.get() || !quota_message_filter_.get()) - return; - QuotaDispatcher::ThreadSpecificInstance( - thread_safe_sender_.get(), - quota_message_filter_.get())->QueryStorageUsageAndQuota( - storage_partition, - static_cast(type), - QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); -} - -} // namespace content diff --git a/content/worker/worker_webkitplatformsupport_impl.h b/content/worker/worker_webkitplatformsupport_impl.h deleted file mode 100644 index 9fa56d464e9f4e..00000000000000 --- a/content/worker/worker_webkitplatformsupport_impl.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ -#define CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ - -#include "base/memory/scoped_ptr.h" -#include "content/child/blink_platform_impl.h" -#include "third_party/WebKit/public/platform/WebIDBFactory.h" -#include "third_party/WebKit/public/platform/WebMimeRegistry.h" - -namespace base { -class MessageLoopProxy; -} - -namespace IPC { -class SyncMessageFilter; -} - -namespace blink { -class WebFileUtilities; -} - -namespace content { -class QuotaMessageFilter; -class ThreadSafeSender; -class WebDatabaseObserverImpl; -class WebFileSystemImpl; - -class WorkerWebKitPlatformSupportImpl : public BlinkPlatformImpl, - public blink::WebMimeRegistry { - public: - WorkerWebKitPlatformSupportImpl( - ThreadSafeSender* sender, - IPC::SyncMessageFilter* sync_message_filter, - QuotaMessageFilter* quota_message_filter); - virtual ~WorkerWebKitPlatformSupportImpl(); - - // WebKitPlatformSupport methods: - virtual blink::WebClipboard* clipboard(); - virtual blink::WebMimeRegistry* mimeRegistry(); - virtual blink::WebFileSystem* fileSystem(); - virtual blink::WebFileUtilities* fileUtilities(); - virtual blink::WebSandboxSupport* sandboxSupport(); - virtual bool sandboxEnabled(); - virtual unsigned long long visitedLinkHash(const char* canonicalURL, - size_t length); - virtual bool isLinkVisited(unsigned long long linkHash); - virtual void createMessageChannel(blink::WebMessagePortChannel** channel1, - blink::WebMessagePortChannel** channel2); - virtual void setCookies(const blink::WebURL& url, - const blink::WebURL& first_party_for_cookies, - const blink::WebString& value); - virtual blink::WebString cookies( - const blink::WebURL& url, - const blink::WebURL& first_party_for_cookies); - virtual blink::WebString defaultLocale(); - virtual blink::WebStorageNamespace* createLocalStorageNamespace(); - virtual void dispatchStorageEvent( - const blink::WebString& key, const blink::WebString& old_value, - const blink::WebString& new_value, const blink::WebString& origin, - const blink::WebURL& url, bool is_local_storage); - - virtual blink::Platform::FileHandle databaseOpenFile( - const blink::WebString& vfs_file_name, int desired_flags); - virtual int databaseDeleteFile(const blink::WebString& vfs_file_name, - bool sync_dir); - virtual long databaseGetFileAttributes( - const blink::WebString& vfs_file_name); - virtual long long databaseGetFileSize( - const blink::WebString& vfs_file_name); - virtual long long databaseGetSpaceAvailableForOrigin( - const blink::WebString& origin_identifier); - virtual blink::WebBlobRegistry* blobRegistry(); - virtual blink::WebIDBFactory* idbFactory(); - virtual blink::WebDatabaseObserver* databaseObserver(); - - // WebMimeRegistry methods: - virtual blink::WebMimeRegistry::SupportsType supportsMIMEType( - const blink::WebString&); - virtual blink::WebMimeRegistry::SupportsType supportsImageMIMEType( - const blink::WebString&); - virtual blink::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType( - const blink::WebString&); - virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( - const blink::WebString&, - const blink::WebString&, - const blink::WebString&); - virtual bool supportsMediaSourceMIMEType( - const blink::WebString&, - const blink::WebString&); - virtual bool supportsEncryptedMediaMIMEType(const blink::WebString&, - const blink::WebString&, - const blink::WebString&); - virtual blink::WebMimeRegistry::SupportsType supportsNonImageMIMEType( - const blink::WebString&); - virtual blink::WebString mimeTypeForExtension(const blink::WebString&); - virtual blink::WebString wellKnownMimeTypeForExtension( - const blink::WebString&); - virtual blink::WebString mimeTypeFromFile(const blink::WebString&); - virtual void queryStorageUsageAndQuota( - const blink::WebURL& storage_partition, - blink::WebStorageQuotaType, - blink::WebStorageQuotaCallbacks) OVERRIDE; - - WebDatabaseObserverImpl* web_database_observer_impl() { - return web_database_observer_impl_.get(); - } - - private: - - class FileUtilities; - scoped_ptr file_utilities_; - scoped_ptr blob_registry_; - scoped_ptr web_idb_factory_; - scoped_refptr thread_safe_sender_; - scoped_refptr child_thread_loop_; - scoped_refptr sync_message_filter_; - scoped_refptr quota_message_filter_; - scoped_ptr web_database_observer_impl_; - - DISALLOW_COPY_AND_ASSIGN(WorkerWebKitPlatformSupportImpl); -}; - -} // namespace content - -#endif // CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ diff --git a/extensions/shell/app_shell.gyp b/extensions/shell/app_shell.gyp index bfd9ac19c0ca4b..cb1dceb83770be 100644 --- a/extensions/shell/app_shell.gyp +++ b/extensions/shell/app_shell.gyp @@ -79,7 +79,6 @@ '<(DEPTH)/content/content.gyp:content', '<(DEPTH)/content/content.gyp:content_gpu', '<(DEPTH)/content/content.gyp:content_ppapi_plugin', - '<(DEPTH)/content/content.gyp:content_worker', '<(DEPTH)/content/content_shell_and_tests.gyp:content_shell_lib', '<(DEPTH)/extensions/common/api/api.gyp:extensions_api', '<(DEPTH)/extensions/extensions.gyp:extensions_browser',