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 ca5d522cd3500b0e1719f730a61c9c5a1667bc83..71ed5e6cd48d1c59f239c73b603756d82d509274 100644 |
--- a/content/browser/service_worker/embedded_worker_instance.h |
+++ b/content/browser/service_worker/embedded_worker_instance.h |
@@ -26,6 +26,7 @@ |
#include "content/common/service_worker/embedded_worker.mojom.h" |
#include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
#include "content/common/service_worker/service_worker_status_code.h" |
+#include "mojo/public/cpp/bindings/associated_binding.h" |
#include "url/gurl.h" |
// Windows headers will redefine SendMessage. |
@@ -46,7 +47,8 @@ class ServiceWorkerContextCore; |
// 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 mojom::EmbeddedWorkerInstanceHost) { |
public: |
typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; |
@@ -99,7 +101,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
CONTENT_EXPORT virtual bool OnMessageReceived(const IPC::Message& message); |
}; |
- ~EmbeddedWorkerInstance(); |
+ ~EmbeddedWorkerInstance() override; |
// Starts the worker. It is invalid to call this when the worker is not in |
// STOPPED status. |callback| is invoked after the worker script has been |
@@ -219,37 +221,30 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
// Called back from StartTask after a start worker message is sent. |
void OnStartWorkerMessageSent(); |
- // Called back from Registry when the worker instance has ack'ed that |
- // it is ready for inspection. |
- void OnReadyForInspection(); |
- |
- // Called back from Registry when the worker instance has ack'ed that |
- // it finished loading the script. |
- void OnScriptLoaded(); |
- |
- // Called back from Registry when the worker instance has ack'ed that |
- // it has started a worker thread. |
- void OnThreadStarted(int thread_id); |
- |
- // Called back from Registry when the worker instance has ack'ed that |
- // it failed to load the script. |
- void OnScriptLoadFailed(); |
- |
- // Called back from Registry when the worker instance has ack'ed that |
- // it finished evaluating the script. This is called before OnStarted. |
- void OnScriptEvaluated(bool success); |
- |
- // Called back from Registry when the worker instance has ack'ed that its |
- // WorkerGlobalScope has actually started and evaluated the script. This is |
- // called after OnScriptEvaluated. |
- // This will change the internal status from STARTING to RUNNING. |
- void OnStarted(); |
- |
- // Called back from Registry when the worker instance has ack'ed that |
- // its WorkerGlobalScope is actually stopped in the child process. |
- // This will change the internal status from STARTING or RUNNING to |
- // STOPPED. |
- void OnStopped(); |
+ // Implements mojom::EmbeddedWorkerInstanceHost. |
+ // These functions all run on the IO thread. |
+ void OnReadyForInspection() override; |
+ void OnScriptLoaded() override; |
+ // Notifies the corresponding provider host that the thread has started and is |
+ // ready to receive messages. |
+ void OnThreadStarted(int thread_id, int provider_id) override; |
+ void OnScriptLoadFailed() override; |
+ // Fires the callback passed to Start(). |
+ void OnScriptEvaluated(bool success) override; |
+ // Changes the internal worker status from STARTING to RUNNING. |
+ void OnStarted() override; |
+ // Resets the embedded worker instance to the initial state. This will change |
+ // the internal status from STARTING or RUNNING to STOPPED. |
+ void OnStopped() override; |
+ void OnReportException(const base::string16& error_message, |
+ int line_number, |
+ int column_number, |
+ const GURL& source_url) override; |
+ void OnReportConsoleMessage(int source_identifier, |
+ int message_level, |
+ const base::string16& message, |
+ int line_number, |
+ const GURL& source_url) override; |
// Called when ServiceWorkerDispatcherHost for the worker died while it was |
// running. |
@@ -260,19 +255,6 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
// Returns false if the message is not handled. |
bool OnMessageReceived(const IPC::Message& message); |
- // Called back from Registry when the worker instance reports the exception. |
- void OnReportException(const base::string16& error_message, |
- int line_number, |
- int column_number, |
- const GURL& source_url); |
- |
- // Called back from Registry when the worker instance reports to the console. |
- void OnReportConsoleMessage(int source_identifier, |
- int message_level, |
- const base::string16& message, |
- int line_number, |
- const GURL& source_url); |
- |
// Resets all running state. After this function is called, |status_| is |
// STOPPED. |
void ReleaseProcess(); |
@@ -303,6 +285,9 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { |
// |client_| is used to send messages to the renderer process. |
mojom::EmbeddedWorkerInstanceClientPtr client_; |
+ // Binding for EmbeddedWorkerInstanceHost, runs on IO thread. |
+ mojo::AssociatedBinding<EmbeddedWorkerInstanceHost> instance_host_binding_; |
+ |
// TODO(shimazu): Remove this after EmbeddedWorkerStartParams is changed to |
// a mojo struct. |
mojom::ServiceWorkerEventDispatcherRequest pending_dispatcher_request_; |