blob: c53aee7ad6b68ee32fc482a6e622c516ec3cc40b [file] [log] [blame]
// chromeos/crosapi/mojom/kiosk_session_service.mojom.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 "chromeos/crosapi/mojom/kiosk_session_service.mojom.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 "chromeos/crosapi/mojom/kiosk_session_service.mojom-params-data.h"
#include "chromeos/crosapi/mojom/kiosk_session_service.mojom-shared-message-ids.h"
#include "chromeos/crosapi/mojom/kiosk_session_service.mojom-import-headers.h"
#include "chromeos/crosapi/mojom/kiosk_session_service.mojom-test-utils.h"
#ifndef CHROMEOS_CROSAPI_MOJOM_KIOSK_SESSION_SERVICE_MOJOM_JUMBO_H_
#define CHROMEOS_CROSAPI_MOJOM_KIOSK_SESSION_SERVICE_MOJOM_JUMBO_H_
#endif
namespace crosapi {
namespace mojom {
const char KioskSessionService::Name_[] = "crosapi.mojom.KioskSessionService";
constexpr base::Token KioskSessionService::Uuid_;
std::pair<uint32_t, const void*> KioskSessionService::MessageToMethodInfo_(mojo::Message& message) {
switch (message.name()) {
case internal::kKioskSessionService_AttemptUserExit_Name: {
constexpr uint32_t value = base::MD5Hash32Constexpr(
"(Impl)crosapi::mojom::KioskSessionService::AttemptUserExit");
return std::make_pair(value, reinterpret_cast<const void*>(&KioskSessionService::AttemptUserExit_Sym::IPCSymbol));
}
case internal::kKioskSessionService_RestartDevice_Name: {
constexpr uint32_t value = base::MD5Hash32Constexpr(
"(Impl)crosapi::mojom::KioskSessionService::RestartDevice");
return std::make_pair(value, reinterpret_cast<const void*>(&KioskSessionService::RestartDevice_Sym::IPCSymbol));
}
}
return std::make_pair(0, nullptr);
}
const char* KioskSessionService::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::kKioskSessionService_AttemptUserExit_Name:
return "Receive crosapi::mojom::KioskSessionService::AttemptUserExit";
case internal::kKioskSessionService_RestartDevice_Name:
return "Receive crosapi::mojom::KioskSessionService::RestartDevice";
}
} else {
switch (message.name()) {
case internal::kKioskSessionService_AttemptUserExit_Name:
return "Receive reply crosapi::mojom::KioskSessionService::AttemptUserExit";
case internal::kKioskSessionService_RestartDevice_Name:
return "Receive reply crosapi::mojom::KioskSessionService::RestartDevice";
}
}
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)
}
void KioskSessionService::AttemptUserExit_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();
}
void KioskSessionService::RestartDevice_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();
}
class KioskSessionService_RestartDevice_ForwardToCallback
: public mojo::MessageReceiver {
public:
KioskSessionService_RestartDevice_ForwardToCallback(
KioskSessionService::RestartDeviceCallback callback
) : callback_(std::move(callback)) {
}
KioskSessionService_RestartDevice_ForwardToCallback(const KioskSessionService_RestartDevice_ForwardToCallback&) = delete;
KioskSessionService_RestartDevice_ForwardToCallback& operator=(const KioskSessionService_RestartDevice_ForwardToCallback&) = delete;
bool Accept(mojo::Message* message) override;
private:
KioskSessionService::RestartDeviceCallback callback_;
};
KioskSessionServiceProxy::KioskSessionServiceProxy(mojo::MessageReceiverWithResponder* receiver)
: receiver_(receiver) {
}
void KioskSessionServiceProxy::AttemptUserExit(
) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "Send crosapi::mojom::KioskSessionService::AttemptUserExit");
#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::kKioskSessionService_AttemptUserExit_Name, kFlags, 0, 0, nullptr);
mojo::internal::MessageFragment<
::crosapi::mojom::internal::KioskSessionService_AttemptUserExit_Params_Data> params(
message);
params.Allocate();
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(KioskSessionService::Name_);
message.set_method_name("AttemptUserExit");
#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);
}
void KioskSessionServiceProxy::RestartDevice(
const std::string& in_description, RestartDeviceCallback callback) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send crosapi::mojom::KioskSessionService::RestartDevice", "input_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("description"), in_description,
"<value of type const std::string&>");
});
#endif
const bool kExpectsResponse = true;
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::kKioskSessionService_RestartDevice_Name, kFlags, 0, 0, nullptr);
mojo::internal::MessageFragment<
::crosapi::mojom::internal::KioskSessionService_RestartDevice_Params_Data> params(
message);
params.Allocate();
mojo::internal::MessageFragment<
typename decltype(params->description)::BaseType> description_fragment(
params.message());
mojo::internal::Serialize<mojo::StringDataView>(
in_description, description_fragment);
params->description.Set(
description_fragment.is_null() ? nullptr : description_fragment.data());
MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(
params->description.is_null(),
mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
"null description in KioskSessionService.RestartDevice request");
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(KioskSessionService::Name_);
message.set_method_name("RestartDevice");
#endif
std::unique_ptr<mojo::MessageReceiver> responder(
new KioskSessionService_RestartDevice_ForwardToCallback(
std::move(callback)));
::mojo::internal::SendMessage(*receiver_, message, std::move(responder));
}
class KioskSessionService_RestartDevice_ProxyToResponder : public ::mojo::internal::ProxyToResponder {
public:
static KioskSessionService::RestartDeviceCallback CreateCallback(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) {
std::unique_ptr<KioskSessionService_RestartDevice_ProxyToResponder> proxy(
new KioskSessionService_RestartDevice_ProxyToResponder(
message, std::move(responder)));
return base::BindOnce(&KioskSessionService_RestartDevice_ProxyToResponder::Run,
std::move(proxy));
}
~KioskSessionService_RestartDevice_ProxyToResponder() {
#if DCHECK_IS_ON()
if (responder_) {
// If we're being destroyed without being run, we want to ensure the
// binding endpoint has been closed. This checks for that asynchronously.
// We pass a bound generated callback to handle the response so that any
// resulting DCHECK stack will have useful interface type information.
responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete));
}
#endif
}
private:
KioskSessionService_RestartDevice_ProxyToResponder(
::mojo::Message& message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder)
: ::mojo::internal::ProxyToResponder(message, std::move(responder)) {
}
#if DCHECK_IS_ON()
static void OnIsConnectedComplete(bool connected) {
DCHECK(!connected)
<< "KioskSessionService::RestartDeviceCallback was destroyed without "
<< "first either being run or its corresponding binding being closed. "
<< "It is an error to drop response callbacks which still correspond "
<< "to an open interface pipe.";
}
#endif
void Run(
bool in_status);
};
bool KioskSessionService_RestartDevice_ForwardToCallback::Accept(
mojo::Message* message) {
DCHECK(message->is_serialized());
internal::KioskSessionService_RestartDevice_ResponseParams_Data* params =
reinterpret_cast<
internal::KioskSessionService_RestartDevice_ResponseParams_Data*>(
message->mutable_payload());
bool success = true;
bool p_status{};
KioskSessionService_RestartDevice_ResponseParamsDataView input_data_view(params, message);
if (success)
p_status = input_data_view.status();
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
KioskSessionService::Name_, 1, true);
return false;
}
if (!callback_.is_null())
std::move(callback_).Run(
std::move(p_status));
return true;
}
void KioskSessionService_RestartDevice_ProxyToResponder::Run(
bool in_status) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT1(
"mojom", "Send reply crosapi::mojom::KioskSessionService::RestartDevice", "async_response_parameters",
[&](perfetto::TracedValue context){
auto dict = std::move(context).WriteDictionary();
perfetto::WriteIntoTracedValueWithFallback(
dict.AddItem("status"), in_status,
"<value of type bool>");
});
#endif
const uint32_t kFlags = mojo::Message::kFlagIsResponse |
((is_sync_) ? mojo::Message::kFlagIsSync : 0) |
((true) ? 0 : mojo::Message::kFlagNoInterrupt);
mojo::Message message(
internal::kKioskSessionService_RestartDevice_Name, kFlags, 0, 0, nullptr);
mojo::internal::MessageFragment<
::crosapi::mojom::internal::KioskSessionService_RestartDevice_ResponseParams_Data> params(
message);
params.Allocate();
params->status = in_status;
#if defined(ENABLE_IPC_FUZZER)
message.set_interface_name(KioskSessionService::Name_);
message.set_method_name("RestartDevice");
#endif
message.set_request_id(request_id_);
message.set_trace_nonce(trace_nonce_);
::mojo::internal::SendMessage(*responder_, message);
// SendMessage fails silently if the responder connection is closed,
// or if the message is malformed.
//
// TODO(darin): If Accept() returns false due to a malformed message, that
// may be good reason to close the connection. However, we don't have a
// way to do that from here. We should add a way.
responder_ = nullptr;
}
// static
bool KioskSessionServiceStubDispatch::Accept(
KioskSessionService* impl,
mojo::Message* message) {
switch (message->header()->name) {
case internal::kKioskSessionService_AttemptUserExit_Name: {
DCHECK(message->is_serialized());
internal::KioskSessionService_AttemptUserExit_Params_Data* params =
reinterpret_cast<internal::KioskSessionService_AttemptUserExit_Params_Data*>(
message->mutable_payload());
bool success = true;
KioskSessionService_AttemptUserExit_ParamsDataView input_data_view(params, message);
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
KioskSessionService::Name_, 0, false);
return false;
}
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->AttemptUserExit();
return true;
}
case internal::kKioskSessionService_RestartDevice_Name: {
break;
}
}
return false;
}
// static
bool KioskSessionServiceStubDispatch::AcceptWithResponder(
KioskSessionService* 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::kKioskSessionService_AttemptUserExit_Name: {
break;
}
case internal::kKioskSessionService_RestartDevice_Name: {
internal::KioskSessionService_RestartDevice_Params_Data* params =
reinterpret_cast<
internal::KioskSessionService_RestartDevice_Params_Data*>(
message->mutable_payload());
bool success = true;
std::string p_description{};
KioskSessionService_RestartDevice_ParamsDataView input_data_view(params, message);
if (success && !input_data_view.ReadDescription(&p_description))
success = false;
if (!success) {
ReportValidationErrorForMessage(
message,
mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED,
KioskSessionService::Name_, 1, false);
return false;
}
KioskSessionService::RestartDeviceCallback callback =
KioskSessionService_RestartDevice_ProxyToResponder::CreateCallback(
*message, std::move(responder));
// A null |impl| means no implementation was bound.
DCHECK(impl);
impl->RestartDevice(
std::move(p_description), std::move(callback));
return true;
}
}
return false;
}
static const mojo::internal::GenericValidationInfo kKioskSessionServiceValidationInfo[] = {
{&internal::KioskSessionService_AttemptUserExit_Params_Data::Validate,
nullptr /* no response */},
{&internal::KioskSessionService_RestartDevice_Params_Data::Validate,
&internal::KioskSessionService_RestartDevice_ResponseParams_Data::Validate},
};
bool KioskSessionServiceRequestValidator::Accept(mojo::Message* message) {
const char* name = ::crosapi::mojom::KioskSessionService::Name_;
return mojo::internal::ValidateRequestGenericPacked(message, name, kKioskSessionServiceValidationInfo);
}
bool KioskSessionServiceResponseValidator::Accept(mojo::Message* message) {
const char* name = ::crosapi::mojom::KioskSessionService::Name_;
return mojo::internal::ValidateResponseGenericPacked(message, name, kKioskSessionServiceValidationInfo);
}
} // namespace mojom
} // namespace crosapi
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 crosapi {
namespace mojom {
void KioskSessionServiceInterceptorForTesting::AttemptUserExit() {
GetForwardingInterface()->AttemptUserExit();
}
void KioskSessionServiceInterceptorForTesting::RestartDevice(const std::string& description, RestartDeviceCallback callback) {
GetForwardingInterface()->RestartDevice(std::move(description), std::move(callback));
}
KioskSessionServiceAsyncWaiter::KioskSessionServiceAsyncWaiter(
KioskSessionService* proxy) : proxy_(proxy) {}
KioskSessionServiceAsyncWaiter::~KioskSessionServiceAsyncWaiter() = default;
void KioskSessionServiceAsyncWaiter::RestartDevice(
const std::string& description, bool* out_status) {
base::RunLoop loop;
proxy_->RestartDevice(std::move(description),
base::BindOnce(
[](base::RunLoop* loop,
bool* out_status
,
bool status) {*out_status = std::move(status);
loop->Quit();
},
&loop,
out_status));
loop.Run();
}
} // namespace mojom
} // namespace crosapi
#if defined(__clang__)
#pragma clang diagnostic pop
#endif