summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhoro@chromium.org <horo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 08:54:02 +0000
committerhoro@chromium.org <horo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 08:54:02 +0000
commitab4d372e38ccfd13b5802a00d66e9552b93d9928 (patch)
tree39e111056c0bd989f4ea16cab758c64269aba41a
parent8370cc3f82216fabc914e609faaae11cf375ab94 (diff)
downloadchromium_src-ab4d372e38ccfd13b5802a00d66e9552b93d9928.zip
chromium_src-ab4d372e38ccfd13b5802a00d66e9552b93d9928.tar.gz
chromium_src-ab4d372e38ccfd13b5802a00d66e9552b93d9928.tar.bz2
Revert of Make DevTools support for the embedded SharedWorker. (https://codereview.chromium.org/196503005/)
Reason for revert: buildbot failure in Chromium Memory on Linux ASan+LSan Tests SharedWorkerDevToolsManagerTest.AttachTest test causes memory leaks. Original issue's description: > Make DevTools support for the embedded SharedWorker. > > BUG=327256 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=261314 TBR=kinuko@chromium.org,pfeldman@chromium.org,yurys@chromium.org,sergeyv@chromium.org,jochen@chromium.org NOTREECHECKS=true NOTRY=true BUG=327256 Review URL: https://codereview.chromium.org/223583002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261327 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/devtools/shared_worker_devtools_manager.cc248
-rw-r--r--content/browser/devtools/shared_worker_devtools_manager.h95
-rw-r--r--content/browser/devtools/shared_worker_devtools_manager_unittest.cc263
-rw-r--r--content/browser/devtools/worker_devtools_manager.cc13
-rw-r--r--content/browser/devtools/worker_devtools_manager.h6
-rw-r--r--content/browser/shared_worker/shared_worker_host.cc44
-rw-r--r--content/browser/shared_worker/shared_worker_host.h12
-rw-r--r--content/browser/shared_worker/shared_worker_instance.cc16
-rw-r--r--content/browser/shared_worker/shared_worker_instance.h4
-rw-r--r--content/browser/shared_worker/shared_worker_service_impl.cc100
-rw-r--r--content/browser/shared_worker/shared_worker_service_impl.h17
-rw-r--r--content/browser/shared_worker/shared_worker_service_impl_unittest.cc7
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/content_tests.gypi1
-rw-r--r--content/renderer/render_thread_impl.cc1
-rw-r--r--content/renderer/shared_worker/embedded_shared_worker_stub.cc11
-rw-r--r--content/renderer/shared_worker/embedded_shared_worker_stub.h1
17 files changed, 49 insertions, 792 deletions
diff --git a/content/browser/devtools/shared_worker_devtools_manager.cc b/content/browser/devtools/shared_worker_devtools_manager.cc
deleted file mode 100644
index eac5114..0000000
--- a/content/browser/devtools/shared_worker_devtools_manager.cc
+++ /dev/null
@@ -1,248 +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.
-
-#include "content/browser/devtools/shared_worker_devtools_manager.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/ipc_devtools_agent_host.h"
-#include "content/browser/shared_worker/shared_worker_instance.h"
-#include "content/common/devtools_messages.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/worker_service.h"
-#include "ipc/ipc_listener.h"
-
-namespace content {
-
-namespace {
-
-bool SendMessageToWorker(const SharedWorkerDevToolsManager::WorkerId& worker_id,
- IPC::Message* message) {
- RenderProcessHost* host = RenderProcessHost::FromID(worker_id.first);
- if (!host) {
- delete message;
- return false;
- }
- message->set_routing_id(worker_id.second);
- host->Send(message);
- return true;
-}
-
-} // namespace
-
-class SharedWorkerDevToolsManager::SharedWorkerDevToolsAgentHost
- : public IPCDevToolsAgentHost,
- public IPC::Listener {
- public:
- explicit SharedWorkerDevToolsAgentHost(WorkerId worker_id)
- : worker_id_(worker_id), worker_attached_(true) {
- AddRef();
- if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first))
- host->AddRoute(worker_id_.second, this);
- }
-
- // IPCDevToolsAgentHost implementation.
- virtual void SendMessageToAgent(IPC::Message* message) OVERRIDE {
- if (worker_attached_)
- SendMessageToWorker(worker_id_, message);
- }
- virtual void OnClientAttached() OVERRIDE {}
- virtual void OnClientDetached() OVERRIDE {}
-
- // IPC::Listener implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(SharedWorkerDevToolsAgentHost, msg)
- IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend,
- OnDispatchOnInspectorFrontend)
- IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState,
- OnSaveAgentRuntimeState)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
- }
-
- void ReattachToWorker(WorkerId worker_id) {
- CHECK(!worker_attached_);
- worker_attached_ = true;
- worker_id_ = worker_id;
- AddRef();
- if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first))
- host->AddRoute(worker_id_.second, this);
- Reattach(state_);
- }
-
- void DetachFromWorker() {
- CHECK(worker_attached_);
- worker_attached_ = false;
- if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first))
- host->RemoveRoute(worker_id_.second);
- Release();
- }
-
- WorkerId worker_id() const { return worker_id_; }
-
- private:
- virtual ~SharedWorkerDevToolsAgentHost() {
- CHECK(!worker_attached_);
- SharedWorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData(this);
- }
-
- void OnDispatchOnInspectorFrontend(const std::string& message) {
- DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend(this,
- message);
- }
-
- void OnSaveAgentRuntimeState(const std::string& state) { state_ = state; }
-
- WorkerId worker_id_;
- bool worker_attached_;
- std::string state_;
- DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsAgentHost);
-};
-
-// static
-SharedWorkerDevToolsManager* SharedWorkerDevToolsManager::GetInstance() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return Singleton<SharedWorkerDevToolsManager>::get();
-}
-
-DevToolsAgentHost* SharedWorkerDevToolsManager::GetDevToolsAgentHostForWorker(
- int worker_process_id,
- int worker_route_id) {
- WorkerId id(worker_process_id, worker_route_id);
-
- WorkerInfoMap::iterator it = workers_.find(id);
- if (it == workers_.end())
- return NULL;
-
- WorkerInfo* info = it->second;
- if (info->state() != WORKER_UNINSPECTED)
- return info->agent_host();
-
- SharedWorkerDevToolsAgentHost* agent_host =
- new SharedWorkerDevToolsAgentHost(id);
- info->set_agent_host(agent_host);
- info->set_state(WORKER_INSPECTED);
- return agent_host;
-}
-
-SharedWorkerDevToolsManager::SharedWorkerDevToolsManager() {}
-
-SharedWorkerDevToolsManager::~SharedWorkerDevToolsManager() {}
-
-bool SharedWorkerDevToolsManager::WorkerCreated(
- int worker_process_id,
- int worker_route_id,
- const SharedWorkerInstance& instance) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const WorkerId id(worker_process_id, worker_route_id);
- WorkerInfoMap::iterator it = FindExistingWorkerInfo(instance);
- if (it == workers_.end()) {
- scoped_ptr<WorkerInfo> info(new WorkerInfo(instance));
- workers_.set(id, info.Pass());
- return false;
- }
- DCHECK_EQ(WORKER_TERMINATED, it->second->state());
- scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it);
- info->set_state(WORKER_PAUSED);
- workers_.set(id, info.Pass());
- return true;
-}
-
-void SharedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id,
- int worker_route_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const WorkerId id(worker_process_id, worker_route_id);
- WorkerInfoMap::iterator it = workers_.find(id);
- DCHECK(it != workers_.end());
- WorkerInfo* info = it->second;
- switch (info->state()) {
- case WORKER_UNINSPECTED:
- workers_.erase(it);
- break;
- case WORKER_INSPECTED: {
- SharedWorkerDevToolsAgentHost* agent_host = info->agent_host();
- if (!agent_host->IsAttached()) {
- scoped_ptr<WorkerInfo> worker_info = workers_.take_and_erase(it);
- agent_host->DetachFromWorker();
- return;
- }
- info->set_state(WORKER_TERMINATED);
- // Client host is debugging this worker agent host.
- std::string notification =
- DevToolsProtocol::CreateNotification(
- devtools::Worker::disconnectedFromWorker::kName, NULL)
- ->Serialize();
- DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend(
- agent_host, notification);
- agent_host->DetachFromWorker();
- break;
- }
- case WORKER_TERMINATED:
- NOTREACHED();
- break;
- case WORKER_PAUSED: {
- scoped_ptr<WorkerInfo> worker_info = workers_.take_and_erase(it);
- worker_info->set_state(WORKER_TERMINATED);
- const WorkerId old_id = worker_info->agent_host()->worker_id();
- workers_.set(old_id, worker_info.Pass());
- break;
- }
- }
-}
-
-void SharedWorkerDevToolsManager::WorkerContextStarted(int worker_process_id,
- int worker_route_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const WorkerId id(worker_process_id, worker_route_id);
- WorkerInfoMap::iterator it = workers_.find(id);
- DCHECK(it != workers_.end());
- WorkerInfo* info = it->second;
- if (info->state() != WORKER_PAUSED)
- return;
- info->agent_host()->ReattachToWorker(id);
- info->set_state(WORKER_INSPECTED);
-}
-
-void SharedWorkerDevToolsManager::RemoveInspectedWorkerData(
- SharedWorkerDevToolsAgentHost* agent_host) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const WorkerId id(agent_host->worker_id());
- scoped_ptr<WorkerInfo> worker_info = workers_.take_and_erase(id);
- if (worker_info) {
- DCHECK_EQ(WORKER_TERMINATED, worker_info->state());
- return;
- }
- for (WorkerInfoMap::iterator it = workers_.begin(); it != workers_.end();
- ++it) {
- if (it->second->agent_host() == agent_host) {
- DCHECK_EQ(WORKER_PAUSED, it->second->state());
- SendMessageToWorker(
- it->first,
- new DevToolsAgentMsg_ResumeWorkerContext(it->first.second));
- it->second->set_agent_host(NULL);
- it->second->set_state(WORKER_UNINSPECTED);
- return;
- }
- }
-}
-
-SharedWorkerDevToolsManager::WorkerInfoMap::iterator
-SharedWorkerDevToolsManager::FindExistingWorkerInfo(
- const SharedWorkerInstance& instance) {
- WorkerInfoMap::iterator it = workers_.begin();
- for (; it != workers_.end(); ++it) {
- if (it->second->instance().Matches(instance))
- break;
- }
- return it;
-}
-
-void SharedWorkerDevToolsManager::ResetForTesting() { workers_.clear(); }
-
-} // namespace content
diff --git a/content/browser/devtools/shared_worker_devtools_manager.h b/content/browser/devtools/shared_worker_devtools_manager.h
deleted file mode 100644
index 4b23821..0000000
--- a/content/browser/devtools/shared_worker_devtools_manager.h
+++ /dev/null
@@ -1,95 +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.
-
-#ifndef CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
-#define CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
-
-#include "base/basictypes.h"
-#include "base/containers/scoped_ptr_hash_map.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/singleton.h"
-#include "base/strings/string16.h"
-#include "content/browser/shared_worker/shared_worker_instance.h"
-#include "content/common/content_export.h"
-
-class GURL;
-
-namespace content {
-class DevToolsAgentHost;
-
-// SharedWorkerDevToolsManager is used instead of WorkerDevToolsManager when
-// "enable-embedded-shared-worker" flag is set.
-// This class lives on UI thread.
-class CONTENT_EXPORT SharedWorkerDevToolsManager {
- public:
- typedef std::pair<int, int> WorkerId;
- class SharedWorkerDevToolsAgentHost;
-
- // Returns the SharedWorkerDevToolsManager singleton.
- static SharedWorkerDevToolsManager* GetInstance();
-
- DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
- int worker_route_id);
-
- // Returns true when the worker must be paused on start.
- bool WorkerCreated(int worker_process_id,
- int worker_route_id,
- const SharedWorkerInstance& instance);
- void WorkerDestroyed(int worker_process_id, int worker_route_id);
- void WorkerContextStarted(int worker_process_id, int worker_route_id);
-
- private:
- friend struct DefaultSingletonTraits<SharedWorkerDevToolsManager>;
- friend class SharedWorkerDevToolsManagerTest;
- FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, BasicTest);
- FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, AttachTest);
-
- enum WorkerState {
- WORKER_UNINSPECTED,
- WORKER_INSPECTED,
- WORKER_TERMINATED,
- WORKER_PAUSED,
- };
-
- class WorkerInfo {
- public:
- explicit WorkerInfo(const SharedWorkerInstance& instance)
- : instance_(instance), state_(WORKER_UNINSPECTED), agent_host_(NULL) {}
-
- const SharedWorkerInstance& instance() const { return instance_; }
- WorkerState state() { return state_; }
- void set_state(WorkerState new_state) { state_ = new_state; }
- SharedWorkerDevToolsAgentHost* agent_host() { return agent_host_; }
- void set_agent_host(SharedWorkerDevToolsAgentHost* agent_host) {
- agent_host_ = agent_host;
- }
-
- private:
- const SharedWorkerInstance instance_;
- WorkerState state_;
- SharedWorkerDevToolsAgentHost* agent_host_;
- };
-
- typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap;
-
- SharedWorkerDevToolsManager();
- virtual ~SharedWorkerDevToolsManager();
-
- void RemoveInspectedWorkerData(SharedWorkerDevToolsAgentHost* agent_host);
-
- WorkerInfoMap::iterator FindExistingWorkerInfo(
- const SharedWorkerInstance& instance);
-
- // Resets to its initial state as if newly created.
- void ResetForTesting();
-
- WorkerInfoMap workers_;
-
- DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsManager);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
diff --git a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc b/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
deleted file mode 100644
index 5b4e536..0000000
--- a/content/browser/devtools/shared_worker_devtools_manager_unittest.cc
+++ /dev/null
@@ -1,263 +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.
-
-#include "content/browser/devtools/shared_worker_devtools_manager.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#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/public/browser/devtools_agent_host.h"
-#include "content/public/browser/devtools_client_host.h"
-#include "content/public/test/test_browser_context.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace content {
-namespace {
-
-class TestDevToolsClientHost : public DevToolsClientHost {
- public:
- TestDevToolsClientHost() {}
- virtual ~TestDevToolsClientHost() {}
- virtual void DispatchOnInspectorFrontend(const std::string& message)
- OVERRIDE {}
- virtual void InspectedContentsClosing() OVERRIDE {}
- virtual void ReplacedWithAnotherClient() OVERRIDE {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestDevToolsClientHost);
-};
-}
-
-class SharedWorkerDevToolsManagerTest : public testing::Test {
- public:
- SharedWorkerDevToolsManagerTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- browser_context_(new TestBrowserContext()),
- partition_(
- new WorkerStoragePartition(browser_context_->GetRequestContext(),
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL)) {}
-
- protected:
- virtual void SetUp() OVERRIDE {
- manager_ = SharedWorkerDevToolsManager::GetInstance();
- }
- virtual void TearDown() OVERRIDE {
- SharedWorkerDevToolsManager::GetInstance()->ResetForTesting();
- }
-
- void CheckWorkerState(int worker_process_id,
- int worker_route_id,
- SharedWorkerDevToolsManager::WorkerState state) {
- const SharedWorkerDevToolsManager::WorkerId id(worker_process_id,
- worker_route_id);
- SharedWorkerDevToolsManager::WorkerInfoMap::iterator it =
- manager_->workers_.find(id);
- EXPECT_TRUE(manager_->workers_.end() != it);
- EXPECT_EQ(state, it->second->state());
- }
-
- void CheckWorkerNotExist(int worker_process_id, int worker_route_id) {
- const SharedWorkerDevToolsManager::WorkerId id(worker_process_id,
- worker_route_id);
- EXPECT_TRUE(manager_->workers_.end() == manager_->workers_.find(id));
- }
-
- void CheckWorkerCount(size_t size) {
- EXPECT_EQ(size, manager_->workers_.size());
- }
-
- void RegisterDevToolsClientHostFor(DevToolsAgentHost* agent_host,
- DevToolsClientHost* client_host) {
- DevToolsManagerImpl::GetInstance()->RegisterDevToolsClientHostFor(
- agent_host, client_host);
- }
-
- void ClientHostClosing(DevToolsClientHost* client_host) {
- DevToolsManagerImpl::GetInstance()->ClientHostClosing(client_host);
- }
-
- base::MessageLoopForIO message_loop_;
- BrowserThreadImpl ui_thread_;
- scoped_ptr<TestBrowserContext> browser_context_;
- scoped_ptr<WorkerStoragePartition> partition_;
- SharedWorkerDevToolsManager* manager_;
-};
-
-TEST_F(SharedWorkerDevToolsManagerTest, BasicTest) {
- scoped_refptr<DevToolsAgentHost> agent_host;
-
- SharedWorkerInstance instance1(GURL("http://example.com/w.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- *partition_.get());
-
- agent_host = manager_->GetDevToolsAgentHostForWorker(1, 1);
- EXPECT_FALSE(agent_host.get());
-
- // Created -> Started -> Destroyed
- CheckWorkerNotExist(1, 1);
- manager_->WorkerCreated(1, 1, instance1);
- CheckWorkerState(1, 1, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- manager_->WorkerContextStarted(1, 1);
- CheckWorkerState(1, 1, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- manager_->WorkerDestroyed(1, 1);
- CheckWorkerNotExist(1, 1);
-
- // Created -> GetDevToolsAgentHost -> Started -> Destroyed
- CheckWorkerNotExist(1, 2);
- manager_->WorkerCreated(1, 2, instance1);
- CheckWorkerState(1, 2, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host = manager_->GetDevToolsAgentHostForWorker(1, 2);
- EXPECT_TRUE(agent_host.get());
- CheckWorkerState(1, 2, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- EXPECT_EQ(agent_host.get(), manager_->GetDevToolsAgentHostForWorker(1, 2));
- manager_->WorkerContextStarted(1, 2);
- CheckWorkerState(1, 2, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerDestroyed(1, 2);
- CheckWorkerNotExist(1, 2);
- agent_host = NULL;
-
- // Created -> Started -> GetDevToolsAgentHost -> Destroyed
- CheckWorkerNotExist(1, 3);
- manager_->WorkerCreated(1, 3, instance1);
- CheckWorkerState(1, 3, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- manager_->WorkerContextStarted(1, 3);
- CheckWorkerState(1, 3, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host = manager_->GetDevToolsAgentHostForWorker(1, 3);
- EXPECT_TRUE(agent_host.get());
- CheckWorkerState(1, 3, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerDestroyed(1, 3);
- CheckWorkerNotExist(1, 3);
- agent_host = NULL;
-
- // Created -> Destroyed
- CheckWorkerNotExist(1, 4);
- manager_->WorkerCreated(1, 4, instance1);
- CheckWorkerState(1, 4, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- manager_->WorkerDestroyed(1, 4);
- CheckWorkerNotExist(1, 4);
-
- // Created -> GetDevToolsAgentHost -> Destroyed
- CheckWorkerNotExist(1, 5);
- manager_->WorkerCreated(1, 5, instance1);
- CheckWorkerState(1, 5, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host = manager_->GetDevToolsAgentHostForWorker(1, 5);
- EXPECT_TRUE(agent_host.get());
- CheckWorkerState(1, 5, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerDestroyed(1, 5);
- CheckWorkerNotExist(1, 5);
- agent_host = NULL;
-
- // Created -> GetDevToolsAgentHost -> Free agent_host -> Destroyed
- CheckWorkerNotExist(1, 6);
- manager_->WorkerCreated(1, 6, instance1);
- CheckWorkerState(1, 6, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host = manager_->GetDevToolsAgentHostForWorker(1, 6);
- EXPECT_TRUE(agent_host.get());
- CheckWorkerState(1, 6, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- agent_host = NULL;
- manager_->WorkerDestroyed(1, 6);
- CheckWorkerNotExist(1, 6);
-}
-
-TEST_F(SharedWorkerDevToolsManagerTest, AttachTest) {
- scoped_refptr<DevToolsAgentHost> agent_host1;
- scoped_refptr<DevToolsAgentHost> agent_host2;
-
- SharedWorkerInstance instance1(GURL("http://example.com/w1.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- *partition_.get());
- SharedWorkerInstance instance2(GURL("http://example.com/w2.js"),
- base::string16(),
- base::string16(),
- blink::WebContentSecurityPolicyTypeReport,
- browser_context_->GetResourceContext(),
- *partition_.get());
-
- // Created -> GetDevToolsAgentHost -> Register -> Started -> Destroyed
- scoped_ptr<TestDevToolsClientHost> client_host1(new TestDevToolsClientHost());
- CheckWorkerNotExist(2, 1);
- manager_->WorkerCreated(2, 1, instance1);
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host1 = manager_->GetDevToolsAgentHostForWorker(2, 1);
- EXPECT_TRUE(agent_host1.get());
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- EXPECT_EQ(agent_host1.get(), manager_->GetDevToolsAgentHostForWorker(2, 1));
- RegisterDevToolsClientHostFor(agent_host1.get(), client_host1.get());
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerContextStarted(2, 1);
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerDestroyed(2, 1);
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_TERMINATED);
- EXPECT_EQ(agent_host1.get(), manager_->GetDevToolsAgentHostForWorker(2, 1));
-
- // Created -> Started -> GetDevToolsAgentHost -> Register -> Destroyed
- scoped_ptr<TestDevToolsClientHost> client_host2(new TestDevToolsClientHost());
- manager_->WorkerCreated(2, 2, instance2);
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- manager_->WorkerContextStarted(2, 2);
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_UNINSPECTED);
- agent_host2 = manager_->GetDevToolsAgentHostForWorker(2, 2);
- EXPECT_TRUE(agent_host2.get());
- EXPECT_NE(agent_host1.get(), agent_host2.get());
- EXPECT_EQ(agent_host2.get(), manager_->GetDevToolsAgentHostForWorker(2, 2));
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- RegisterDevToolsClientHostFor(agent_host2.get(), client_host2.get());
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- manager_->WorkerDestroyed(2, 2);
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_TERMINATED);
- EXPECT_EQ(agent_host2.get(), manager_->GetDevToolsAgentHostForWorker(2, 2));
-
- // Re-created -> Started -> ClientHostClosing -> Destroyed
- CheckWorkerState(2, 1, SharedWorkerDevToolsManager::WORKER_TERMINATED);
- manager_->WorkerCreated(2, 3, instance1);
- CheckWorkerNotExist(2, 1);
- CheckWorkerState(2, 3, SharedWorkerDevToolsManager::WORKER_PAUSED);
- EXPECT_EQ(agent_host1.get(), manager_->GetDevToolsAgentHostForWorker(2, 3));
- manager_->WorkerContextStarted(2, 3);
- CheckWorkerState(2, 3, SharedWorkerDevToolsManager::WORKER_INSPECTED);
- ClientHostClosing(client_host1.get());
- manager_->WorkerDestroyed(2, 3);
- CheckWorkerNotExist(2, 3);
- agent_host1 = NULL;
-
- // Re-created -> Destroyed
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_TERMINATED);
- manager_->WorkerCreated(2, 4, instance2);
- CheckWorkerNotExist(2, 2);
- CheckWorkerState(2, 4, SharedWorkerDevToolsManager::WORKER_PAUSED);
- EXPECT_EQ(agent_host2.get(), manager_->GetDevToolsAgentHostForWorker(2, 4));
- manager_->WorkerDestroyed(2, 4);
- CheckWorkerNotExist(2, 4);
- CheckWorkerState(2, 2, SharedWorkerDevToolsManager::WORKER_TERMINATED);
-
- // Re-created -> ClientHostClosing -> Destroyed
- manager_->WorkerCreated(2, 5, instance2);
- CheckWorkerNotExist(2, 2);
- CheckWorkerState(2, 5, SharedWorkerDevToolsManager::WORKER_PAUSED);
- EXPECT_EQ(agent_host2.get(), manager_->GetDevToolsAgentHostForWorker(2, 5));
- ClientHostClosing(client_host2.get());
- CheckWorkerCount(1);
- agent_host2 = NULL;
- CheckWorkerCount(1);
- manager_->WorkerDestroyed(2, 5);
- CheckWorkerCount(0);
-}
-
-} // namespace content
diff --git a/content/browser/devtools/worker_devtools_manager.cc b/content/browser/devtools/worker_devtools_manager.cc
index a05a04a..62f77e7 100644
--- a/content/browser/devtools/worker_devtools_manager.cc
+++ b/content/browser/devtools/worker_devtools_manager.cc
@@ -13,7 +13,6 @@
#include "content/browser/devtools/devtools_protocol.h"
#include "content/browser/devtools/devtools_protocol_constants.h"
#include "content/browser/devtools/ipc_devtools_agent_host.h"
-#include "content/browser/devtools/shared_worker_devtools_manager.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"
@@ -28,13 +27,9 @@ namespace content {
scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker(
int worker_process_id,
int worker_route_id) {
- if (WorkerService::EmbeddedSharedWorkerEnabled()) {
- return SharedWorkerDevToolsManager::GetInstance()
- ->GetDevToolsAgentHostForWorker(worker_process_id, worker_route_id);
- } else {
- return WorkerDevToolsManager::GetDevToolsAgentHostForWorker(
- worker_process_id, worker_route_id);
- }
+ return WorkerDevToolsManager::GetDevToolsAgentHostForWorker(
+ worker_process_id,
+ worker_route_id);
}
namespace {
@@ -212,7 +207,6 @@ struct WorkerDevToolsManager::InspectedWorker {
// static
WorkerDevToolsManager* WorkerDevToolsManager::GetInstance() {
- DCHECK(!WorkerService::EmbeddedSharedWorkerEnabled());
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return Singleton<WorkerDevToolsManager>::get();
}
@@ -221,7 +215,6 @@ WorkerDevToolsManager* WorkerDevToolsManager::GetInstance() {
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())
diff --git a/content/browser/devtools/worker_devtools_manager.h b/content/browser/devtools/worker_devtools_manager.h
index 73916c3..a70f178 100644
--- a/content/browser/devtools/worker_devtools_manager.h
+++ b/content/browser/devtools/worker_devtools_manager.h
@@ -19,7 +19,6 @@ 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<int, int> WorkerId;
@@ -42,8 +41,9 @@ class WorkerDevToolsManager {
// Called on the IO thread.
// Returns true when the worker must be paused on start.
- bool WorkerCreated(WorkerProcessHost* process,
- const WorkerProcessHost::WorkerInstance& instance);
+ bool WorkerCreated(
+ WorkerProcessHost* process,
+ const WorkerProcessHost::WorkerInstance& instance);
void WorkerDestroyed(WorkerProcessHost* process, int worker_route_id);
void WorkerContextStarted(WorkerProcessHost* process, int worker_route_id);
diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc
index acca666..78ffb4b 100644
--- a/content/browser/shared_worker/shared_worker_host.cc
+++ b/content/browser/shared_worker/shared_worker_host.cc
@@ -5,19 +5,16 @@
#include "content/browser/shared_worker/shared_worker_host.h"
#include "base/metrics/histogram.h"
-#include "content/browser/devtools/shared_worker_devtools_manager.h"
#include "content/browser/frame_host/render_frame_host_delegate.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/message_port_service.h"
#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/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/render_process_host.h"
#include "content/public/common/content_client.h"
namespace content {
@@ -31,27 +28,13 @@ void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) {
host->delegate()->WorkerCrashed(host);
}
-void NotifyWorkerScriptLoadedOnUI(int worker_process_id, int worker_route_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- SharedWorkerDevToolsManager::GetInstance()->WorkerContextStarted(
- worker_process_id, worker_route_id);
-}
-
-void NotifyWorkerDestroyedOnUI(int worker_process_id, int worker_route_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- SharedWorkerDevToolsManager::GetInstance()->WorkerDestroyed(worker_process_id,
- worker_route_id);
-}
-
} // namespace
-SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance,
- SharedWorkerMessageFilter* filter)
+SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance)
: instance_(instance),
worker_document_set_(new WorkerDocumentSet()),
- container_render_filter_(filter),
- worker_process_id_(filter->render_process_id()),
- worker_route_id_(filter->GetNextRoutingID()),
+ container_render_filter_(NULL),
+ worker_route_id_(MSG_ROUTING_NONE),
load_failed_(false),
closed_(false),
creation_time_(base::TimeTicks::Now()) {
@@ -77,13 +60,6 @@ SharedWorkerHost::~SharedWorkerHost() {
parent_iter->render_frame_id()));
}
}
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(
- &NotifyWorkerDestroyedOnUI, worker_process_id_, worker_route_id_));
- SharedWorkerServiceImpl::GetInstance()->NotifyWorkerDestroyed(
- worker_process_id_, worker_route_id_);
}
bool SharedWorkerHost::Send(IPC::Message* message) {
@@ -94,13 +70,17 @@ bool SharedWorkerHost::Send(IPC::Message* message) {
return container_render_filter_->Send(message);
}
-void SharedWorkerHost::Start(bool pause_on_start) {
+void SharedWorkerHost::Init(SharedWorkerMessageFilter* filter) {
+ CHECK(instance_);
+ DCHECK(worker_route_id_ == MSG_ROUTING_NONE);
+ container_render_filter_ = filter;
+ worker_route_id_ = filter->GetNextRoutingID();
+
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 = worker_route_id_;
Send(new WorkerProcessMsg_CreateWorker(params));
@@ -163,13 +143,9 @@ void SharedWorkerHost::WorkerContextDestroyed() {
}
void SharedWorkerHost::WorkerScriptLoaded() {
+ // TODO(horo): implement this.
UMA_HISTOGRAM_TIMES("SharedWorker.TimeToScriptLoaded",
base::TimeTicks::Now() - creation_time_);
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(
- &NotifyWorkerScriptLoadedOnUI, worker_process_id_, worker_route_id_));
}
void SharedWorkerHost::WorkerScriptLoadFailed() {
diff --git a/content/browser/shared_worker/shared_worker_host.h b/content/browser/shared_worker/shared_worker_host.h
index 5b2a27b..3fdc29f 100644
--- a/content/browser/shared_worker/shared_worker_host.h
+++ b/content/browser/shared_worker/shared_worker_host.h
@@ -28,16 +28,15 @@ class SharedWorkerInstance;
// the browser <-> worker communication channel.
class SharedWorkerHost {
public:
- SharedWorkerHost(SharedWorkerInstance* instance,
- SharedWorkerMessageFilter* filter);
+ explicit SharedWorkerHost(SharedWorkerInstance* instance);
~SharedWorkerHost();
// Sends |message| to the SharedWorker.
bool Send(IPC::Message* message);
// Starts the SharedWorker in the renderer process which is associated with
- // |filter_|.
- void Start(bool pause_on_start);
+ // |filter|.
+ void Init(SharedWorkerMessageFilter* filter);
// Returns true iff the given message from a renderer process was forwarded to
// the worker.
@@ -80,7 +79,9 @@ class SharedWorkerHost {
SharedWorkerMessageFilter* container_render_filter() const {
return container_render_filter_;
}
- int process_id() const { return worker_process_id_; }
+ int process_id() const {
+ return container_render_filter_->render_process_id();
+ }
int worker_route_id() const { return worker_route_id_; }
bool load_failed() const { return load_failed_; }
bool closed() const { return closed_; }
@@ -122,7 +123,6 @@ class SharedWorkerHost {
scoped_refptr<WorkerDocumentSet> worker_document_set_;
FilterList filters_;
SharedWorkerMessageFilter* container_render_filter_;
- int worker_process_id_;
int worker_route_id_;
bool load_failed_;
bool closed_;
diff --git a/content/browser/shared_worker/shared_worker_instance.cc b/content/browser/shared_worker/shared_worker_instance.cc
index a4965a5..506626a 100644
--- a/content/browser/shared_worker/shared_worker_instance.cc
+++ b/content/browser/shared_worker/shared_worker_instance.cc
@@ -24,15 +24,8 @@ SharedWorkerInstance::SharedWorkerInstance(
DCHECK(resource_context_);
}
-SharedWorkerInstance::SharedWorkerInstance(const SharedWorkerInstance& other)
- : url_(other.url_),
- name_(other.name_),
- content_security_policy_(other.content_security_policy_),
- security_policy_type_(other.security_policy_type_),
- resource_context_(other.resource_context_),
- partition_(other.partition_) {}
-
-SharedWorkerInstance::~SharedWorkerInstance() {}
+SharedWorkerInstance::~SharedWorkerInstance() {
+}
bool SharedWorkerInstance::Matches(const GURL& match_url,
const base::string16& match_name,
@@ -57,9 +50,4 @@ bool SharedWorkerInstance::Matches(const GURL& match_url,
return name_ == match_name;
}
-bool SharedWorkerInstance::Matches(const SharedWorkerInstance& other) const {
- return Matches(
- other.url(), other.name(), other.partition(), other.resource_context());
-}
-
} // namespace content
diff --git a/content/browser/shared_worker/shared_worker_instance.h b/content/browser/shared_worker/shared_worker_instance.h
index 9d4e303..0d61316 100644
--- a/content/browser/shared_worker/shared_worker_instance.h
+++ b/content/browser/shared_worker/shared_worker_instance.h
@@ -16,8 +16,6 @@
namespace content {
class ResourceContext;
-// SharedWorkerInstance is copyable value-type data type. It could be passed to
-// the UI thread and be used for comparison in SharedWorkerDevToolsManager.
class CONTENT_EXPORT SharedWorkerInstance {
public:
SharedWorkerInstance(const GURL& url,
@@ -26,7 +24,6 @@ class CONTENT_EXPORT SharedWorkerInstance {
blink::WebContentSecurityPolicyType security_policy_type,
ResourceContext* resource_context,
const WorkerStoragePartition& partition);
- SharedWorkerInstance(const SharedWorkerInstance& other);
~SharedWorkerInstance();
// Checks if this SharedWorkerInstance matches the passed url/name params
@@ -40,7 +37,6 @@ class CONTENT_EXPORT SharedWorkerInstance {
const base::string16& name,
const WorkerStoragePartition& partition,
ResourceContext* resource_context) const;
- bool Matches(const SharedWorkerInstance& other) const;
// Accessors.
const GURL& url() const { return url_; }
diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc
index 0d0e0c65..1f81ca3 100644
--- a/content/browser/shared_worker/shared_worker_service_impl.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl.cc
@@ -9,7 +9,6 @@
#include <set>
#include <vector>
-#include "content/browser/devtools/shared_worker_devtools_manager.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/shared_worker/shared_worker_host.h"
#include "content/browser/shared_worker/shared_worker_instance.h"
@@ -62,29 +61,6 @@ void UpdateWorkerDependency(const std::vector<int>& added_ids,
base::Bind(&UpdateWorkerDependencyOnUI, added_ids, removed_ids));
}
-void WorkerCreatedResultCallbackOnIO(int worker_process_id,
- int worker_route_id,
- bool pause_on_start) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- SharedWorkerServiceImpl::GetInstance()->WorkerCreatedResultCallback(
- worker_process_id, worker_route_id, pause_on_start);
-}
-
-void NotifyWorkerCreatedOnUI(int worker_process_id,
- int worker_route_id,
- const SharedWorkerInstance& instance) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- bool pause_on_start =
- SharedWorkerDevToolsManager::GetInstance()->WorkerCreated(
- worker_process_id, worker_route_id, instance);
- BrowserThread::PostTask(BrowserThread::IO,
- FROM_HERE,
- base::Bind(&WorkerCreatedResultCallbackOnIO,
- worker_process_id,
- worker_route_id,
- pause_on_start));
-}
-
} // namespace
SharedWorkerServiceImpl* SharedWorkerServiceImpl::GetInstance() {
@@ -154,7 +130,7 @@ void SharedWorkerServiceImpl::CreateWorker(
ScopedWorkerDependencyChecker checker(this);
*url_mismatch = false;
SharedWorkerHost* existing_host = FindSharedWorkerHost(
- worker_hosts_, params.url, params.name, partition, resource_context);
+ params.url, params.name, partition, resource_context);
if (existing_host) {
if (params.url != existing_host->instance()->url()) {
*url_mismatch = true;
@@ -172,23 +148,6 @@ void SharedWorkerServiceImpl::CreateWorker(
filter->Send(new ViewMsg_WorkerCreated(route_id));
return;
}
- SharedWorkerHost* pending_host = FindSharedWorkerHost(pending_worker_hosts_,
- params.url,
- params.name,
- partition,
- resource_context);
- if (pending_host) {
- if (params.url != pending_host->instance()->url()) {
- *url_mismatch = true;
- return;
- }
- pending_host->AddFilter(filter, route_id);
- pending_host->worker_document_set()->Add(filter,
- params.document_id,
- filter->render_process_id(),
- params.render_frame_route_id);
- return;
- }
scoped_ptr<SharedWorkerInstance> instance(new SharedWorkerInstance(
params.url,
@@ -197,42 +156,25 @@ void SharedWorkerServiceImpl::CreateWorker(
params.security_policy_type,
resource_context,
partition));
- scoped_ptr<SharedWorkerHost> host(
- new SharedWorkerHost(instance.release(), filter));
+ scoped_ptr<SharedWorkerHost> host(new SharedWorkerHost(instance.release()));
host->AddFilter(filter, route_id);
host->worker_document_set()->Add(filter,
params.document_id,
filter->render_process_id(),
params.render_frame_route_id);
- const int worker_route_id = host->worker_route_id();
- // We need to call SharedWorkerDevToolsManager::WorkerCreated() on UI thread
- // to know whether the worker should be paused on start or not.
- // WorkerCreatedResultCallback() will be called with the result.
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(&NotifyWorkerCreatedOnUI,
- filter->render_process_id(),
- worker_route_id,
- *host->instance()));
- pending_worker_hosts_.set(
- std::make_pair(filter->render_process_id(), worker_route_id),
- host.Pass());
-}
-void SharedWorkerServiceImpl::WorkerCreatedResultCallback(int worker_process_id,
- int worker_route_id,
- bool pause_on_start) {
- scoped_ptr<SharedWorkerHost> host = pending_worker_hosts_.take_and_erase(
- std::make_pair(worker_process_id, worker_route_id));
- const GURL url = host->instance()->url();
- const base::string16 name = host->instance()->name();
- host->Start(pause_on_start);
- worker_hosts_.set(std::make_pair(worker_process_id, worker_route_id),
+ host->Init(filter);
+ const int worker_route_id = host->worker_route_id();
+ worker_hosts_.set(std::make_pair(filter->render_process_id(),
+ worker_route_id),
host.Pass());
+
FOR_EACH_OBSERVER(
- WorkerServiceObserver,
- observers_,
- WorkerCreated(url, name, worker_process_id, worker_route_id));
+ WorkerServiceObserver, observers_,
+ WorkerCreated(params.url,
+ params.name,
+ filter->render_process_id(),
+ worker_route_id));
}
void SharedWorkerServiceImpl::ForwardToWorker(
@@ -346,17 +288,8 @@ void SharedWorkerServiceImpl::OnSharedWorkerMessageFilterClosing(
if (iter->first.first == filter->render_process_id())
remove_list.push_back(iter->first);
}
- for (size_t i = 0; i < remove_list.size(); ++i) {
- scoped_ptr<SharedWorkerHost> host =
- worker_hosts_.take_and_erase(remove_list[i]);
- }
-}
-
-void SharedWorkerServiceImpl::NotifyWorkerDestroyed(int worker_process_id,
- int worker_route_id) {
- FOR_EACH_OBSERVER(WorkerServiceObserver,
- observers_,
- WorkerDestroyed(worker_process_id, worker_route_id));
+ for (size_t i = 0; i < remove_list.size(); ++i)
+ worker_hosts_.erase(remove_list[i]);
}
SharedWorkerHost* SharedWorkerServiceImpl::FindSharedWorkerHost(
@@ -366,14 +299,13 @@ SharedWorkerHost* SharedWorkerServiceImpl::FindSharedWorkerHost(
worker_route_id));
}
-// static
SharedWorkerHost* SharedWorkerServiceImpl::FindSharedWorkerHost(
- const WorkerHostMap& hosts,
const GURL& url,
const base::string16& name,
const WorkerStoragePartition& partition,
ResourceContext* resource_context) {
- for (WorkerHostMap::const_iterator iter = hosts.begin(); iter != hosts.end();
+ for (WorkerHostMap::const_iterator iter = worker_hosts_.begin();
+ iter != worker_hosts_.end();
++iter) {
SharedWorkerInstance* instance = iter->second->instance();
if (instance && !iter->second->closed() &&
diff --git a/content/browser/shared_worker/shared_worker_service_impl.h b/content/browser/shared_worker/shared_worker_service_impl.h
index 7abf452..7088785 100644
--- a/content/browser/shared_worker/shared_worker_service_impl.h
+++ b/content/browser/shared_worker/shared_worker_service_impl.h
@@ -92,21 +92,12 @@ class CONTENT_EXPORT SharedWorkerServiceImpl
// RenderProcessHostImpl on UI thread if necessary.
void CheckWorkerDependency();
- void WorkerCreatedResultCallback(int worker_process_id,
- int worker_route_id,
- bool pause_on_start);
- void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id);
-
private:
friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>;
friend class SharedWorkerServiceImplTest;
typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&,
const std::vector<int>&);
- // Pair of render_process_id and worker_route_id.
- typedef std::pair<int, int> ProcessRouteIdPair;
- typedef base::ScopedPtrHashMap<ProcessRouteIdPair, SharedWorkerHost>
- WorkerHostMap;
SharedWorkerServiceImpl();
virtual ~SharedWorkerServiceImpl();
@@ -117,8 +108,7 @@ class CONTENT_EXPORT SharedWorkerServiceImpl
SharedWorkerMessageFilter* filter,
int worker_route_id);
- static SharedWorkerHost* FindSharedWorkerHost(
- const WorkerHostMap& hosts,
+ SharedWorkerHost* FindSharedWorkerHost(
const GURL& url,
const base::string16& name,
const WorkerStoragePartition& worker_partition,
@@ -134,8 +124,11 @@ class CONTENT_EXPORT SharedWorkerServiceImpl
std::set<int> last_worker_depended_renderers_;
UpdateWorkerDependencyFunc update_worker_dependency_;
+ // Pair of render_process_id and worker_route_id.
+ typedef std::pair<int, int> ProcessRouteIdPair;
+ typedef base::ScopedPtrHashMap<ProcessRouteIdPair,
+ SharedWorkerHost> WorkerHostMap;
WorkerHostMap worker_hosts_;
- WorkerHostMap pending_worker_hosts_;
ObserverList<WorkerServiceObserver> observers_;
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 7c226d6..112b8e8 100644
--- a/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl_unittest.cc
@@ -20,7 +20,6 @@
#include "content/common/worker_messages.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "content/public/test/test_utils.h"
#include "ipc/ipc_sync_message.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -357,9 +356,6 @@ TEST_F(SharedWorkerServiceImplTest, BasicTest) {
// SharedWorkerConnector creates two message ports and sends
// ViewHostMsg_CreateWorker.
connector->Create("http://example.com/w.js", "name", 200, 300);
- // We need to go to UI thread to call
- // SharedWorkerDevToolsManager::WorkerCreated().
- RunAllPendingInMessageLoop();
EXPECT_EQ(2U, renderer_host->QueuedMessageCount());
// WorkerProcessMsg_CreateWorker should be sent to the renderer in which
// SharedWorker will be created.
@@ -445,9 +441,6 @@ TEST_F(SharedWorkerServiceImplTest, TwoRendererTest) {
// SharedWorkerConnector creates two message ports and sends
// ViewHostMsg_CreateWorker.
connector1->Create("http://example.com/w.js", "name", 200, 300);
- // We need to go to UI thread to call
- // SharedWorkerDevToolsManager::WorkerCreated().
- RunAllPendingInMessageLoop();
EXPECT_EQ(2U, renderer_host1->QueuedMessageCount());
// WorkerProcessMsg_CreateWorker should be sent to the renderer in which
// SharedWorker will be created.
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index efeaf69..6eab34b 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -412,8 +412,6 @@
'browser/devtools/render_view_devtools_agent_host.h',
'browser/devtools/renderer_overrides_handler.cc',
'browser/devtools/renderer_overrides_handler.h',
- 'browser/devtools/shared_worker_devtools_manager.cc',
- 'browser/devtools/shared_worker_devtools_manager.h',
'browser/devtools/tethering_handler.h',
'browser/devtools/tethering_handler.cc',
'browser/devtools/worker_devtools_manager.cc',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 9baa29f..37a5463 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -345,7 +345,6 @@
'browser/device_orientation/sensor_manager_android_unittest.cc',
'browser/devtools/devtools_http_handler_unittest.cc',
'browser/devtools/devtools_manager_unittest.cc',
- 'browser/devtools/shared_worker_devtools_manager_unittest.cc',
'browser/dom_storage/dom_storage_area_unittest.cc',
'browser/dom_storage/dom_storage_context_impl_unittest.cc',
'browser/dom_storage/dom_storage_database_unittest.cc',
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 3157515..3a94dcb 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1426,7 +1426,6 @@ void RenderThreadImpl::OnCreateNewSharedWorker(
params.name,
params.content_security_policy,
params.security_policy_type,
- params.pause_on_start,
params.route_id);
}
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
index 57cd279..aa34529 100644
--- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc
+++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
@@ -21,16 +21,13 @@ EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub(
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), name_(name), runing_(false), url_(url) {
+ : route_id_(route_id),
+ name_(name),
+ runing_(false),
+ url_(url) {
RenderThreadImpl::current()->AddSharedWorkerRoute(route_id_, this);
impl_ = blink::WebSharedWorker::create(this);
- 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_));
impl_->startWorkerContext(url, name_,
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.h b/content/renderer/shared_worker/embedded_shared_worker_stub.h
index 92943a6..226b89b 100644
--- a/content/renderer/shared_worker/embedded_shared_worker_stub.h
+++ b/content/renderer/shared_worker/embedded_shared_worker_stub.h
@@ -35,7 +35,6 @@ class EmbeddedSharedWorkerStub : public IPC::Listener,
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.