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

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

Issue 2606593002: [ServiceWorker] Associate interfaces.
Patch Set: Fix unit tests Created 3 years, 11 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 "base/optional.h"
10 #include "content/child/child_thread_impl.h" 10 #include "content/child/child_thread_impl.h"
11 #include "content/common/service_worker/embedded_worker.mojom.h" 11 #include "content/common/service_worker/embedded_worker.mojom.h"
12 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" 12 #include "content/renderer/service_worker/embedded_worker_dispatcher.h"
13 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/associated_binding.h"
14 #include "mojo/public/cpp/bindings/interface_ptr.h"
15 14
16 namespace content { 15 namespace content {
17 16
18 // This class exposes interfaces of WebEmbeddedWorker to the browser process. 17 // This class exposes interfaces of WebEmbeddedWorker to the browser process.
19 // Unless otherwise noted, all methods should be called on the main thread. 18 // Unless otherwise noted, all methods should be called on the main thread.
20 class EmbeddedWorkerInstanceClientImpl 19 class EmbeddedWorkerInstanceClientImpl
21 : public mojom::EmbeddedWorkerInstanceClient { 20 : public mojom::EmbeddedWorkerInstanceClient {
22 public: 21 public:
23 static void Create( 22 static void Create(
24 EmbeddedWorkerDispatcher* dispatcher, 23 EmbeddedWorkerDispatcher* dispatcher,
25 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request); 24 mojom::EmbeddedWorkerInstanceClientAssociatedRequest request);
26 25
27 ~EmbeddedWorkerInstanceClientImpl() override; 26 ~EmbeddedWorkerInstanceClientImpl() override;
28 27
29 // Called from ServiceWorkerContextClient. 28 // Called from ServiceWorkerContextClient.
30 void StopWorkerCompleted(); 29 void StopWorkerCompleted();
31 30
32 private: 31 private:
33 EmbeddedWorkerInstanceClientImpl( 32 EmbeddedWorkerInstanceClientImpl(
34 EmbeddedWorkerDispatcher* dispatcher, 33 EmbeddedWorkerDispatcher* dispatcher,
35 mojo::InterfaceRequest<mojom::EmbeddedWorkerInstanceClient> request); 34 mojom::EmbeddedWorkerInstanceClientAssociatedRequest request);
36 35
37 // mojom::EmbeddedWorkerInstanceClient implementation 36 // mojom::EmbeddedWorkerInstanceClient implementation
38 void StartWorker( 37 void StartWorker(
39 const EmbeddedWorkerStartParams& params, 38 const EmbeddedWorkerStartParams& params,
40 mojom::ServiceWorkerEventDispatcherRequest dispatcher_request) override; 39 mojom::ServiceWorkerEventDispatcherRequest dispatcher_request) override;
41 void StopWorker(const StopWorkerCallback& callback) override; 40 void StopWorker(const StopWorkerCallback& callback) override;
42 41
43 // Handler of connection error bound to |binding_| 42 // Handler of connection error bound to |binding_|
44 void OnError(); 43 void OnError();
45 44
46 EmbeddedWorkerDispatcher* dispatcher_; 45 EmbeddedWorkerDispatcher* dispatcher_;
47 mojo::Binding<mojom::EmbeddedWorkerInstanceClient> binding_; 46 mojo::AssociatedBinding<mojom::EmbeddedWorkerInstanceClient> binding_;
48 47
49 // This is valid before StartWorker is called. After that, this object 48 // This is valid before StartWorker is called. After that, this object
50 // will be passed to ServiceWorkerContextClient. 49 // will be passed to ServiceWorkerContextClient.
51 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> temporal_self_; 50 std::unique_ptr<EmbeddedWorkerInstanceClientImpl> temporal_self_;
52 51
53 base::Optional<int> embedded_worker_id_; 52 base::Optional<int> embedded_worker_id_;
54 53
55 // Owned by EmbeddedWorkerDispatcher. This can be nullptr while a worker is 54 // Owned by EmbeddedWorkerDispatcher. This can be nullptr while a worker is
56 // not running. 55 // not running.
57 EmbeddedWorkerDispatcher::WorkerWrapper* wrapper_; 56 EmbeddedWorkerDispatcher::WorkerWrapper* wrapper_;
58 57
59 StopWorkerCallback stop_callback_; 58 StopWorkerCallback stop_callback_;
60 59
61 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceClientImpl); 60 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceClientImpl);
62 }; 61 };
63 62
64 } // namespace content 63 } // namespace content
65 64
66 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_ H_ 65 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_CLIENT_IMPL_ H_
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | content/renderer/service_worker/embedded_worker_instance_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698