| // third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.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 "third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.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 "third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.mojom-params-data.h" |
| #include "third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.mojom-shared-message-ids.h" |
| |
| #include "third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.mojom-import-headers.h" |
| #include "third_party/blink/public/mojom/font_unique_name_lookup/font_unique_name_lookup.mojom-test-utils.h" |
| |
| |
| #ifndef THIRD_PARTY_BLINK_PUBLIC_MOJOM_FONT_UNIQUE_NAME_LOOKUP_FONT_UNIQUE_NAME_LOOKUP_MOJOM_JUMBO_H_ |
| #define THIRD_PARTY_BLINK_PUBLIC_MOJOM_FONT_UNIQUE_NAME_LOOKUP_FONT_UNIQUE_NAME_LOOKUP_MOJOM_JUMBO_H_ |
| #endif |
| |
| |
| |
| namespace blink { |
| namespace mojom { |
| const char FontUniqueNameLookup::Name_[] = "blink.mojom.FontUniqueNameLookup"; |
| |
| std::pair<uint32_t, const void*> FontUniqueNameLookup::MessageToMethodInfo_(mojo::Message& message) { |
| switch (message.name()) { |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name: { |
| constexpr uint32_t value = base::MD5Hash32Constexpr( |
| "(Impl)blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable"); |
| #if BUILDFLAG(IS_FUCHSIA) |
| return std::make_pair(value, nullptr); |
| #else |
| return std::make_pair(value, reinterpret_cast<const void*>(&FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable_Sym::IPCSymbol)); |
| #endif // BUILDFLAG(IS_FUCHSIA) |
| } |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name: { |
| constexpr uint32_t value = base::MD5Hash32Constexpr( |
| "(Impl)blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTable"); |
| #if BUILDFLAG(IS_FUCHSIA) |
| return std::make_pair(value, nullptr); |
| #else |
| return std::make_pair(value, reinterpret_cast<const void*>(&FontUniqueNameLookup::GetUniqueNameLookupTable_Sym::IPCSymbol)); |
| #endif // BUILDFLAG(IS_FUCHSIA) |
| } |
| } |
| return std::make_pair(0, nullptr); |
| } |
| |
| |
| const char* FontUniqueNameLookup::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::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name: |
| return "Receive blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable"; |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name: |
| return "Receive blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTable"; |
| } |
| } else { |
| switch (message.name()) { |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name: |
| return "Receive reply blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable"; |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name: |
| return "Receive reply blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTable"; |
| } |
| } |
| 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 FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable_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 FontUniqueNameLookup::GetUniqueNameLookupTable_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) |
| bool FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable(bool* out_sync_available, ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table) { |
| NOTREACHED(); |
| return false; |
| } |
| class FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse |
| : public mojo::MessageReceiver { |
| public: |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse( |
| bool* result, bool* out_sync_available, ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table) |
| : result_(result), out_sync_available_(out_sync_available), out_font_lookup_table_(out_font_lookup_table) { |
| DCHECK(!*result_); |
| } |
| |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse(const FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse&) = delete; |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse& operator=(const FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| bool* result_; |
| bool* out_sync_available_; |
| ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table_;}; |
| |
| class FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback( |
| FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailableCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback(const FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback&) = delete; |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback& operator=(const FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailableCallback callback_; |
| }; |
| |
| class FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback( |
| FontUniqueNameLookup::GetUniqueNameLookupTableCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback(const FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback&) = delete; |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback& operator=(const FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| FontUniqueNameLookup::GetUniqueNameLookupTableCallback callback_; |
| }; |
| |
| FontUniqueNameLookupProxy::FontUniqueNameLookupProxy(mojo::MessageReceiverWithResponder* receiver) |
| : receiver_(receiver) { |
| } |
| bool FontUniqueNameLookupProxy::GetUniqueNameLookupTableIfAvailable( |
| bool* out_param_sync_available, ::base::ReadOnlySharedMemoryRegion* out_param_font_lookup_table) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT_BEGIN0("mojom", "Call blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable (sync)"); |
| #else |
| TRACE_EVENT0("mojom", "FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable"); |
| #endif |
| const bool kExpectsResponse = true; |
| const bool kIsSync = true; |
| 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::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::blink::mojom::internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Params_Data> params( |
| message); |
| params.Allocate(); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(FontUniqueNameLookup::Name_); |
| message.set_method_name("GetUniqueNameLookupTableIfAvailable"); |
| #endif |
| |
| bool result = false; |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse( |
| &result, out_param_sync_available, out_param_font_lookup_table)); |
| ::mojo::internal::SendMessage(*receiver_, message, std::move(responder)); |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT_END1( |
| "mojom", "FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable", "sync_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("sync_available"), out_param_sync_available, |
| "<value of type bool>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("font_lookup_table"), out_param_font_lookup_table, |
| "<value of type ::base::ReadOnlySharedMemoryRegion>"); |
| }); |
| #endif |
| return result; |
| } |
| |
| void FontUniqueNameLookupProxy::GetUniqueNameLookupTableIfAvailable( |
| GetUniqueNameLookupTableIfAvailableCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT0("mojom", "Send blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable"); |
| #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::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::blink::mojom::internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Params_Data> params( |
| message); |
| params.Allocate(); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(FontUniqueNameLookup::Name_); |
| message.set_method_name("GetUniqueNameLookupTableIfAvailable"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMessage(*receiver_, message, std::move(responder)); |
| } |
| |
| void FontUniqueNameLookupProxy::GetUniqueNameLookupTable( |
| GetUniqueNameLookupTableCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT0("mojom", "Send blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTable"); |
| #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::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::blink::mojom::internal::FontUniqueNameLookup_GetUniqueNameLookupTable_Params_Data> params( |
| message); |
| params.Allocate(); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(FontUniqueNameLookup::Name_); |
| message.set_method_name("GetUniqueNameLookupTable"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMessage(*receiver_, message, std::move(responder)); |
| } |
| class FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailableCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder> proxy( |
| new FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_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: |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_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) |
| << "FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailableCallback 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_sync_available, ::base::ReadOnlySharedMemoryRegion in_font_lookup_table); |
| }; |
| |
| bool FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| |
| DCHECK(message->is_serialized()); |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| bool p_sync_available{}; |
| ::base::ReadOnlySharedMemoryRegion p_font_lookup_table{}; |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_sync_available = input_data_view.sync_available(); |
| if (success && !input_data_view.ReadFontLookupTable(&p_font_lookup_table)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| FontUniqueNameLookup::Name_, 0, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_sync_available), |
| std::move(p_font_lookup_table)); |
| return true; |
| } |
| |
| void FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder::Run( |
| bool in_sync_available, ::base::ReadOnlySharedMemoryRegion in_font_lookup_table) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailable", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("sync_available"), in_sync_available, |
| "<value of type bool>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("font_lookup_table"), in_font_lookup_table, |
| "<value of type ::base::ReadOnlySharedMemoryRegion>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::blink::mojom::internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| params->sync_available = in_sync_available; |
| mojo::internal::MessageFragment< |
| typename decltype(params->font_lookup_table)::BaseType> font_lookup_table_fragment( |
| params.message()); |
| mojo::internal::Serialize<::mojo_base::mojom::ReadOnlySharedMemoryRegionDataView>( |
| in_font_lookup_table, font_lookup_table_fragment); |
| params->font_lookup_table.Set( |
| font_lookup_table_fragment.is_null() ? nullptr : font_lookup_table_fragment.data()); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(FontUniqueNameLookup::Name_); |
| message.set_method_name("GetUniqueNameLookupTableIfAvailable"); |
| #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; |
| } |
| bool FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_HandleSyncResponse::Accept( |
| mojo::Message* message) { |
| |
| DCHECK(message->is_serialized()); |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data* params = |
| reinterpret_cast<internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| bool p_sync_available{}; |
| ::base::ReadOnlySharedMemoryRegion p_font_lookup_table{}; |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_sync_available = input_data_view.sync_available(); |
| if (success && !input_data_view.ReadFontLookupTable(&p_font_lookup_table)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| FontUniqueNameLookup::Name_, 0, true); |
| return false; |
| } |
| *out_sync_available_ = std::move(p_sync_available); |
| *out_font_lookup_table_ = std::move(p_font_lookup_table); |
| *result_ = true; |
| return true; |
| } |
| class FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static FontUniqueNameLookup::GetUniqueNameLookupTableCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder> proxy( |
| new FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~FontUniqueNameLookup_GetUniqueNameLookupTable_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: |
| FontUniqueNameLookup_GetUniqueNameLookupTable_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) |
| << "FontUniqueNameLookup::GetUniqueNameLookupTableCallback 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( |
| ::base::ReadOnlySharedMemoryRegion in_font_lookup_table); |
| }; |
| |
| bool FontUniqueNameLookup_GetUniqueNameLookupTable_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| |
| DCHECK(message->is_serialized()); |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTable_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTable_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| ::base::ReadOnlySharedMemoryRegion p_font_lookup_table{}; |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success && !input_data_view.ReadFontLookupTable(&p_font_lookup_table)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| FontUniqueNameLookup::Name_, 1, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_font_lookup_table)); |
| return true; |
| } |
| |
| void FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder::Run( |
| ::base::ReadOnlySharedMemoryRegion in_font_lookup_table) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply blink::mojom::FontUniqueNameLookup::GetUniqueNameLookupTable", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("font_lookup_table"), in_font_lookup_table, |
| "<value of type ::base::ReadOnlySharedMemoryRegion>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::blink::mojom::internal::FontUniqueNameLookup_GetUniqueNameLookupTable_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| mojo::internal::MessageFragment< |
| typename decltype(params->font_lookup_table)::BaseType> font_lookup_table_fragment( |
| params.message()); |
| mojo::internal::Serialize<::mojo_base::mojom::ReadOnlySharedMemoryRegionDataView>( |
| in_font_lookup_table, font_lookup_table_fragment); |
| params->font_lookup_table.Set( |
| font_lookup_table_fragment.is_null() ? nullptr : font_lookup_table_fragment.data()); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(FontUniqueNameLookup::Name_); |
| message.set_method_name("GetUniqueNameLookupTable"); |
| #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 FontUniqueNameLookupStubDispatch::Accept( |
| FontUniqueNameLookup* impl, |
| mojo::Message* message) { |
| switch (message->header()->name) { |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name: { |
| break; |
| } |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name: { |
| break; |
| } |
| } |
| return false; |
| } |
| |
| // static |
| bool FontUniqueNameLookupStubDispatch::AcceptWithResponder( |
| FontUniqueNameLookup* 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::kFontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Name: { |
| |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Params_Data* params = |
| reinterpret_cast< |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Params_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ParamsDataView input_data_view(params, message); |
| |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| FontUniqueNameLookup::Name_, 0, false); |
| return false; |
| } |
| FontUniqueNameLookup::GetUniqueNameLookupTableIfAvailableCallback callback = |
| FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->GetUniqueNameLookupTableIfAvailable(std::move(callback)); |
| return true; |
| } |
| case internal::kFontUniqueNameLookup_GetUniqueNameLookupTable_Name: { |
| |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTable_Params_Data* params = |
| reinterpret_cast< |
| internal::FontUniqueNameLookup_GetUniqueNameLookupTable_Params_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ParamsDataView input_data_view(params, message); |
| |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| FontUniqueNameLookup::Name_, 1, false); |
| return false; |
| } |
| FontUniqueNameLookup::GetUniqueNameLookupTableCallback callback = |
| FontUniqueNameLookup_GetUniqueNameLookupTable_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->GetUniqueNameLookupTable(std::move(callback)); |
| return true; |
| } |
| } |
| return false; |
| } |
| |
| |
| static const mojo::internal::GenericValidationInfo kFontUniqueNameLookupValidationInfo[] = { |
| {&internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_Params_Data::Validate, |
| &internal::FontUniqueNameLookup_GetUniqueNameLookupTableIfAvailable_ResponseParams_Data::Validate}, |
| {&internal::FontUniqueNameLookup_GetUniqueNameLookupTable_Params_Data::Validate, |
| &internal::FontUniqueNameLookup_GetUniqueNameLookupTable_ResponseParams_Data::Validate}, |
| }; |
| |
| bool FontUniqueNameLookupRequestValidator::Accept(mojo::Message* message) { |
| const char* name = ::blink::mojom::FontUniqueNameLookup::Name_; |
| return mojo::internal::ValidateRequestGenericPacked(message, name, kFontUniqueNameLookupValidationInfo); |
| } |
| |
| bool FontUniqueNameLookupResponseValidator::Accept(mojo::Message* message) { |
| const char* name = ::blink::mojom::FontUniqueNameLookup::Name_; |
| return mojo::internal::ValidateResponseGenericPacked(message, name, kFontUniqueNameLookupValidationInfo); |
| } |
| |
| |
| } // namespace mojom |
| } // namespace blink |
| |
| |
| 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 blink { |
| namespace mojom { |
| |
| |
| void FontUniqueNameLookupInterceptorForTesting::GetUniqueNameLookupTableIfAvailable(GetUniqueNameLookupTableIfAvailableCallback callback) { |
| GetForwardingInterface()->GetUniqueNameLookupTableIfAvailable(std::move(callback)); |
| } |
| void FontUniqueNameLookupInterceptorForTesting::GetUniqueNameLookupTable(GetUniqueNameLookupTableCallback callback) { |
| GetForwardingInterface()->GetUniqueNameLookupTable(std::move(callback)); |
| } |
| FontUniqueNameLookupAsyncWaiter::FontUniqueNameLookupAsyncWaiter( |
| FontUniqueNameLookup* proxy) : proxy_(proxy) {} |
| |
| FontUniqueNameLookupAsyncWaiter::~FontUniqueNameLookupAsyncWaiter() = default; |
| |
| void FontUniqueNameLookupAsyncWaiter::GetUniqueNameLookupTableIfAvailable( |
| bool* out_sync_available, ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table) { |
| base::RunLoop loop; |
| proxy_->GetUniqueNameLookupTableIfAvailable( |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| bool* out_sync_available |
| , |
| ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table |
| , |
| bool sync_available, |
| ::base::ReadOnlySharedMemoryRegion font_lookup_table) {*out_sync_available = std::move(sync_available);*out_font_lookup_table = std::move(font_lookup_table); |
| loop->Quit(); |
| }, |
| &loop, |
| out_sync_available, |
| out_font_lookup_table)); |
| loop.Run(); |
| } |
| void FontUniqueNameLookupAsyncWaiter::GetUniqueNameLookupTable( |
| ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table) { |
| base::RunLoop loop; |
| proxy_->GetUniqueNameLookupTable( |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| ::base::ReadOnlySharedMemoryRegion* out_font_lookup_table |
| , |
| ::base::ReadOnlySharedMemoryRegion font_lookup_table) {*out_font_lookup_table = std::move(font_lookup_table); |
| loop->Quit(); |
| }, |
| &loop, |
| out_font_lookup_table)); |
| loop.Run(); |
| } |
| |
| |
| |
| |
| |
| } // namespace mojom |
| } // namespace blink |
| |
| |
| #if defined(__clang__) |
| #pragma clang diagnostic pop |
| #endif |