Commit dcb3a564 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate FuzzInterface to new Mojo interface

This CL converts FuzzAssociated() of FuzzInterface interface
to new Mojo type

 - Convert InterfaceAssociatedRequest to mojo::PendingAssociatedReceiver
 - Convert AssociatedBindingSet to AssociatedReceiverSet
 - Convert InterfaceAssociatedPtr to mojo::AssociatedRemote

Additionally, this CL adds a copyright to fuzz.mojom.

Bug: 955171
Change-Id: I8942810b085057b8f274bf748c58ecc5cf24c13c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833020Reviewed-by: default avatarOliver Chang <ochang@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#703588}
parent bfa33f1b
// Copyright 2019 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 fuzz.mojom;
[Extensible]
......@@ -63,6 +67,7 @@ interface FuzzDummyInterface {
Ping();
};
// A comprehensive Mojo interface used for fuzzing message dispatch and validation.
interface FuzzInterface {
FuzzBasic();
FuzzBasicResp() => ();
......@@ -74,5 +79,5 @@ interface FuzzInterface {
[Sync]
FuzzArgsSyncResp(FuzzStruct a, FuzzStruct? b) => ();
FuzzAssociated(associated FuzzDummyInterface& request);
FuzzAssociated(pending_associated_receiver<FuzzDummyInterface> receiver);
};
......@@ -38,8 +38,8 @@ void FuzzImpl::FuzzArgsSyncResp(fuzz::mojom::FuzzStructPtr a,
}
void FuzzImpl::FuzzAssociated(
fuzz::mojom::FuzzDummyInterfaceAssociatedRequest req) {
associated_bindings_.AddBinding(this, std::move(req));
mojo::PendingAssociatedReceiver<fuzz::mojom::FuzzDummyInterface> receiver) {
associated_receivers_.Add(this, std::move(receiver));
}
void FuzzImpl::Ping() {}
......@@ -5,8 +5,9 @@
#ifndef MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_
#define MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_
#include "mojo/public/cpp/bindings/associated_binding_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/tools/fuzzers/fuzz.mojom.h"
class FuzzImpl : public fuzz::mojom::FuzzInterface,
......@@ -30,7 +31,8 @@ class FuzzImpl : public fuzz::mojom::FuzzInterface,
FuzzArgsSyncRespCallback callback) override;
void FuzzAssociated(
fuzz::mojom::FuzzDummyInterfaceAssociatedRequest req) override;
mojo::PendingAssociatedReceiver<fuzz::mojom::FuzzDummyInterface> receiver)
override;
// fuzz::mojom::FuzzDummyInterface:
void Ping() override;
......@@ -39,7 +41,7 @@ class FuzzImpl : public fuzz::mojom::FuzzInterface,
mojo::Binding<FuzzInterface> binding_;
private:
mojo::AssociatedBindingSet<FuzzDummyInterface> associated_bindings_;
mojo::AssociatedReceiverSet<FuzzDummyInterface> associated_receivers_;
};
#endif // MOJO_PUBLIC_TOOLS_FUZZERS_FUZZ_IMPL_H_
......@@ -13,6 +13,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/associated_remote.h"
#include "mojo/public/tools/fuzzers/fuzz.mojom.h"
#include "mojo/public/tools/fuzzers/fuzz_impl.h"
......@@ -225,7 +226,7 @@ void FuzzCallback() {}
* supplied directory. */
void DumpMessages(std::string output_directory) {
fuzz::mojom::FuzzInterfacePtr fuzz;
fuzz::mojom::FuzzDummyInterfaceAssociatedPtr dummy;
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));
......@@ -247,7 +248,7 @@ void DumpMessages(std::string output_directory) {
GetPopulatedFuzzStruct(), base::Bind(FuzzCallback));
fuzz->FuzzArgsSyncResp(fuzz::mojom::FuzzStruct::New(),
GetPopulatedFuzzStruct(), base::Bind(FuzzCallback));
fuzz->FuzzAssociated(MakeRequest(&dummy));
fuzz->FuzzAssociated(dummy.BindNewEndpointAndPassReceiver());
dummy->Ping();
}
......
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