Commit c9541823 authored by horo@chromium.org's avatar horo@chromium.org

Call EmbeddedWorkerDevToolsManager::ServiceWorkerCreated, WorkerContextStarted and WorkerDestroyed.


BUG=358657

Review URL: https://codereview.chromium.org/261753008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271144 0039d316-1c4b-4281-b951-d872f2087c98
parent b67f29b8
......@@ -34,6 +34,25 @@ bool SendMessageToWorker(
} // namespace
EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
const ServiceWorkerContextCore* const service_worker_context,
int64 service_worker_version_id)
: service_worker_context_(service_worker_context),
service_worker_version_id_(service_worker_version_id) {
}
EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
const ServiceWorkerIdentifier& other)
: service_worker_context_(other.service_worker_context_),
service_worker_version_id_(other.service_worker_version_id_) {
}
bool EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::Matches(
const ServiceWorkerIdentifier& other) const {
return service_worker_context_ == other.service_worker_context_ &&
service_worker_version_id_ == other.service_worker_version_id_;
}
EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo(
const SharedWorkerInstance& instance)
: shared_worker_instance_(new SharedWorkerInstance(instance)),
......@@ -42,10 +61,8 @@ EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo(
}
EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo(
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope)
: storage_partition_path_(new base::FilePath(storage_partition_path)),
service_worker_scope_(new GURL(service_worker_scope)),
const ServiceWorkerIdentifier& service_worker_id)
: service_worker_id_(new ServiceWorkerIdentifier(service_worker_id)),
state_(WORKER_UNINSPECTED),
agent_host_(NULL) {
}
......@@ -58,12 +75,10 @@ bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches(
}
bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches(
const base::FilePath& other_storage_partition_path,
const GURL& other_service_worker_scope) {
if (!storage_partition_path_ || !service_worker_scope_)
const ServiceWorkerIdentifier& other) {
if (!service_worker_id_)
return false;
return *storage_partition_path_ == other_storage_partition_path &&
*service_worker_scope_ == other_service_worker_scope;
return service_worker_id_->Matches(other);
}
EmbeddedWorkerDevToolsManager::WorkerInfo::~WorkerInfo() {
......@@ -175,10 +190,8 @@ DevToolsAgentHost* EmbeddedWorkerDevToolsManager::GetDevToolsAgentHostForWorker(
DevToolsAgentHost*
EmbeddedWorkerDevToolsManager::GetDevToolsAgentHostForServiceWorker(
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope) {
WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(
storage_partition_path, service_worker_scope);
const ServiceWorkerIdentifier& service_worker_id) {
WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(service_worker_id);
if (it == workers_.end())
return NULL;
return GetDevToolsAgentHostForWorker(it->first.first, it->first.second);
......@@ -209,15 +222,12 @@ bool EmbeddedWorkerDevToolsManager::SharedWorkerCreated(
bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated(
int worker_process_id,
int worker_route_id,
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope) {
const ServiceWorkerIdentifier& service_worker_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const WorkerId id(worker_process_id, worker_route_id);
WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(
storage_partition_path, service_worker_scope);
WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(service_worker_id);
if (it == workers_.end()) {
scoped_ptr<WorkerInfo> info(
new WorkerInfo(storage_partition_path, service_worker_scope));
scoped_ptr<WorkerInfo> info(new WorkerInfo(service_worker_id));
workers_.set(id, info.Pass());
return false;
}
......@@ -316,11 +326,10 @@ EmbeddedWorkerDevToolsManager::FindExistingSharedWorkerInfo(
EmbeddedWorkerDevToolsManager::WorkerInfoMap::iterator
EmbeddedWorkerDevToolsManager::FindExistingServiceWorkerInfo(
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope) {
const ServiceWorkerIdentifier& service_worker_id) {
WorkerInfoMap::iterator it = workers_.begin();
for (; it != workers_.end(); ++it) {
if (it->second->Matches(storage_partition_path, service_worker_scope))
if (it->second->Matches(service_worker_id))
break;
}
return it;
......
......@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
......@@ -15,10 +14,10 @@
#include "content/browser/shared_worker/shared_worker_instance.h"
#include "content/common/content_export.h"
class GURL;
namespace content {
class DevToolsAgentHost;
class ServiceWorkerContextCore;
// EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when
// "enable-embedded-shared-worker" flag is set.
......@@ -28,27 +27,37 @@ class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
typedef std::pair<int, int> WorkerId;
class EmbeddedWorkerDevToolsAgentHost;
class ServiceWorkerIdentifier {
public:
ServiceWorkerIdentifier(
const ServiceWorkerContextCore* const service_worker_context,
int64 service_worker_version_id);
explicit ServiceWorkerIdentifier(const ServiceWorkerIdentifier& other);
~ServiceWorkerIdentifier() {}
bool Matches(const ServiceWorkerIdentifier& other) const;
private:
const ServiceWorkerContextCore* const service_worker_context_;
const int64 service_worker_version_id_;
};
// Returns the EmbeddedWorkerDevToolsManager singleton.
static EmbeddedWorkerDevToolsManager* GetInstance();
DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
int worker_route_id);
DevToolsAgentHost* GetDevToolsAgentHostForServiceWorker(
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope);
const ServiceWorkerIdentifier& service_worker_id);
// Returns true when the worker must be paused on start.
bool SharedWorkerCreated(int worker_process_id,
int worker_route_id,
const SharedWorkerInstance& instance);
// Returns true when the worker must be paused on start.
// TODO(horo): Currently we identify ServiceWorkers with the path of storage
// partition and the scope of ServiceWorker. Consider having a class like
// SharedWorkerInstance instead of the pair.
bool ServiceWorkerCreated(int worker_process_id,
int worker_route_id,
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope);
const ServiceWorkerIdentifier& service_worker_id);
void WorkerContextStarted(int worker_process_id, int worker_route_id);
void WorkerDestroyed(int worker_process_id, int worker_route_id);
......@@ -70,8 +79,7 @@ class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
// Creates WorkerInfo for SharedWorker.
explicit WorkerInfo(const SharedWorkerInstance& instance);
// Creates WorkerInfo for ServiceWorker.
WorkerInfo(const base::FilePath& storage_partition_path,
const GURL& service_worker_scope);
explicit WorkerInfo(const ServiceWorkerIdentifier& service_worker_id);
~WorkerInfo();
WorkerState state() { return state_; }
......@@ -81,13 +89,11 @@ class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
agent_host_ = agent_host;
}
bool Matches(const SharedWorkerInstance& other);
bool Matches(const base::FilePath& other_storage_partition_path,
const GURL& other_service_worker_scope);
bool Matches(const ServiceWorkerIdentifier& other);
private:
scoped_ptr<SharedWorkerInstance> shared_worker_instance_;
scoped_ptr<base::FilePath> storage_partition_path_;
scoped_ptr<GURL> service_worker_scope_;
scoped_ptr<ServiceWorkerIdentifier> service_worker_id_;
WorkerState state_;
EmbeddedWorkerDevToolsAgentHost* agent_host_;
};
......@@ -102,8 +108,7 @@ class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
WorkerInfoMap::iterator FindExistingSharedWorkerInfo(
const SharedWorkerInstance& instance);
WorkerInfoMap::iterator FindExistingServiceWorkerInfo(
const base::FilePath& storage_partition_path,
const GURL& service_worker_scope);
const ServiceWorkerIdentifier& service_worker_id);
void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it);
......
......@@ -4,14 +4,20 @@
#include "content/browser/service_worker/embedded_worker_instance.h"
#include "base/bind_helpers.h"
#include "content/browser/devtools/embedded_worker_devtools_manager.h"
#include "content/browser/service_worker/embedded_worker_registry.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_message.h"
#include "url/gurl.h"
namespace content {
namespace {
// Functor to sort by the .second element of a struct.
struct SecondGreater {
template <typename Value>
......@@ -19,11 +25,75 @@ struct SecondGreater {
return lhs.second > rhs.second;
}
};
void NotifyWorkerContextStarted(int worker_process_id, int worker_route_id) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(
NotifyWorkerContextStarted, worker_process_id, worker_route_id));
return;
}
EmbeddedWorkerDevToolsManager::GetInstance()->WorkerContextStarted(
worker_process_id, worker_route_id);
}
void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id));
return;
}
EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed(
worker_process_id, worker_route_id);
}
void RegisterToWorkerDevToolsManager(
int process_id,
const ServiceWorkerContextCore* const service_worker_context,
int64 service_worker_version_id,
const base::Callback<void(int worker_devtools_agent_route_id,
bool pause_on_start)>& callback) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(RegisterToWorkerDevToolsManager,
process_id,
service_worker_context,
service_worker_version_id,
callback));
return;
}
int worker_devtools_agent_route_id = MSG_ROUTING_NONE;
bool pause_on_start = false;
if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) {
// |rph| may be NULL in unit tests.
worker_devtools_agent_route_id = rph->GetNextRoutingID();
pause_on_start =
EmbeddedWorkerDevToolsManager::GetInstance()->ServiceWorkerCreated(
process_id,
worker_devtools_agent_route_id,
EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier(
service_worker_context, service_worker_version_id));
}
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(callback, worker_devtools_agent_route_id, pause_on_start));
}
} // namespace
EmbeddedWorkerInstance::~EmbeddedWorkerInstance() {
if (status_ == STARTING || status_ == RUNNING)
Stop();
if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE)
NotifyWorkerDestroyed(process_id_, worker_devtools_agent_route_id_);
if (context_ && process_id_ != -1)
context_->process_manager()->ReleaseWorkerProcess(process_id_);
registry_->RemoveWorker(process_id_, embedded_worker_id_);
}
......@@ -32,15 +102,28 @@ void EmbeddedWorkerInstance::Start(int64 service_worker_version_id,
const GURL& script_url,
const std::vector<int>& possible_process_ids,
const StatusCallback& callback) {
if (!context_) {
callback.Run(SERVICE_WORKER_ERROR_ABORT);
return;
}
DCHECK(status_ == STOPPED);
status_ = STARTING;
std::vector<int> ordered_process_ids = SortProcesses(possible_process_ids);
registry_->StartWorker(ordered_process_ids,
embedded_worker_id_,
service_worker_version_id,
scope,
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params(
new EmbeddedWorkerMsg_StartWorker_Params());
params->embedded_worker_id = embedded_worker_id_;
params->service_worker_version_id = service_worker_version_id;
params->scope = scope;
params->script_url = script_url;
params->worker_devtools_agent_route_id = MSG_ROUTING_NONE;
params->pause_on_start = false;
context_->process_manager()->AllocateWorkerProcess(
SortProcesses(possible_process_ids),
script_url,
callback);
base::Bind(&EmbeddedWorkerInstance::RunProcessAllocated,
weak_factory_.GetWeakPtr(),
context_,
base::Passed(&params),
callback));
}
ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() {
......@@ -77,32 +160,76 @@ void EmbeddedWorkerInstance::ReleaseProcessReference(int process_id) {
process_refs_.erase(found);
}
EmbeddedWorkerInstance::EmbeddedWorkerInstance(EmbeddedWorkerRegistry* registry,
EmbeddedWorkerInstance::EmbeddedWorkerInstance(
base::WeakPtr<ServiceWorkerContextCore> context,
int embedded_worker_id)
: registry_(registry),
: context_(context),
registry_(context->embedded_worker_registry()),
embedded_worker_id_(embedded_worker_id),
status_(STOPPED),
process_id_(-1),
thread_id_(-1),
worker_devtools_agent_route_id_(MSG_ROUTING_NONE) {
worker_devtools_agent_route_id_(MSG_ROUTING_NONE),
weak_factory_(this) {
}
void EmbeddedWorkerInstance::RecordProcessId(
int process_id,
// static
void EmbeddedWorkerInstance::RunProcessAllocated(
base::WeakPtr<EmbeddedWorkerInstance> instance,
base::WeakPtr<ServiceWorkerContextCore> context,
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const EmbeddedWorkerInstance::StatusCallback& callback,
ServiceWorkerStatusCode status,
int worker_devtools_agent_route_id) {
int process_id) {
if (!context) {
callback.Run(SERVICE_WORKER_ERROR_ABORT);
return;
}
if (!instance) {
context->process_manager()->ReleaseWorkerProcess(process_id);
callback.Run(SERVICE_WORKER_ERROR_ABORT);
return;
}
instance->ProcessAllocated(params.Pass(), callback, process_id, status);
}
void EmbeddedWorkerInstance::ProcessAllocated(
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
int process_id,
ServiceWorkerStatusCode status) {
DCHECK_EQ(process_id_, -1);
DCHECK_EQ(worker_devtools_agent_route_id_, MSG_ROUTING_NONE);
if (status == SERVICE_WORKER_OK) {
process_id_ = process_id;
worker_devtools_agent_route_id_ = worker_devtools_agent_route_id;
} else {
if (status != SERVICE_WORKER_OK) {
status_ = STOPPED;
callback.Run(status);
return;
}
const int64 service_worker_version_id = params->service_worker_version_id;
process_id_ = process_id;
RegisterToWorkerDevToolsManager(
process_id,
context_.get(),
service_worker_version_id,
base::Bind(&EmbeddedWorkerInstance::SendStartWorker,
weak_factory_.GetWeakPtr(),
base::Passed(&params),
callback));
}
void EmbeddedWorkerInstance::SendStartWorker(
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
int worker_devtools_agent_route_id,
bool pause_on_start) {
worker_devtools_agent_route_id_ = worker_devtools_agent_route_id;
params->worker_devtools_agent_route_id = worker_devtools_agent_route_id;
params->pause_on_start = pause_on_start;
registry_->SendStartWorker(params.Pass(), callback, process_id_);
}
void EmbeddedWorkerInstance::OnScriptLoaded() {
// TODO(horo): Implement this.
if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE)
NotifyWorkerContextStarted(process_id_, worker_devtools_agent_route_id_);
}
void EmbeddedWorkerInstance::OnScriptLoadFailed() {
......@@ -119,6 +246,10 @@ void EmbeddedWorkerInstance::OnStarted(int thread_id) {
}
void EmbeddedWorkerInstance::OnStopped() {
if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE)
NotifyWorkerDestroyed(process_id_, worker_devtools_agent_route_id_);
if (context_)
context_->process_manager()->ReleaseWorkerProcess(process_id_);
status_ = STOPPED;
process_id_ = -1;
thread_id_ = -1;
......
......@@ -13,12 +13,14 @@
#include "base/gtest_prod_util.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "content/common/content_export.h"
#include "content/common/service_worker/service_worker_status_code.h"
#include "url/gurl.h"
class GURL;
struct EmbeddedWorkerMsg_StartWorker_Params;
namespace IPC {
class Message;
......@@ -27,6 +29,7 @@ class Message;
namespace content {
class EmbeddedWorkerRegistry;
class ServiceWorkerContextCore;
struct ServiceWorkerFetchRequest;
// This gives an interface to control one EmbeddedWorker instance, which
......@@ -94,9 +97,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
Status status() const { return status_; }
int process_id() const { return process_id_; }
int thread_id() const { return thread_id_; }
int worker_devtools_agent_route_id() const {
return worker_devtools_agent_route_id_;
}
void AddListener(Listener* listener);
void RemoveListener(Listener* listener);
......@@ -111,14 +111,28 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
// Constructor is called via EmbeddedWorkerRegistry::CreateWorker().
// This instance holds a ref of |registry|.
EmbeddedWorkerInstance(EmbeddedWorkerRegistry* registry,
EmbeddedWorkerInstance(base::WeakPtr<ServiceWorkerContextCore> context,
int embedded_worker_id);
// Called back from EmbeddedWorkerRegistry after Start() passes control to the
// UI thread to acquire a reference to the process.
void RecordProcessId(int process_id,
// Called back from ServiceWorkerProcessManager after Start() passes control
// to the UI thread to acquire a reference to the process.
static void RunProcessAllocated(
base::WeakPtr<EmbeddedWorkerInstance> instance,
base::WeakPtr<ServiceWorkerContextCore> context,
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const EmbeddedWorkerInstance::StatusCallback& callback,
ServiceWorkerStatusCode status,
int worker_devtools_agent_route_id);
int process_id);
void ProcessAllocated(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
int process_id,
ServiceWorkerStatusCode status);
// Called back after ProcessAllocated() passes control to the UI thread to
// register to WorkerDevToolsManager.
void SendStartWorker(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
int worker_devtools_agent_route_id,
bool pause_on_start);
// Called back from Registry when the worker instance has ack'ed that
// it finished loading the script.
......@@ -163,6 +177,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
std::vector<int> SortProcesses(
const std::vector<int>& possible_process_ids) const;
base::WeakPtr<ServiceWorkerContextCore> context_;
scoped_refptr<EmbeddedWorkerRegistry> registry_;
const int embedded_worker_id_;
Status status_;
......@@ -175,6 +190,8 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
ProcessRefMap process_refs_;
ListenerList listener_list_;
base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
};
......
......@@ -19,47 +19,18 @@ namespace content {
EmbeddedWorkerRegistry::EmbeddedWorkerRegistry(
base::WeakPtr<ServiceWorkerContextCore> context)
: context_(context),
next_embedded_worker_id_(0) {}
: context_(context), next_embedded_worker_id_(0) {
}
scoped_ptr<EmbeddedWorkerInstance> EmbeddedWorkerRegistry::CreateWorker() {
scoped_ptr<EmbeddedWorkerInstance> worker(
new EmbeddedWorkerInstance(this, next_embedded_worker_id_));
new EmbeddedWorkerInstance(context_, next_embedded_worker_id_));
worker_map_[next_embedded_worker_id_++] = worker.get();
return worker.Pass();
}
void EmbeddedWorkerRegistry::StartWorker(const std::vector<int>& process_ids,
int embedded_worker_id,
int64 service_worker_version_id,
const GURL& scope,
const GURL& script_url,
const StatusCallback& callback) {
if (!context_) {
callback.Run(SERVICE_WORKER_ERROR_ABORT);
return;
}
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params(
new EmbeddedWorkerMsg_StartWorker_Params());
params->embedded_worker_id = embedded_worker_id;
params->service_worker_version_id = service_worker_version_id;
params->scope = scope;
params->script_url = script_url;
params->worker_devtools_agent_route_id = MSG_ROUTING_NONE;
context_->process_manager()->AllocateWorkerProcess(
process_ids,
script_url,
base::Bind(&EmbeddedWorkerRegistry::StartWorkerWithProcessId,
this,
embedded_worker_id,
base::Passed(&params),
callback));
}
ServiceWorkerStatusCode EmbeddedWorkerRegistry::StopWorker(
int process_id, int embedded_worker_id) {
if (context_)
context_->process_manager()->ReleaseWorkerProcess(process_id);
return Send(process_id,
new EmbeddedWorkerMsg_StopWorker(embedded_worker_id));
}
......@@ -210,37 +181,10 @@ EmbeddedWorkerRegistry::~EmbeddedWorkerRegistry() {
Shutdown();
}
void EmbeddedWorkerRegistry::StartWorkerWithProcessId(
int embedded_worker_id,
void EmbeddedWorkerRegistry::SendStartWorker(
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
ServiceWorkerStatusCode status,
int process_id) {
WorkerInstanceMap::const_iterator worker =
worker_map_.find(embedded_worker_id);
if (worker == worker_map_.end()) {
// The Instance was destroyed before it could finish starting. Undo what
// we've done so far.
if (context_)
context_->process_manager()->ReleaseWorkerProcess(process_id);
callback.Run(SERVICE_WORKER_ERROR_ABORT);
return;
}
if (status == SERVICE_WORKER_OK) {
// Gets the new routing id for the renderer process.
scoped_refptr<RenderWidgetHelper> helper(
RenderWidgetHelper::FromProcessHostID(process_id));
// |helper| may be NULL in unittest.
params->worker_devtools_agent_route_id =
helper ? helper->GetNextRoutingID() : MSG_ROUTING_NONE;
}
worker->second->RecordProcessId(
process_id, status, params->worker_devtools_agent_route_id);
if (status != SERVICE_WORKER_OK) {
callback.Run(status);
return;
}
// The ServiceWorkerDispatcherHost is supposed to be created when the process
// is created, and keep an entry in process_sender_map_ for its whole
// lifetime.
......
......@@ -50,12 +50,9 @@ class CONTENT_EXPORT EmbeddedWorkerRegistry
scoped_ptr<EmbeddedWorkerInstance> CreateWorker();
// Called from EmbeddedWorkerInstance, relayed to the child process.
void StartWorker(const std::vector<int>& process_ids,
int embedded_worker_id,
int64 service_worker_version_id,
const GURL& scope,
const GURL& script_url,
const StatusCallback& callback);
void SendStartWorker(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
int process_id);
ServiceWorkerStatusCode StopWorker(int process_id,
int embedded_worker_id);
......@@ -96,13 +93,6 @@ class CONTENT_EXPORT EmbeddedWorkerRegistry
~EmbeddedWorkerRegistry();
void StartWorkerWithProcessId(
int embedded_worker_id,
scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
const StatusCallback& callback,
ServiceWorkerStatusCode status,
int process_id);
ServiceWorkerStatusCode Send(int process_id, IPC::Message* message);
// RemoveWorker is called when EmbeddedWorkerInstance is destructed.
......
......@@ -23,6 +23,7 @@ IPC_STRUCT_BEGIN(EmbeddedWorkerMsg_StartWorker_Params)
IPC_STRUCT_MEMBER(GURL, scope)
IPC_STRUCT_MEMBER(GURL, script_url)
IPC_STRUCT_MEMBER(int, worker_devtools_agent_route_id)
IPC_STRUCT_MEMBER(bool, pause_on_start)
IPC_STRUCT_END()
// Parameters structure for EmbeddedWorkerHostMsg_ReportConsoleMessage.
......
......@@ -82,7 +82,9 @@ void EmbeddedWorkerDispatcher::OnStartWorker(
blink::WebEmbeddedWorkerStartData start_data;
start_data.scriptURL = params.script_url;
start_data.userAgent = base::UTF8ToUTF16(GetContentClient()->GetUserAgent());
start_data.startMode = blink::WebEmbeddedWorkerStartModeDontPauseOnStart;
start_data.startMode =
params.pause_on_start ? blink::WebEmbeddedWorkerStartModePauseOnStart
: blink::WebEmbeddedWorkerStartModeDontPauseOnStart;
wrapper->worker()->startWorkerContext(start_data);
workers_.AddWithID(wrapper.release(), params.embedded_worker_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment