Commit 59d4fc10 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate references of content::mojom::ChildHistogramFetcher* to new Mojo types

Convert both the implementation and clients in the browser and child
process for the content.mojom.ChildHistogramFetcherFactory and the
content.mojo.ChildHistogramFetcher interfaces to the new Mojo types.

Bug: 955171
Change-Id: I3e45219b9c027eb861507f7db9f0cac128eef5bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798357Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#695955}
parent ca219edc
......@@ -101,12 +101,18 @@ template <class T>
void HistogramController::SetHistogramMemory(
T* host,
base::WritableSharedMemoryRegion shared_region) {
content::mojom::ChildHistogramFetcherFactoryPtr
child_histogram_fetcher_factory;
content::mojom::ChildHistogramFetcherPtr child_histogram_fetcher;
content::BindInterface(host, &child_histogram_fetcher_factory);
mojo::PendingRemote<content::mojom::ChildHistogramFetcherFactory>
pending_child_histogram_fetcher_factory;
content::BindInterface(host, &pending_child_histogram_fetcher_factory);
mojo::Remote<content::mojom::ChildHistogramFetcherFactory>
child_histogram_fetcher_factory(
std::move(pending_child_histogram_fetcher_factory));
mojo::Remote<content::mojom::ChildHistogramFetcher> child_histogram_fetcher;
child_histogram_fetcher_factory->CreateFetcher(
std::move(shared_region), mojo::MakeRequest(&child_histogram_fetcher));
std::move(shared_region),
child_histogram_fetcher.BindNewPipeAndPassReceiver());
InsertChildHistogramFetcherInterface(host,
std::move(child_histogram_fetcher));
}
......@@ -114,10 +120,11 @@ void HistogramController::SetHistogramMemory(
template <class T>
void HistogramController::InsertChildHistogramFetcherInterface(
T* host,
content::mojom::ChildHistogramFetcherPtr child_histogram_fetcher) {
mojo::Remote<content::mojom::ChildHistogramFetcher>
child_histogram_fetcher) {
// Broken pipe means remove this from the map. The map size is a proxy for
// the number of known processes
child_histogram_fetcher.set_connection_error_handler(base::BindOnce(
child_histogram_fetcher.set_disconnect_handler(base::BindOnce(
&HistogramController::RemoveChildHistogramFetcherInterface<T>,
base::Unretained(this), base::Unretained(host)));
GetChildHistogramFetcherMap<T>()[host] = std::move(child_histogram_fetcher);
......
......@@ -13,6 +13,7 @@
#include "base/memory/singleton.h"
#include "base/memory/writable_shared_memory_region.h"
#include "content/common/histogram_fetcher.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace content {
......@@ -80,12 +81,13 @@ class HistogramController {
template <class T>
using ChildHistogramFetcherMap =
std::map<T*, content::mojom::ChildHistogramFetcherPtr>;
std::map<T*, mojo::Remote<content::mojom::ChildHistogramFetcher>>;
template <class T>
void InsertChildHistogramFetcherInterface(
T* host,
content::mojom::ChildHistogramFetcherPtr child_histogram_fetcher);
mojo::Remote<content::mojom::ChildHistogramFetcher>
child_histogram_fetcher);
template <class T>
content::mojom::ChildHistogramFetcher* GetChildHistogramFetcherInterface(
......
......@@ -14,7 +14,7 @@
#include "base/single_thread_task_runner.h"
#include "content/child/child_process.h"
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace content {
......@@ -24,14 +24,16 @@ ChildHistogramFetcherFactoryImpl::ChildHistogramFetcherFactoryImpl() {}
ChildHistogramFetcherFactoryImpl::~ChildHistogramFetcherFactoryImpl() {}
void ChildHistogramFetcherFactoryImpl::Create(
content::mojom::ChildHistogramFetcherFactoryRequest request) {
mojo::MakeStrongBinding(std::make_unique<ChildHistogramFetcherFactoryImpl>(),
std::move(request));
mojo::PendingReceiver<content::mojom::ChildHistogramFetcherFactory>
receiver) {
mojo::MakeSelfOwnedReceiver(
std::make_unique<ChildHistogramFetcherFactoryImpl>(),
std::move(receiver));
}
void ChildHistogramFetcherFactoryImpl::CreateFetcher(
base::WritableSharedMemoryRegion shared_memory,
content::mojom::ChildHistogramFetcherRequest request) {
mojo::PendingReceiver<content::mojom::ChildHistogramFetcher> receiver) {
if (shared_memory.IsValid()) {
// This message must be received only once. Multiple calls to create a
// global allocator will cause a CHECK() failure.
......@@ -43,9 +45,8 @@ void ChildHistogramFetcherFactoryImpl::CreateFetcher(
if (global_allocator)
global_allocator->CreateTrackingHistograms(global_allocator->Name());
content::mojom::ChildHistogramFetcherPtr child_histogram_interface;
mojo::MakeStrongBinding(std::make_unique<ChildHistogramFetcherImpl>(),
std::move(request));
mojo::MakeSelfOwnedReceiver(std::make_unique<ChildHistogramFetcherImpl>(),
std::move(receiver));
}
ChildHistogramFetcherImpl::ChildHistogramFetcherImpl() {}
......
......@@ -13,6 +13,7 @@
#include "base/memory/writable_shared_memory_region.h"
#include "content/common/histogram_fetcher.mojom.h"
#include "ipc/message_filter.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace base {
class HistogramDeltaSerialization;
......@@ -26,11 +27,13 @@ class ChildHistogramFetcherFactoryImpl
ChildHistogramFetcherFactoryImpl();
~ChildHistogramFetcherFactoryImpl() override;
static void Create(content::mojom::ChildHistogramFetcherFactoryRequest);
static void Create(
mojo::PendingReceiver<content::mojom::ChildHistogramFetcherFactory>);
private:
void CreateFetcher(base::WritableSharedMemoryRegion,
content::mojom::ChildHistogramFetcherRequest) override;
void CreateFetcher(
base::WritableSharedMemoryRegion,
mojo::PendingReceiver<content::mojom::ChildHistogramFetcher>) override;
};
class ChildHistogramFetcherImpl : public content::mojom::ChildHistogramFetcher {
......
......@@ -10,7 +10,7 @@ interface ChildHistogramFetcherFactory {
// Creates a ChildHistogram interface that uses shared memory buffer to
// store histograms that are to be reported by the browser process to UMA.
CreateFetcher(mojo_base.mojom.WritableSharedMemoryRegion? shared_memory,
ChildHistogramFetcher& child_histogram_fetcher);
pending_receiver<ChildHistogramFetcher> child_histogram_fetcher);
};
interface ChildHistogramFetcher{
......
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