blob: 4f53c3367731630c2845be9e0d012842e9477b3f [file] [log] [blame]
// components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2013 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.
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif
#include "components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-blink.h"
#include <math.h>
#include <stdint.h>
#include <utility>
#include "base/debug/alias.h"
#include "base/hash/md5_constexpr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/lib/generated_code_util.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
#include "mojo/public/cpp/bindings/lib/send_message_helper.h"
#include "mojo/public/cpp/bindings/lib/proxy_to_responder.h"
#include "mojo/public/cpp/bindings/lib/serialization_util.h"
#include "mojo/public/cpp/bindings/lib/unserialized_message_context.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"
#include "components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-params-data.h"
#include "components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-shared-message-ids.h"
#include "components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-blink-import-headers.h"
#include "components/optimization_guide/optimization_guide_internals/webui/optimization_guide_internals.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"
#ifndef COMPONENTS_OPTIMIZATION_GUIDE_OPTIMIZATION_GUIDE_INTERNALS_WEBUI_OPTIMIZATION_GUIDE_INTERNALS_MOJOM_BLINK_JUMBO_H_
#define COMPONENTS_OPTIMIZATION_GUIDE_OPTIMIZATION_GUIDE_INTERNALS_WEBUI_OPTIMIZATION_GUIDE_INTERNALS_MOJOM_BLINK_JUMBO_H_
#endif
namespace optimization_guide_internals {
namespace mojom {
namespace blink {
const char PageHandlerFactory::Name_[] = "optimization_guide_internals.mojom.PageHandlerFactory";
std::pair<uint32_t, const void*> PageHandlerFactory::MessageToMethodInfo_(mojo::Message& message) {
switch (message.name()) {
case internal::kPageHandlerFactory_CreatePageHandler_Name: {
constexpr uint32_t value = base::MD5Hash32Constexpr(
"(Impl)optimization_guide_internals::mojom::PageHandlerFactory::CreatePageHandler");
#if BUILDFLAG(IS_FUCHSIA)
return std::make_pair(value, nullptr);
#else
return std::make_pair(value, reinterpret_cast<const void*>(&PageHandlerFactory::CreatePageHandler_Sym::IPCSymbol));
#endif // BUILDFLAG(IS_FUCHSIA)
}
}
return std::make_pair(0, nullptr);
}
const char* PageHandlerFactory::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (!is_response) {
switch (message.name()) {
case internal::kPageHandlerFactory_CreatePageHandler_Name:
return "Receive optimization_guide_internals::mojom::PageHandlerFactory::CreatePageHandler";
}
} else {
switch (message.name()) {
case internal::kPageHandlerFactory_CreatePageHandler_Name:
return "Receive reply optimization_guide_internals::mojom::PageHandlerFactory::CreatePageHandler";
}
}
return "Receive unknown mojo message";
#else
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (is_response) {
return "Receive mojo reply";
} else {
return "Receive mojo message";
}
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}
#if !BUILDFLAG(IS_FUCHSIA)
void PageHandlerFactory::CreatePageHandler_Sym::IPCSymbol() {
// This method's address is used for indetifiying the mojo method name after
// symblozation. So each IPCSymbol should have a unique address.
NO_CODE_FOLDING();
}
# endif // !BUILDFLAG(IS_FUCHSIA)
PageHandlerFactoryProxy::PageHandlerFactoryProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void PageHandlerFactoryProxy::CreatePageHandler(
::mojo::PendingRemote<Page> in_page) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send optimization_guide_internals::mojom::PageHandlerFactory::CreatePageHandler", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("page"), in_page,
"<value of type ::mojo::PendingRemote<Page>>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt);
mojo::Message message(
internal::kPageHandlerFactory_CreatePageHandler_Name, kFlags, 0, 0, nullptr);
mojo::internal::MessageFragment<
::optimization_guide_internals::mojom::internal::PageHandlerFactory_CreatePageHandler_Params_Data> params(
message);
params.Allocate();
mojo::internal::Serialize<mojo::InterfacePtrDataView<::optimization_guide_internals::mojom::PageInterfaceBase>>(
in_page, &params->page, &params.message());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
!mojo::internal::IsHandleOrInterfaceValid(params->page),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
"invalid page in PageHandlerFactory.CreatePageHandler request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(PageHandlerFactory::Name_);
message.set_method_name("CreatePageHandler");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMessage(*receiver_, message);
}
// static
bool PageHandlerFactoryStubDispatch::Accept(
PageHandlerFactory* impl,
mojo::Message* message) {
switch (message->header()->name) {
case internal::kPageHandlerFactory_CreatePageHandler_Name: {
DCHECK(message->is_serialized());
internal::PageHandlerFactory_CreatePageHandler_Params_Data* params =
reinterpret_cast<internal::PageHandlerFactory_CreatePageHandler_Params_Data*>(
message->mutable_payload());
bool success = true;
::mojo::PendingRemote<Page> p_page{};
PageHandlerFactory_CreatePageHandler_ParamsDataView input_data_view(params, message);
if (success) {
p_page =
input_data_view.TakePage<decltype(p_page)>();
}
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
PageHandlerFactory::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->CreatePageHandler(
std::move(p_page));
return true;
}
}
return false;
}
// static
bool PageHandlerFactoryStubDispatch::AcceptWithResponder(
PageHandlerFactory* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
[[maybe_unused]] const bool message_is_sync =
message->has_flag(mojo::Message::kFlagIsSync);
[[maybe_unused]] const uint64_t request_id = message->request_id();
switch (message->header()->name) {
case internal::kPageHandlerFactory_CreatePageHandler_Name: {
break;
}
}
return false;
}
static const mojo::internal::GenericValidationInfo kPageHandlerFactoryValidationInfo[] = {
{&internal::PageHandlerFactory_CreatePageHandler_Params_Data::Validate,
nullptr /* no response */},
};
bool PageHandlerFactoryRequestValidator::Accept(mojo::Message* message) {
const char* name = ::optimization_guide_internals::mojom::blink::PageHandlerFactory::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kPageHandlerFactoryValidationInfo);
}
const char Page::Name_[] = "optimization_guide_internals.mojom.Page";
std::pair<uint32_t, const void*> Page::MessageToMethodInfo_(mojo::Message& message) {
switch (message.name()) {
case internal::kPage_OnLogMessageAdded_Name: {
constexpr uint32_t value = base::MD5Hash32Constexpr(
"(Impl)optimization_guide_internals::mojom::Page::OnLogMessageAdded");
#if BUILDFLAG(IS_FUCHSIA)
return std::make_pair(value, nullptr);
#else
return std::make_pair(value, reinterpret_cast<const void*>(&Page::OnLogMessageAdded_Sym::IPCSymbol));
#endif // BUILDFLAG(IS_FUCHSIA)
}
}
return std::make_pair(0, nullptr);
}
const char* Page::MessageToMethodName_(mojo::Message& message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (!is_response) {
switch (message.name()) {
case internal::kPage_OnLogMessageAdded_Name:
return "Receive optimization_guide_internals::mojom::Page::OnLogMessageAdded";
}
} else {
switch (message.name()) {
case internal::kPage_OnLogMessageAdded_Name:
return "Receive reply optimization_guide_internals::mojom::Page::OnLogMessageAdded";
}
}
return "Receive unknown mojo message";
#else
bool is_response = message.has_flag(mojo::Message::kFlagIsResponse);
if (is_response) {
return "Receive mojo reply";
} else {
return "Receive mojo message";
}
#endif // BUILDFLAG(MOJO_TRACE_ENABLED)
}
#if !BUILDFLAG(IS_FUCHSIA)
void Page::OnLogMessageAdded_Sym::IPCSymbol() {
// This method's address is used for indetifiying the mojo method name after
// symblozation. So each IPCSymbol should have a unique address.
NO_CODE_FOLDING();
}
# endif // !BUILDFLAG(IS_FUCHSIA)
PageProxy::PageProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void PageProxy::OnLogMessageAdded(
::base::Time in_event_time, const WTF::String& in_source_file, int64_t in_source_line, const WTF::String& in_message) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send optimization_guide_internals::mojom::Page::OnLogMessageAdded", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("event_time"), in_event_time,
"<value of type ::base::Time>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("source_file"), in_source_file,
"<value of type const WTF::String&>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("source_line"), in_source_line,
"<value of type int64_t>");
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("message"), in_message,
"<value of type const WTF::String&>");
});
#endif
const bool kExpectsResponse = false;
const bool kIsSync = false;
const bool kAllowInterrupt = true;
const uint32_t kFlags =
((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) |
((kIsSync) ? mojo::Message::kFlagIsSync : 0) |
((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt);
mojo::Message message(
internal::kPage_OnLogMessageAdded_Name, kFlags, 0, 0, nullptr);
mojo::internal::MessageFragment<
::optimization_guide_internals::mojom::internal::Page_OnLogMessageAdded_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->event_time)::BaseType> event_time_fragment(
params.message());
mojo::internal::Serialize<::mojo_base::mojom::TimeDataView>(
in_event_time, event_time_fragment);
params->event_time.Set(
event_time_fragment.is_null() ? nullptr : event_time_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->event_time.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null event_time in Page.OnLogMessageAdded request");
mojo::internal::MessageFragment<
typename decltype(params->source_file)::BaseType> source_file_fragment(
params.message());
mojo::internal::Serialize<mojo::StringDataView>(
in_source_file, source_file_fragment);
params->source_file.Set(
source_file_fragment.is_null() ? nullptr : source_file_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->source_file.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null source_file in Page.OnLogMessageAdded request");
params->source_line = in_source_line;
mojo::internal::MessageFragment<
typename decltype(params->message)::BaseType> message_fragment(
params.message());
mojo::internal::Serialize<mojo::StringDataView>(
in_message, message_fragment);
params->message.Set(
message_fragment.is_null() ? nullptr : message_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->message.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null message in Page.OnLogMessageAdded request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(Page::Name_);
message.set_method_name("OnLogMessageAdded");
#endif
// This return value may be ignored as false implies the Connector has
// encountered an error, which will be visible through other means.
::mojo::internal::SendMessage(*receiver_, message);
}
// static
bool PageStubDispatch::Accept(
Page* impl,
mojo::Message* message) {
switch (message->header()->name) {
case internal::kPage_OnLogMessageAdded_Name: {
DCHECK(message->is_serialized());
internal::Page_OnLogMessageAdded_Params_Data* params =
reinterpret_cast<internal::Page_OnLogMessageAdded_Params_Data*>(
message->mutable_payload());
bool success = true;
::base::Time p_event_time{};
WTF::String p_source_file{};
int64_t p_source_line{};
WTF::String p_message{};
Page_OnLogMessageAdded_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadEventTime(&p_event_time))
success = false;
if (success && !input_data_view.ReadSourceFile(&p_source_file))
success = false;
if (success)
p_source_line = input_data_view.source_line();
if (success && !input_data_view.ReadMessage(&p_message))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
Page::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->OnLogMessageAdded(
std::move(p_event_time),
std::move(p_source_file),
std::move(p_source_line),
std::move(p_message));
return true;
}
}
return false;
}
// static
bool PageStubDispatch::AcceptWithResponder(
Page* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
[[maybe_unused]] const bool message_is_sync =
message->has_flag(mojo::Message::kFlagIsSync);
[[maybe_unused]] const uint64_t request_id = message->request_id();
switch (message->header()->name) {
case internal::kPage_OnLogMessageAdded_Name: {
break;
}
}
return false;
}
static const mojo::internal::GenericValidationInfo kPageValidationInfo[] = {
{&internal::Page_OnLogMessageAdded_Params_Data::Validate,
nullptr /* no response */},
};
bool PageRequestValidator::Accept(mojo::Message* message) {
const char* name = ::optimization_guide_internals::mojom::blink::Page::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kPageValidationInfo);
}
} // namespace blink
} // namespace mojom
} // namespace optimization_guide_internals
namespace mojo {
} // namespace mojo
// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.
namespace optimization_guide_internals {
namespace mojom {
namespace blink {
void PageHandlerFactoryInterceptorForTesting::CreatePageHandler(::mojo::PendingRemote<Page> page) {
GetForwardingInterface()->CreatePageHandler(std::move(page));
}
PageHandlerFactoryAsyncWaiter::PageHandlerFactoryAsyncWaiter(
PageHandlerFactory* proxy) : proxy_(proxy) {}
PageHandlerFactoryAsyncWaiter::~PageHandlerFactoryAsyncWaiter() = default;
void PageInterceptorForTesting::OnLogMessageAdded(::base::Time event_time, const WTF::String& source_file, int64_t source_line, const WTF::String& message) {
GetForwardingInterface()->OnLogMessageAdded(std::move(event_time), std::move(source_file), std::move(source_line), std::move(message));
}
PageAsyncWaiter::PageAsyncWaiter(
Page* proxy) : proxy_(proxy) {}
PageAsyncWaiter::~PageAsyncWaiter() = default;
} // namespace blink
} // namespace mojom
} // namespace optimization_guide_internals
#if defined(__clang__)
#pragma clang diagnostic pop
#endif