OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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 SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_SERVICE_H_ | 5 #ifndef SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ |
6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_SERVICE_H_ | 6 #define SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
11 #include "services/service_manager/public/cpp/binder_registry.h" | 11 #include "services/service_manager/public/cpp/binder_registry.h" |
12 #include "services/service_manager/public/cpp/interface_factory.h" | 12 #include "services/service_manager/public/cpp/interface_factory.h" |
13 #include "services/service_manager/public/cpp/service.h" | 13 #include "services/service_manager/public/cpp/service.h" |
14 #include "services/video_capture/public/interfaces/service.mojom.h" | 14 #include "services/service_manager/public/cpp/service_context_ref.h" |
| 15 #include "services/video_capture/public/interfaces/device_factory_provider.mojom
.h" |
15 | 16 |
16 namespace video_capture { | 17 namespace video_capture { |
17 | 18 |
18 class DeviceFactoryMediaToMojoAdapter; | 19 class ServiceImpl : public service_manager::Service { |
19 | |
20 // Implementation of video_capture::mojom::Service as a Service Manager service. | |
21 class ServiceImpl : public service_manager::Service, | |
22 public service_manager::InterfaceFactory<mojom::Service>, | |
23 public mojom::Service { | |
24 public: | 20 public: |
25 ServiceImpl(); | 21 ServiceImpl(); |
26 ~ServiceImpl() override; | 22 ~ServiceImpl() override; |
27 | 23 |
28 // service_manager::Service: | 24 // service_manager::Service implementation. |
| 25 void OnStart() override; |
29 void OnBindInterface(const service_manager::ServiceInfo& source_info, | 26 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
30 const std::string& interface_name, | 27 const std::string& interface_name, |
31 mojo::ScopedMessagePipeHandle interface_pipe) override; | 28 mojo::ScopedMessagePipeHandle interface_pipe) override; |
32 | 29 bool OnServiceManagerConnectionLost() override; |
33 // service_manager::InterfaceFactory<video_capture::mojom::Service>: | |
34 void Create(const service_manager::Identity& remote_identity, | |
35 mojom::ServiceRequest request) override; | |
36 | |
37 // video_capture::mojom::Service | |
38 void ConnectToDeviceFactory(mojom::DeviceFactoryRequest request) override; | |
39 void ConnectToFakeDeviceFactory(mojom::DeviceFactoryRequest request) override; | |
40 | 30 |
41 private: | 31 private: |
42 void LazyInitializeDeviceFactory(); | 32 void OnDeviceFactoryProviderRequest( |
43 void LazyInitializeFakeDeviceFactory(); | 33 mojom::DeviceFactoryProviderRequest request); |
| 34 void SetShutdownDelayInSeconds(float seconds); |
| 35 void MaybeRequestQuitDelayed(); |
| 36 void MaybeRequestQuit(); |
44 | 37 |
| 38 float shutdown_delay_in_seconds_; |
45 service_manager::BinderRegistry registry_; | 39 service_manager::BinderRegistry registry_; |
46 mojo::BindingSet<mojom::Service> service_bindings_; | 40 std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_; |
47 mojo::BindingSet<mojom::DeviceFactory> factory_bindings_; | 41 base::WeakPtrFactory<ServiceImpl> weak_factory_; |
48 mojo::BindingSet<mojom::DeviceFactory> fake_factory_bindings_; | 42 |
49 std::unique_ptr<DeviceFactoryMediaToMojoAdapter> device_factory_; | 43 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); |
50 std::unique_ptr<DeviceFactoryMediaToMojoAdapter> fake_device_factory_; | |
51 }; | 44 }; |
52 | 45 |
53 } // namespace video_capture | 46 } // namespace video_capture |
54 | 47 |
55 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_SERVICE_H_ | 48 #endif // SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ |
OLD | NEW |