Commit 2060f20b authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

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/+/1893606Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#713731}
parent b9f77040
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
#include <utility> #include <utility>
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h" #include "mojo/public/tools/fuzzers/fuzz.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h" #include "mojo/public/tools/fuzzers/fuzz_impl.h"
FuzzImpl::FuzzImpl(fuzz::mojom::FuzzInterfaceRequest request) FuzzImpl::FuzzImpl(mojo::PendingReceiver<fuzz::mojom::FuzzInterface> receiver)
: binding_(this, std::move(request)) {} : receiver_(this, std::move(receiver)) {}
FuzzImpl::~FuzzImpl() {} FuzzImpl::~FuzzImpl() {}
......
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
#define MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_ #define MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_
#include "mojo/public/cpp/bindings/associated_receiver_set.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_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" #include "mojo/public/tools/fuzzers/fuzz.mojom.h"
class FuzzImpl : public fuzz::mojom::FuzzInterface, class FuzzImpl : public fuzz::mojom::FuzzInterface,
public fuzz::mojom::FuzzDummyInterface { public fuzz::mojom::FuzzDummyInterface {
public: public:
explicit FuzzImpl(fuzz::mojom::FuzzInterfaceRequest request); explicit FuzzImpl(mojo::PendingReceiver<fuzz::mojom::FuzzInterface> receiver);
~FuzzImpl() override; ~FuzzImpl() override;
// fuzz::mojom::FuzzInterface: // fuzz::mojom::FuzzInterface:
...@@ -38,7 +39,7 @@ class FuzzImpl : public fuzz::mojom::FuzzInterface, ...@@ -38,7 +39,7 @@ class FuzzImpl : public fuzz::mojom::FuzzInterface,
void Ping() override; void Ping() override;
/* Expose the binding to the fuzz harness. */ /* Expose the binding to the fuzz harness. */
mojo::Binding<FuzzInterface> binding_; mojo::Receiver<FuzzInterface> receiver_;
private: private:
mojo::AssociatedReceiverSet<FuzzDummyInterface> associated_receivers_; mojo::AssociatedReceiverSet<FuzzDummyInterface> associated_receivers_;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/task/thread_pool/thread_pool_instance.h" #include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/associated_remote.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.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h" #include "mojo/public/tools/fuzzers/fuzz_impl.h"
...@@ -227,13 +228,15 @@ void FuzzCallback() {} ...@@ -227,13 +228,15 @@ void FuzzCallback() {}
/* Invokes each method in the FuzzInterface and dumps the messages to the /* Invokes each method in the FuzzInterface and dumps the messages to the
* supplied directory. */ * supplied directory. */
void DumpMessages(std::string output_directory) { void DumpMessages(std::string output_directory) {
fuzz::mojom::FuzzInterfacePtr fuzz; mojo::Remote<fuzz::mojom::FuzzInterface> fuzz;
mojo::AssociatedRemote<fuzz::mojom::FuzzDummyInterface> dummy; mojo::AssociatedRemote<fuzz::mojom::FuzzDummyInterface> dummy;
/* Create the impl and add a MessageDumper to the filter chain. */ /* Create the impl and add a MessageDumper to the filter chain. */
env->impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz)); env->impl = std::make_unique<FuzzImpl>(fuzz.BindNewPipeAndPassReceiver());
env->impl->binding_.RouterForTesting()->SetIncomingMessageFilter( env->impl->receiver_.internal_state()
std::make_unique<MessageDumper>(output_directory)); ->RouterForTesting()
->SetIncomingMessageFilter(
std::make_unique<MessageDumper>(output_directory));
/* Call methods in various ways to generate interesting messages. */ /* Call methods in various ways to generate interesting messages. */
fuzz->FuzzBasic(); fuzz->FuzzBasic();
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#include "base/task/single_thread_task_executor.h" #include "base/task/single_thread_task_executor.h"
#include "base/task/thread_pool/thread_pool_instance.h" #include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.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/fuzz_impl.h"
void FuzzMessage(const uint8_t* data, size_t size, base::RunLoop* run) { void FuzzMessage(const uint8_t* data, size_t size, base::RunLoop* run) {
fuzz::mojom::FuzzInterfacePtr fuzz; mojo::PendingRemote<fuzz::mojom::FuzzInterface> fuzz;
auto impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz)); auto impl = std::make_unique<FuzzImpl>(fuzz.InitWithNewPipeAndPassReceiver());
auto router = impl->binding_.RouterForTesting(); auto router = impl->receiver_.internal_state()->RouterForTesting();
/* Create a mojo message with the appropriate payload size. */ /* Create a mojo message with the appropriate payload size. */
mojo::Message message(0, 0, size, 0, nullptr); mojo::Message message(0, 0, size, 0, nullptr);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/task/single_thread_task_executor.h" #include "base/task/single_thread_task_executor.h"
#include "base/task/thread_pool/thread_pool_instance.h" #include "base/task/thread_pool/thread_pool_instance.h"
#include "mojo/core/embedder/embedder.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/fuzz_impl.h"
#include "mojo/public/tools/fuzzers/mojo_fuzzer.pb.h" #include "mojo/public/tools/fuzzers/mojo_fuzzer.pb.h"
#include "testing/libfuzzer/proto/lpm_interface.h" #include "testing/libfuzzer/proto/lpm_interface.h"
...@@ -20,9 +20,9 @@ namespace mojo_proto_fuzzer { ...@@ -20,9 +20,9 @@ namespace mojo_proto_fuzzer {
void FuzzMessage(const MojoFuzzerMessages& mojo_fuzzer_messages, void FuzzMessage(const MojoFuzzerMessages& mojo_fuzzer_messages,
base::RunLoop* run) { base::RunLoop* run) {
fuzz::mojom::FuzzInterfacePtr fuzz; mojo::PendingRemote<fuzz::mojom::FuzzInterface> fuzz;
auto impl = std::make_unique<FuzzImpl>(MakeRequest(&fuzz)); auto impl = std::make_unique<FuzzImpl>(fuzz.InitWithNewPipeAndPassReceiver());
auto router = impl->binding_.RouterForTesting(); auto router = impl->receiver_.internal_state()->RouterForTesting();
for (auto& message_str : mojo_fuzzer_messages.messages()) { for (auto& message_str : mojo_fuzzer_messages.messages()) {
// Create a mojo message with the appropriate payload size. // Create a mojo message with the appropriate payload size.
......
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