| 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 CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "media/mojo/interfaces/service_factory.mojom.h" | 12 #include "media/mojo/interfaces/service_factory.mojom.h" |
| 13 #include "services/shell/public/interfaces/interface_provider.mojom.h" | 13 #include "services/shell/public/interfaces/interface_provider.mojom.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace shell { |
| 17 class InterfaceProvider; |
| 18 } |
| 19 |
| 16 namespace content { | 20 namespace content { |
| 17 | 21 |
| 18 // MediaInterfaceProvider is an implementation of mojo InterfaceProvider that | 22 // MediaInterfaceProvider is an implementation of mojo InterfaceProvider that |
| 19 // provides media related services and handles app disconnection automatically. | 23 // provides media related services and handles disconnection automatically. |
| 20 // This class is single threaded. | 24 // This class is single threaded. |
| 21 class CONTENT_EXPORT MediaInterfaceProvider | 25 class CONTENT_EXPORT MediaInterfaceProvider |
| 22 : public shell::mojom::InterfaceProvider { | 26 : public shell::mojom::InterfaceProvider { |
| 23 public: | 27 public: |
| 24 // Callback used to connect to a mojo application. | 28 explicit MediaInterfaceProvider(shell::InterfaceProvider* remote_interfaces); |
| 25 using ConnectToApplicationCB = | |
| 26 base::Callback<shell::mojom::InterfaceProviderPtr(const GURL& url)>; | |
| 27 | |
| 28 explicit MediaInterfaceProvider( | |
| 29 const ConnectToApplicationCB& connect_to_app_cb); | |
| 30 ~MediaInterfaceProvider() final; | 29 ~MediaInterfaceProvider() final; |
| 31 | 30 |
| 32 // InterfaceProvider implementation. | 31 // InterfaceProvider implementation. |
| 33 void GetInterface(const mojo::String& interface_name, | 32 void GetInterface(const mojo::String& interface_name, |
| 34 mojo::ScopedMessagePipeHandle pipe) final; | 33 mojo::ScopedMessagePipeHandle pipe) final; |
| 35 | 34 |
| 36 private: | 35 private: |
| 37 media::mojom::ServiceFactory* GetMediaServiceFactory(); | 36 media::mojom::ServiceFactory* GetMediaServiceFactory(); |
| 38 void OnConnectionError(); | 37 void OnConnectionError(); |
| 39 | 38 |
| 40 base::ThreadChecker thread_checker_; | 39 base::ThreadChecker thread_checker_; |
| 41 ConnectToApplicationCB connect_to_app_cb_; | 40 shell::InterfaceProvider* remote_interfaces_; |
| 42 media::mojom::ServiceFactoryPtr media_service_factory_; | 41 media::mojom::ServiceFactoryPtr media_service_factory_; |
| 43 | 42 |
| 44 DISALLOW_COPY_AND_ASSIGN(MediaInterfaceProvider); | 43 DISALLOW_COPY_AND_ASSIGN(MediaInterfaceProvider); |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 } // namespace content | 46 } // namespace content |
| 48 | 47 |
| 49 #endif // CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ | 48 #endif // CONTENT_RENDERER_MEDIA_MEDIA_INTERFACE_PROVIDER_H_ |
| OLD | NEW |