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_SERVICE_IMPL_H_ | 5 #ifndef SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ |
6 #define SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_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/service.h" | 12 #include "services/service_manager/public/cpp/service.h" |
13 #include "services/service_manager/public/cpp/service_context_ref.h" | 13 #include "services/service_manager/public/cpp/service_context_ref.h" |
14 #include "services/video_capture/public/interfaces/device_factory_provider.mojom
.h" | 14 #include "services/video_capture/public/interfaces/device_factory_provider.mojom
.h" |
15 | 15 |
| 16 #if defined(OS_WIN) |
| 17 #include "base/win/scoped_com_initializer.h" |
| 18 #endif |
| 19 |
16 namespace video_capture { | 20 namespace video_capture { |
17 | 21 |
18 class ServiceImpl : public service_manager::Service { | 22 class ServiceImpl : public service_manager::Service { |
19 public: | 23 public: |
20 ServiceImpl(); | 24 ServiceImpl(); |
21 ~ServiceImpl() override; | 25 ~ServiceImpl() override; |
22 | 26 |
23 // service_manager::Service implementation. | 27 // service_manager::Service implementation. |
24 void OnStart() override; | 28 void OnStart() override; |
25 void OnBindInterface(const service_manager::BindSourceInfo& source_info, | 29 void OnBindInterface(const service_manager::BindSourceInfo& source_info, |
26 const std::string& interface_name, | 30 const std::string& interface_name, |
27 mojo::ScopedMessagePipeHandle interface_pipe) override; | 31 mojo::ScopedMessagePipeHandle interface_pipe) override; |
28 bool OnServiceManagerConnectionLost() override; | 32 bool OnServiceManagerConnectionLost() override; |
29 | 33 |
30 private: | 34 private: |
31 void OnDeviceFactoryProviderRequest( | 35 void OnDeviceFactoryProviderRequest( |
32 const service_manager::BindSourceInfo& source_info, | 36 const service_manager::BindSourceInfo& source_info, |
33 mojom::DeviceFactoryProviderRequest request); | 37 mojom::DeviceFactoryProviderRequest request); |
34 void SetShutdownDelayInSeconds(float seconds); | 38 void SetShutdownDelayInSeconds(float seconds); |
35 void MaybeRequestQuitDelayed(); | 39 void MaybeRequestQuitDelayed(); |
36 void MaybeRequestQuit(); | 40 void MaybeRequestQuit(); |
37 | 41 |
| 42 #if defined(OS_WIN) |
| 43 // COM must be initialized in order to access the video capture devices. |
| 44 base::win::ScopedCOMInitializer com_initializer_; |
| 45 #endif |
38 float shutdown_delay_in_seconds_; | 46 float shutdown_delay_in_seconds_; |
39 service_manager::BinderRegistry registry_; | 47 service_manager::BinderRegistry registry_; |
40 std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_; | 48 std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_; |
41 base::ThreadChecker thread_checker_; | 49 base::ThreadChecker thread_checker_; |
42 base::WeakPtrFactory<ServiceImpl> weak_factory_; | 50 base::WeakPtrFactory<ServiceImpl> weak_factory_; |
43 | 51 |
44 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); | 52 DISALLOW_COPY_AND_ASSIGN(ServiceImpl); |
45 }; | 53 }; |
46 | 54 |
47 } // namespace video_capture | 55 } // namespace video_capture |
48 | 56 |
49 #endif // SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ | 57 #endif // SERVICES_VIDEO_CAPTURE_SERVICE_IMPL_H_ |
OLD | NEW |