Chromium Code Reviews| 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..2a269c860a5fcdb10925a70ef9736e62d1878b5d 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,36 @@ 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. |
| + // All these implementation functions run on browser IO thread. |
|
falken
2017/04/12 14:30:18
These functions all run on the IO thread.
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + // This will only notify DevToolsManager about this. |
|
falken
2017/04/12 14:30:18
OK to remove this.
I'm less enthusiastic about th
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + void OnReadyForInspection() override; |
| + // This will set the internal starting phase status to SCRIPT_LOADED. |
|
falken
2017/04/12 14:30:18
I think we can remove this. The starting phase sta
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + void OnScriptLoaded() override; |
| + // This will notify the provider host corresponding with |provider_id| that |
| + // the worker has started a new worker thread |thread_id| in renderer process |
| + // and is ready to receive messages now, then set the internal starting phase |
| + // status to THREAD_STARTED. |
|
falken
2017/04/12 14:30:18
To tighten it up, "Notifies the corresponding prov
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + void OnThreadStarted(int thread_id, int provider_id) override; |
| + void OnScriptLoadFailed() override; |
| + // This will set the internal starting phase status to SCRIPT_EVALUATED and |
| + // fire the callback received by Start(). |
|
falken
2017/04/12 14:30:18
+1 to mentioning this fires the callback. I'd remo
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + void OnScriptEvaluated(bool success) override; |
| + // This will change the internal worker status from STARTING to RUNNING. |
| + void OnStarted() override; |
| + // This will reset the embedded worker instance to initial state, such as |
| + // changing the internal worker status from STARTING or RUNNING to STOPPED |
| + // etc. |
|
falken
2017/04/12 14:30:18
"Resets the embedded worker instance to the initia
leonhsl(Using Gerrit)
2017/04/13 03:10:48
Done.
|
| + 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 +261,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 +291,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_; |