Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2498203004: Move media::mojom::RemoterFactory to content, add ContentBrowserClient API. (Closed)
Patch Set: REBASE Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 98d2a3d907616a687884ce11aa7782c94e5348f1..37cd1e320fb83314f52a6de04c831596e6515027 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -96,7 +96,9 @@
#include "device/vibration/vibration_manager_impl.h"
#include "device/wake_lock/wake_lock_service_context.h"
#include "media/base/media_switches.h"
+#include "media/media_features.h"
#include "media/mojo/interfaces/media_service.mojom.h"
+#include "media/mojo/interfaces/remoting.mojom.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/service_manager/public/cpp/connector.h"
@@ -204,6 +206,40 @@ void NotifyRenderFrameDetachedOnIO(int render_process_id, int render_frame_id) {
render_frame_id);
}
+#if BUILDFLAG(ENABLE_MEDIA_REMOTING)
+// RemoterFactory that delegates Create() calls to the ContentBrowserClient.
+//
+// Since Create() could be called at any time, perhaps by a stray task being run
+// after a RenderFrameHost has been destroyed, the RemoterFactoryImpl uses the
+// process/routing IDs as a weak reference to the RenderFrameHostImpl.
+class RemoterFactoryImpl final : public media::mojom::RemoterFactory {
+ public:
+ RemoterFactoryImpl(int process_id, int routing_id)
+ : process_id_(process_id), routing_id_(routing_id) {}
+
+ static void Bind(int process_id, int routing_id,
+ media::mojom::RemoterFactoryRequest request) {
+ mojo::MakeStrongBinding(
+ base::MakeUnique<RemoterFactoryImpl>(process_id, routing_id),
+ std::move(request));
+ }
+
+ private:
+ void Create(media::mojom::RemotingSourcePtr source,
+ media::mojom::RemoterRequest request) final {
+ if (auto* host = RenderFrameHostImpl::FromID(process_id_, routing_id_)) {
+ GetContentClient()->browser()->CreateMediaRemoter(
+ host, std::move(source), std::move(request));
+ }
+ }
+
+ const int process_id_;
+ const int routing_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl);
+};
+#endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
+
} // namespace
// static
@@ -2250,6 +2286,11 @@ void RenderFrameHostImpl::RegisterMojoInterfaces() {
}
#endif
+#if BUILDFLAG(ENABLE_MEDIA_REMOTING)
+ GetInterfaceRegistry()->AddInterface(base::Bind(
+ &RemoterFactoryImpl::Bind, GetProcess()->GetID(), GetRoutingID()));
+#endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
+
GetContentClient()->browser()->RegisterRenderFrameMojoInterfaces(
GetInterfaceRegistry(), this);
}
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698