Index: content/browser/service_worker/embedded_worker_instance.h |
diff --git a/content/browser/service_worker/embedded_worker_instance.h b/content/browser/service_worker/embedded_worker_instance.h |
index f9d382c27748f208785ccf7bbe00f62f1f5ed4c5..3226fbfb26faa4f9b410a38cff87c33391182b36 100644 |
--- a/content/browser/service_worker/embedded_worker_instance.h |
+++ b/content/browser/service_worker/embedded_worker_instance.h |
@@ -17,8 +17,9 @@ |
#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,12 +28,14 @@ class Message; |
namespace content { |
class EmbeddedWorkerRegistry; |
+class ServiceWorkerContextCore; |
struct ServiceWorkerFetchRequest; |
// This gives an interface to control one EmbeddedWorker instance, which |
// may be 'in-waiting' or running in one of the child processes added by |
// AddProcessReference(). |
-class CONTENT_EXPORT EmbeddedWorkerInstance { |
+class CONTENT_EXPORT EmbeddedWorkerInstance |
+ : NON_EXPORTED_BASE(public base::SupportsWeakPtr<EmbeddedWorkerInstance>) { |
public: |
typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; |
enum Status { |
@@ -69,7 +72,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
// if necessary and the IPC to evaluate the worker's script is sent. |
// Observer::OnStarted() is run when the worker is actually started. |
void Start(int64 service_worker_version_id, |
- const GURL& scope, |
const GURL& script_url, |
const std::vector<int>& possible_process_ids, |
const StatusCallback& callback); |
@@ -94,9 +96,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 +110,33 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
// Constructor is called via EmbeddedWorkerRegistry::CreateWorker(). |
// This instance holds a ref of |registry|. |
- EmbeddedWorkerInstance(EmbeddedWorkerRegistry* registry, |
- 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, |
- ServiceWorkerStatusCode status, |
- int worker_devtools_agent_route_id); |
+ EmbeddedWorkerInstance(base::WeakPtr<ServiceWorkerContextCore> context, |
+ int embedded_worker_id, |
+ const GURL& scope); |
+ |
+ // 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 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. |
+ static void RunSendStartWorker( |
+ base::WeakPtr<EmbeddedWorkerInstance> instance, |
+ scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, |
+ const EmbeddedWorkerInstance::StatusCallback& callback, |
+ int worker_devtools_agent_route_id, |
+ bool pause_on_start); |
+ void SendStartWorker(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, |
+ const StatusCallback& callback); |
// Called back from Registry when the worker instance has ack'ed that |
// it finished loading the script. |
@@ -163,8 +181,10 @@ 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_; |
+ const GURL scope_; |
Status status_; |
// Current running information. -1 indicates the worker is not running. |