Clean up all old uses of FuzzInterface interface
This CL converts remained old Mojo types of FuzzInterface
interface to new Mojo types. Major changes are as below,
- Convert mojom::InterfaceFactoryPtr to
mojo::PendingRemote|Remote<mojom::FuzzInterface>
- Convert mojo::InterfaceFactoryRequest to
mojo::PendingReceiver<mojom::FuzzInterface>
- Convert mojo::Binding to mojo::Receiver
Bug: 955171
Change-Id: If4e276a27bb86098cd5af1e863578c8d30dc535d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893606
Reviewed-by: Ken Rockot <rockot@google.com>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#713731}
diff --git a/mojo/public/tools/fuzzers/fuzz_impl.cc b/mojo/public/tools/fuzzers/fuzz_impl.cc
index 23816fd..9fbecda 100644
--- a/mojo/public/tools/fuzzers/fuzz_impl.cc
+++ b/mojo/public/tools/fuzzers/fuzz_impl.cc
@@ -4,11 +4,12 @@
#include <utility>
+#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
-FuzzImpl::FuzzImpl(fuzz::mojom::FuzzInterfaceRequest request)
- : binding_(this, std::move(request)) {}
+FuzzImpl::FuzzImpl(mojo::PendingReceiver<fuzz::mojom::FuzzInterface> receiver)
+ : receiver_(this, std::move(receiver)) {}
FuzzImpl::~FuzzImpl() {}
diff --git a/mojo/public/tools/fuzzers/fuzz_impl.h b/mojo/public/tools/fuzzers/fuzz_impl.h
index d8f7f566..77f882d 100644
--- a/mojo/public/tools/fuzzers/fuzz_impl.h
+++ b/mojo/public/tools/fuzzers/fuzz_impl.h
@@ -6,14 +6,15 @@
#define MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
-#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h"
class FuzzImpl : public fuzz::mojom::FuzzInterface,
public fuzz::mojom::FuzzDummyInterface {
public:
- explicit FuzzImpl(fuzz::mojom::FuzzInterfaceRequest request);
+ explicit FuzzImpl(mojo::PendingReceiver<fuzz::mojom::FuzzInterface> receiver);
~FuzzImpl() override;
// fuzz::mojom::FuzzInterface:
@@ -38,7 +39,7 @@
void Ping() override;
/* Expose the binding to the fuzz harness. */
- mojo::Binding<FuzzInterface> binding_;
+ mojo::Receiver<FuzzInterface> receiver_;
private:
mojo::AssociatedReceiverSet<FuzzDummyInterface> associated_receivers_;
diff --git a/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc b/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
index b81f8c4..32ea91d 100644
--- a/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
+++ b/mojo/public/tools/fuzzers/mojo_fuzzer_message_dump.cc
@@ -14,6 +14,7 @@
#include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
@@ -227,13 +228,15 @@
/* Invokes each method in the FuzzInterface and dumps the messages to the
* supplied directory. */
void DumpMessages(std::string output_directory) {
- fuzz::mojom::FuzzInterfacePtr fuzz;
+ mojo::Remote<fuzz::mojom::FuzzInterface> fuzz;
mojo::AssociatedRemote<fuzz::mojom::FuzzDummyInterface> dummy;
/* Create the impl and add a MessageDumper to the filter chain. */
- env->impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz));
- env->impl->binding_.RouterForTesting()->SetIncomingMessageFilter(
- std::make_unique<MessageDumper>(output_directory));
+ env->impl = std::make_unique<FuzzImpl>(fuzz.BindNewPipeAndPassReceiver());
+ env->impl->receiver_.internal_state()
+ ->RouterForTesting()
+ ->SetIncomingMessageFilter(
+ std::make_unique<MessageDumper>(output_directory));
/* Call methods in various ways to generate interesting messages. */
fuzz->FuzzBasic();
diff --git a/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc b/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
index b145959..74691fa 100644
--- a/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
+++ b/mojo/public/tools/fuzzers/mojo_parse_message_fuzzer.cc
@@ -8,13 +8,13 @@
#include "base/task/single_thread_task_executor.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.h"
-#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
void FuzzMessage(const uint8_t* data, size_t size, base::RunLoop* run) {
- fuzz::mojom::FuzzInterfacePtr fuzz;
- auto impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz));
- auto router = impl->binding_.RouterForTesting();
+ mojo::PendingRemote<fuzz::mojom::FuzzInterface> fuzz;
+ auto impl = std::make_unique<FuzzImpl>(fuzz.InitWithNewPipeAndPassReceiver());
+ auto router = impl->receiver_.internal_state()->RouterForTesting();
/* Create a mojo message with the appropriate payload size. */
mojo::Message message(0, 0, size, 0, nullptr);
diff --git a/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc b/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
index ec76724..303e62a 100644
--- a/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
+++ b/mojo/public/tools/fuzzers/mojo_parse_message_proto_fuzzer.cc
@@ -11,7 +11,7 @@
#include "base/task/single_thread_task_executor.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.h"
-#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
#include "mojo/public/tools/fuzzers/mojo_fuzzer.pb.h"
#include "testing/libfuzzer/proto/lpm_interface.h"
@@ -20,9 +20,9 @@
void FuzzMessage(const MojoFuzzerMessages& mojo_fuzzer_messages,
base::RunLoop* run) {
- fuzz::mojom::FuzzInterfacePtr fuzz;
- auto impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz));
- auto router = impl->binding_.RouterForTesting();
+ mojo::PendingRemote<fuzz::mojom::FuzzInterface> fuzz;
+ auto impl = std::make_unique<FuzzImpl>(fuzz.InitWithNewPipeAndPassReceiver());
+ auto router = impl->receiver_.internal_state()->RouterForTesting();
for (auto& message_str : mojo_fuzzer_messages.messages()) {
// Create a mojo message with the appropriate payload size.