OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ |
6 #define MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "media/mojo/interfaces/interface_factory.mojom.h" | 15 #include "media/mojo/interfaces/interface_factory.mojom.h" |
16 #include "media/mojo/interfaces/media_service.mojom.h" | 16 #include "media/mojo/interfaces/media_service.mojom.h" |
17 #include "media/mojo/services/media_mojo_export.h" | 17 #include "media/mojo/services/media_mojo_export.h" |
18 #include "mojo/public/cpp/bindings/binding_set.h" | 18 #include "mojo/public/cpp/bindings/binding_set.h" |
| 19 #include "services/service_manager/public/cpp/binder_registry.h" |
19 #include "services/service_manager/public/cpp/interface_factory.h" | 20 #include "services/service_manager/public/cpp/interface_factory.h" |
20 #include "services/service_manager/public/cpp/service.h" | 21 #include "services/service_manager/public/cpp/service.h" |
21 #include "services/service_manager/public/cpp/service_context.h" | 22 #include "services/service_manager/public/cpp/service_context.h" |
22 #include "services/service_manager/public/cpp/service_context_ref.h" | 23 #include "services/service_manager/public/cpp/service_context_ref.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace media { | 26 namespace media { |
26 | 27 |
27 class MediaLog; | 28 class MediaLog; |
28 class MojoMediaClient; | 29 class MojoMediaClient; |
29 | 30 |
30 class MEDIA_MOJO_EXPORT MediaService | 31 class MEDIA_MOJO_EXPORT MediaService |
31 : public NON_EXPORTED_BASE(service_manager::Service), | 32 : public NON_EXPORTED_BASE(service_manager::Service), |
32 public NON_EXPORTED_BASE( | 33 public NON_EXPORTED_BASE( |
33 service_manager::InterfaceFactory<mojom::MediaService>), | 34 service_manager::InterfaceFactory<mojom::MediaService>), |
34 public NON_EXPORTED_BASE(mojom::MediaService) { | 35 public NON_EXPORTED_BASE(mojom::MediaService) { |
35 public: | 36 public: |
36 explicit MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client); | 37 explicit MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client); |
37 ~MediaService() final; | 38 ~MediaService() final; |
38 | 39 |
39 private: | 40 private: |
40 // service_manager::Service implementation. | 41 // service_manager::Service implementation. |
41 void OnStart() final; | 42 void OnStart() final; |
42 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 43 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
43 service_manager::InterfaceRegistry* registry) final; | 44 const std::string& interface_name, |
| 45 mojo::ScopedMessagePipeHandle interface_pipe) override; |
44 bool OnServiceManagerConnectionLost() final; | 46 bool OnServiceManagerConnectionLost() final; |
45 | 47 |
46 // service_manager::InterfaceFactory<mojom::MediaService> implementation. | 48 // service_manager::InterfaceFactory<mojom::MediaService> implementation. |
47 void Create(const service_manager::Identity& remote_identity, | 49 void Create(const service_manager::Identity& remote_identity, |
48 mojom::MediaServiceRequest request) final; | 50 mojom::MediaServiceRequest request) final; |
49 | 51 |
50 // mojom::MediaService implementation. | 52 // mojom::MediaService implementation. |
51 void CreateInterfaceFactory( | 53 void CreateInterfaceFactory( |
52 mojom::InterfaceFactoryRequest request, | 54 mojom::InterfaceFactoryRequest request, |
53 service_manager::mojom::InterfaceProviderPtr host_interfaces) final; | 55 service_manager::mojom::InterfaceProviderPtr host_interfaces) final; |
54 | 56 |
55 // Note: Since each instance runs on a different thread, do not share a common | 57 // Note: Since each instance runs on a different thread, do not share a common |
56 // MojoMediaClient with other instances to avoid threading issues. Hence using | 58 // MojoMediaClient with other instances to avoid threading issues. Hence using |
57 // a unique_ptr here. | 59 // a unique_ptr here. |
58 std::unique_ptr<MojoMediaClient> mojo_media_client_; | 60 std::unique_ptr<MojoMediaClient> mojo_media_client_; |
59 | 61 |
60 scoped_refptr<MediaLog> media_log_; | 62 scoped_refptr<MediaLog> media_log_; |
61 std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_; | 63 std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_; |
62 | 64 |
| 65 service_manager::BinderRegistry registry_; |
63 mojo::BindingSet<mojom::MediaService> bindings_; | 66 mojo::BindingSet<mojom::MediaService> bindings_; |
64 }; | 67 }; |
65 | 68 |
66 } // namespace media | 69 } // namespace media |
67 | 70 |
68 #endif // MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ | 71 #endif // MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_ |
OLD | NEW |