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

Side by Side Diff: content/renderer/service_worker/embedded_worker_instance_client_impl.h

Issue 2307543002: ServiceWorker: Mojofication of EWInstance::StopWorker (Closed)
Patch Set: Incorporated with the review Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_H_ 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_H_
6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_H_ 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_H_
7 7
8 #include "base/id_map.h" 8 #include "base/id_map.h"
9 #include "base/optional.h"
9 #include "content/common/service_worker/embedded_worker.mojom.h" 10 #include "content/common/service_worker/embedded_worker.mojom.h"
10 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" 11 #include "content/renderer/service_worker/embedded_worker_dispatcher.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 class EmbeddedWorkerInstanceClientImpl 16 class EmbeddedWorkerInstanceClientImpl
16 : public mojom::EmbeddedWorkerInstanceClient { 17 : public mojom::EmbeddedWorkerInstanceClient {
17 public: 18 public:
18 static void Create( 19 static void Create(
19 EmbeddedWorkerDispatcher* dispatcher, 20 EmbeddedWorkerDispatcher* dispatcher,
20 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request); 21 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request);
21 22
22 // Implementation of mojo interface
23 void StartWorker(const EmbeddedWorkerStartParams& params) override;
24
25 private:
26 EmbeddedWorkerInstanceClientImpl( 23 EmbeddedWorkerInstanceClientImpl(
27 EmbeddedWorkerDispatcher* dispatcher, 24 EmbeddedWorkerDispatcher* dispatcher,
28 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request); 25 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request);
29 ~EmbeddedWorkerInstanceClientImpl() override; 26 ~EmbeddedWorkerInstanceClientImpl() override;
30 27
28 // Called from ServiceWorkerContextClient. Must call on the main thread.
29 void StopWorkerCompleted();
30
31 private:
32 // Implementation of mojo interface
dcheng 2016/09/30 08:25:28 Nit: This is usually worded as: // mojom::Embedded
shimazu 2016/10/06 03:50:51 Done.
33 void StartWorker(const EmbeddedWorkerStartParams& params) override;
34 void StopWorker(const StopWorkerCallback& callback) override;
35
36 // Handler of connection error bound to |binding_|
31 void OnError(); 37 void OnError();
32 38
33 EmbeddedWorkerDispatcher* dispatcher_; 39 EmbeddedWorkerDispatcher* dispatcher_;
34 mojo::StrongBinding<mojom::EmbeddedWorkerInstanceClient> binding_; 40 // This object will be bound to the main thread.
41 mojo::Binding<mojom::EmbeddedWorkerInstanceClient> binding_;
35 42
43 // This is valid before StartWorker is called. After that, this object
44 // will be passed to ServiceWorkerContextClient.
45 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> temporal_self_;
dcheng 2016/09/30 08:25:28 This is a bit too clever. Let me try to think if t
shimazu 2016/10/06 03:50:51 I think this is needed because currently no browse
46
47 base::Optional<int> embedded_worker_id_;
36 EmbeddedWorkerDispatcher::WorkerWrapper* wrapper_; 48 EmbeddedWorkerDispatcher::WorkerWrapper* wrapper_;
37 49
50 // Stores callbacks
51 StopWorkerCallback stop_callback_;
52
38 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceClientImpl); 53 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceClientImpl);
39 }; 54 };
40 55
41 } // namespace content 56 } // namespace content
42 57
43 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_ H_ 58 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698