Commit aad4e175 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove ViewHostMsg_MediaLogRecords legacy IPC message

This CL implements MediaInternalLogRecordsImpl which works as a receiver
of batched media logs sent from renderer process using class
BatchingMediaLog::EventHandler.

MediaLog messages are grouped together in renderer and then send to
browser in bulk in order to reduce IPC pressure.

Bug: 1047457
Change-Id: Iadd747a5c17ef0572744ba3c6a4366974ed5785f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051877
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742734}
parent 5cfcf074
......@@ -113,6 +113,35 @@ const char kAudioLogUpdateFunction[] = "media.updateAudioComponent";
namespace content {
// This class works as a receiver of logs of events occurring in the
// media pipeline. Media logs send by the renderer process to the
// browser process is handled by the below implementation in the
// browser side.
class MediaInternals::MediaInternalLogRecordsImpl
: public content::mojom::MediaInternalLogRecords {
public:
MediaInternalLogRecordsImpl(content::MediaInternals* media_internals,
int render_process_id);
~MediaInternalLogRecordsImpl() override = default;
void Log(const std::vector<::media::MediaLogRecord>& arr) override;
private:
content::MediaInternals* const media_internals_;
const int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(MediaInternalLogRecordsImpl);
};
MediaInternals::MediaInternalLogRecordsImpl::MediaInternalLogRecordsImpl(
content::MediaInternals* media_internals,
int render_process_id)
: media_internals_(media_internals),
render_process_id_(render_process_id) {}
void MediaInternals::MediaInternalLogRecordsImpl::Log(
const std::vector<::media::MediaLogRecord>& events) {
media_internals_->OnMediaEvents(render_process_id_, events);
}
class MediaInternals::AudioLogImpl : public media::mojom::AudioLog,
public media::AudioLog {
public:
......@@ -571,6 +600,16 @@ void MediaInternals::CreateMojoAudioLog(
std::move(receiver));
}
// static
void MediaInternals::CreateMediaLogRecords(
int render_process_id,
mojo::PendingReceiver<content::mojom::MediaInternalLogRecords> receiver) {
mojo::MakeSelfOwnedReceiver(
std::make_unique<MediaInternalLogRecordsImpl>(
MediaInternals::GetInstance(), render_process_id),
std::move(receiver));
}
std::unique_ptr<MediaInternals::AudioLogImpl>
MediaInternals::CreateAudioLogImpl(
media::AudioLogFactory::AudioComponent component,
......
......@@ -20,6 +20,7 @@
#include "base/values.h"
#include "content/browser/media/media_internals_audio_focus_helper.h"
#include "content/common/content_export.h"
#include "content/common/media/media_log_records.mojom.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "media/audio/audio_logging.h"
......@@ -116,11 +117,16 @@ class CONTENT_EXPORT MediaInternals : public media::AudioLogFactory,
int render_process_id = -1,
int render_frame_id = MSG_ROUTING_NONE);
static void CreateMediaLogRecords(
int render_process_id,
mojo::PendingReceiver<content::mojom::MediaInternalLogRecords> receiver);
private:
// Needs access to SendUpdate.
friend class MediaInternalsAudioFocusHelper;
class AudioLogImpl;
class MediaInternalLogRecordsImpl;
// Inner class to handle reporting pipelinestatus to UMA
class MediaInternalsUMAHandler;
......
......@@ -104,13 +104,7 @@ RenderMessageFilter::~RenderMessageFilter() {
}
bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderMessageFilter, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogRecords, OnMediaLogRecords)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
return false;
}
void RenderMessageFilter::OnDestruct() const {
......@@ -118,12 +112,6 @@ void RenderMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnIOThread::Destruct(this);
}
void RenderMessageFilter::OverrideThreadForMessage(const IPC::Message& message,
BrowserThread::ID* thread) {
if (message.type() == ViewHostMsg_MediaLogRecords::ID)
*thread = BrowserThread::UI;
}
void RenderMessageFilter::GenerateRoutingID(
GenerateRoutingIDCallback callback) {
std::move(callback).Run(render_widget_helper_->GetNextRoutingID());
......
......@@ -64,8 +64,6 @@ class CONTENT_EXPORT RenderMessageFilter
// BrowserMessageFilter methods:
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() const override;
void OverrideThreadForMessage(const IPC::Message& message,
BrowserThread::ID* thread) override;
int render_process_id() const { return render_process_id_; }
......
......@@ -2376,6 +2376,11 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
base::BindRepeating(&RenderProcessHostImpl::BindP2PSocketManager,
weak_factory_.GetWeakPtr()));
AddUIThreadInterface(
registry.get(),
base::BindRepeating(&RenderProcessHostImpl::CreateMediaLogRecordHost,
weak_factory_.GetWeakPtr()));
#if BUILDFLAG(ENABLE_MDNS)
AddUIThreadInterface(
registry.get(),
......@@ -2590,6 +2595,11 @@ void RenderProcessHostImpl::BindP2PSocketManager(
p2p_socket_dispatcher_host_->BindReceiver(std::move(receiver));
}
void RenderProcessHostImpl::CreateMediaLogRecordHost(
mojo::PendingReceiver<content::mojom::MediaInternalLogRecords> receiver) {
content::MediaInternals::CreateMediaLogRecords(GetID(), std::move(receiver));
}
#if BUILDFLAG(ENABLE_PLUGINS)
void RenderProcessHostImpl::BindPluginRegistry(
mojo::PendingReceiver<blink::mojom::PluginRegistry> receiver) {
......
......@@ -33,6 +33,7 @@
#include "build/build_config.h"
#include "content/browser/child_process_launcher.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/browser/media/media_internals.h"
#include "content/browser/media/video_decoder_proxy.h"
#include "content/browser/renderer_host/embedded_frame_sink_provider_impl.h"
#include "content/browser/renderer_host/frame_sink_provider_impl.h"
......@@ -757,6 +758,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
mojo::PendingReceiver<blink::mojom::PushMessaging> receiver);
void BindP2PSocketManager(
mojo::PendingReceiver<network::mojom::P2PSocketManager> receiver);
void CreateMediaLogRecordHost(
mojo::PendingReceiver<content::mojom::MediaInternalLogRecords> receiver);
#if BUILDFLAG(ENABLE_PLUGINS)
void BindPluginRegistry(
mojo::PendingReceiver<blink::mojom::PluginRegistry> receiver);
......
......@@ -453,6 +453,7 @@ mojom("mojo_bindings") {
"input/input_handler.mojom",
"input/input_injector.mojom",
"input/synchronous_compositor.mojom",
"media/media_log_records.mojom",
"media/renderer_audio_input_stream_factory.mojom",
"media/renderer_audio_output_stream_factory.mojom",
"native_types.mojom",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "media/mojo/mojom/media_types.mojom";
// This interface notifies the browser of an event occurring in the
// media pipeline. It sends media event logs from renderer to browser.
interface MediaInternalLogRecords {
// Sends batched media logs to MediaInternalLogRecordsImpl::Log
Log(array<media.mojom.MediaLogRecord> events);
};
\ No newline at end of file
......@@ -216,10 +216,6 @@ IPC_MESSAGE_ROUTED1(
ViewHostMsg_NotifyTextAutosizerPageInfoChangedInLocalMainFrame,
blink::WebTextAutosizerPageInfo /* page_info */)
// Notifies the browser of an event occurring in the media pipeline.
IPC_MESSAGE_CONTROL1(ViewHostMsg_MediaLogRecords,
std::vector<media::MediaLogRecord> /* records */)
// Adding a new message? Stick to the sort order above: first platform
// independent ViewMsg, then ifdefs for platform specific ViewMsg, then platform
// independent ViewHostMsg, then ifdefs for platform specific ViewHostMsg.
......
......@@ -10,11 +10,23 @@ namespace content {
void RenderMediaEventHandler::SendQueuedMediaEvents(
std::vector<media::MediaLogRecord> events_to_send) {
RenderThread::Get()->Send(new ViewHostMsg_MediaLogRecords(events_to_send));
GetMediaInternalRecordLogRemote().Log(events_to_send);
}
RenderMediaEventHandler::RenderMediaEventHandler() = default;
RenderMediaEventHandler::~RenderMediaEventHandler() = default;
// This media log doesn't care, since the RenderThread outlives us for
// chrome://media-internals.
void RenderMediaEventHandler::OnWebMediaPlayerDestroyed() {}
content::mojom::MediaInternalLogRecords&
RenderMediaEventHandler::GetMediaInternalRecordLogRemote() {
if (!media_internal_log_remote_) {
RenderThread::Get()->BindHostReceiver(
media_internal_log_remote_.BindNewPipeAndPassReceiver());
}
return *media_internal_log_remote_;
}
} // namespace content
......@@ -7,7 +7,9 @@
#include <vector>
#include "content/common/media/media_log_records.mojom.h"
#include "content/renderer/media/batching_media_log.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace content {
......@@ -16,10 +18,15 @@ namespace content {
class CONTENT_EXPORT RenderMediaEventHandler
: public BatchingMediaLog::EventHandler {
public:
RenderMediaEventHandler() = default;
~RenderMediaEventHandler() override = default;
RenderMediaEventHandler();
~RenderMediaEventHandler() override;
void SendQueuedMediaEvents(std::vector<media::MediaLogRecord>) override;
void OnWebMediaPlayerDestroyed() override;
private:
content::mojom::MediaInternalLogRecords& GetMediaInternalRecordLogRemote();
mojo::Remote<content::mojom::MediaInternalLogRecords>
media_internal_log_remote_;
};
} // namespace content
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment