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