Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1922)

Unified Diff: content/renderer/service_worker/embedded_worker_instance_client_impl.h

Issue 2307543002: ServiceWorker: Mojofication of EWInstance::StopWorker (Closed)
Patch Set: Added a check of the status when detached Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/service_worker/embedded_worker_instance_client_impl.h
diff --git a/content/renderer/service_worker/embedded_worker_instance_client_impl.h b/content/renderer/service_worker/embedded_worker_instance_client_impl.h
index 893ae1d14087a6247435967ea978a986017868dc..bb0c777560c9bded22ecf67a65d02d0df127031e 100644
--- a/content/renderer/service_worker/embedded_worker_instance_client_impl.h
+++ b/content/renderer/service_worker/embedded_worker_instance_client_impl.h
@@ -6,11 +6,15 @@
#define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_H_
#include "base/id_map.h"
+#include "base/optional.h"
#include "content/common/service_worker/embedded_worker.mojom.h"
#include "content/renderer/service_worker/embedded_worker_dispatcher.h"
+#include "mojo/public/cpp/bindings/binding.h"
namespace content {
+// This class exposes interfaces of WebEmbeddedWorker to the browser process.
+// All methods should be called on the main thread.
class EmbeddedWorkerInstanceClientImpl
: public mojom::EmbeddedWorkerInstanceClient {
public:
@@ -18,18 +22,37 @@ class EmbeddedWorkerInstanceClientImpl
EmbeddedWorkerDispatcher* dispatcher,
mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request);
- explicit EmbeddedWorkerInstanceClientImpl(
- EmbeddedWorkerDispatcher* dispatcher);
~EmbeddedWorkerInstanceClientImpl() override;
- // Implementation of mojo interface
- void StartWorker(const EmbeddedWorkerStartParams& params) override;
+ // Called from ServiceWorkerContextClient. Must call on the main thread.
+ void StopWorkerCompleted();
private:
+ EmbeddedWorkerInstanceClientImpl(
+ EmbeddedWorkerDispatcher* dispatcher,
+ mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request);
+
+ // mojom::EmbeddedWorkerInstanceClient implementation
+ void StartWorker(const EmbeddedWorkerStartParams& params) override;
+ void StopWorker(const StopWorkerCallback& callback) override;
+
+ // Handler of connection error bound to |binding_|
+ void OnError();
+
EmbeddedWorkerDispatcher* dispatcher_;
+ // This object will be bound to the main thread.
+ mojo::Binding<mojom::EmbeddedWorkerInstanceClient> binding_;
+ // This is valid before StartWorker is called. After that, this object
+ // will be passed to ServiceWorkerContextClient.
+ std::unique_ptr<EmbeddedWorkerInstanceClientImpl> temporal_self_;
+
+ base::Optional<int> embedded_worker_id_;
EmbeddedWorkerDispatcher::WorkerWrapper* wrapper_;
+ // Stores callbacks
+ StopWorkerCallback stop_callback_;
+
DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceClientImpl);
};

Powered by Google App Engine
This is Rietveld 408576698