| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERFACE_PROXY_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_MEDIA_INTERFACE_PROXY_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/threading/thread_checker.h" |
| 13 #include "media/mojo/interfaces/interface_factory.mojom.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" |
| 15 #include "services/service_manager/public/cpp/interface_registry.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class RenderFrameHost; |
| 20 |
| 21 // This implements the media::mojom::InterfaceFactory interface for |
| 22 // RenderFrameHostImpl. Upon media::mojom::InterfaceFactory calls, it will |
| 23 // figure out where to forward to the interface requests. |
| 24 class MediaInterfaceProxy : public media::mojom::InterfaceFactory { |
| 25 public: |
| 26 // Constructs MediaInterfaceProxy and bind |this| to the |request|. When |
| 27 // connection error happens on the client interface, |error_handler| should be |
| 28 // fired. |
| 29 MediaInterfaceProxy(RenderFrameHost* render_frame_host, |
| 30 media::mojom::InterfaceFactoryRequest request, |
| 31 const base::Closure& error_handler); |
| 32 ~MediaInterfaceProxy() final; |
| 33 |
| 34 // media::mojom::InterfaceFactory implementation. |
| 35 void CreateAudioDecoder(media::mojom::AudioDecoderRequest request) final; |
| 36 void CreateVideoDecoder(media::mojom::VideoDecoderRequest request) final; |
| 37 void CreateRenderer(const std::string& audio_device_id, |
| 38 media::mojom::RendererRequest request) final; |
| 39 void CreateCdm(media::mojom::ContentDecryptionModuleRequest request) final; |
| 40 |
| 41 private: |
| 42 media::mojom::InterfaceFactory* GetMediaInterfaceFactory(); |
| 43 |
| 44 // Callback for connection error on |interface_factory_ptr_|. |
| 45 void OnConnectionError(); |
| 46 |
| 47 void ConnectToService(); |
| 48 |
| 49 // Safe to hold a raw pointer since |this| is owned by RenderFrameHostImpl. |
| 50 RenderFrameHost* render_frame_host_; |
| 51 |
| 52 // TODO(xhwang): Replace InterfaceProvider with a dedicated host interface. |
| 53 // See http://crbug.com/660573 |
| 54 std::vector<std::unique_ptr<service_manager::InterfaceRegistry>> |
| 55 media_registries_; |
| 56 |
| 57 mojo::Binding<media::mojom::InterfaceFactory> binding_; |
| 58 |
| 59 // InterfacePtr to the remote media::mojom::InterfaceFactory implementation. |
| 60 media::mojom::InterfaceFactoryPtr interface_factory_ptr_; |
| 61 |
| 62 base::ThreadChecker thread_checker_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(MediaInterfaceProxy); |
| 65 }; |
| 66 |
| 67 } // namespace content |
| 68 |
| 69 #endif // CONTENT_BROWSER_MEDIA_MEDIA_INTERFACE_PROXY_H_ |
| OLD | NEW |