| // 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. |
| |
| #ifndef SERVICES_DEVICE_PUBLIC_INTERFACES_NFC_PROVIDER_MOJOM_BLINK_H_ |
| #define SERVICES_DEVICE_PUBLIC_INTERFACES_NFC_PROVIDER_MOJOM_BLINK_H_ |
| |
| #include <stdint.h> |
| |
| #include <limits> |
| #include <type_traits> |
| #include <utility> |
| |
| #include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/optional.h" |
| |
| #include "mojo/public/cpp/bindings/mojo_features.h" |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| #include "base/trace_event/trace_event.h" |
| #endif |
| #include "mojo/public/cpp/bindings/clone_traits.h" |
| #include "mojo/public/cpp/bindings/equals_traits.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/struct_ptr.h" |
| #include "mojo/public/cpp/bindings/struct_traits.h" |
| #include "mojo/public/cpp/bindings/union_traits.h" |
| #include "services/device/public/interfaces/nfc_provider.mojom-shared.h" |
| #include "services/device/public/interfaces/nfc.mojom-blink.h" |
| |
| #include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h" |
| #include "mojo/public/cpp/bindings/lib/wtf_hash_util.h" |
| #include "third_party/WebKit/Source/platform/mojo/RevocableInterfacePtr.h" |
| #include "third_party/WebKit/Source/platform/wtf/HashFunctions.h" |
| #include "third_party/WebKit/Source/platform/wtf/Optional.h" |
| #include "third_party/WebKit/Source/platform/wtf/text/WTFString.h" |
| |
| #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
| #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| #include "mojo/public/cpp/bindings/interface_ptr.h" |
| #include "mojo/public/cpp/bindings/interface_request.h" |
| #include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
| #include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h" |
| #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" |
| #include "third_party/WebKit/Source/platform/mojo/RevocableInterfacePtr.h" |
| |
| |
| #include "mojo/public/cpp/bindings/lib/native_enum_serialization.h" |
| #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" |
| #include "third_party/WebKit/public/platform/WebCommon.h" |
| |
| |
| namespace device { |
| namespace mojom { |
| namespace blink { |
| class NFCProvider; |
| using NFCProviderPtr = mojo::InterfacePtr<NFCProvider>; |
| using RevocableNFCProviderPtr = ::blink::RevocableInterfacePtr<NFCProvider>; |
| using NFCProviderPtrInfo = mojo::InterfacePtrInfo<NFCProvider>; |
| using ThreadSafeNFCProviderPtr = |
| mojo::ThreadSafeInterfacePtr<NFCProvider>; |
| using NFCProviderRequest = mojo::InterfaceRequest<NFCProvider>; |
| using NFCProviderAssociatedPtr = |
| mojo::AssociatedInterfacePtr<NFCProvider>; |
| using ThreadSafeNFCProviderAssociatedPtr = |
| mojo::ThreadSafeAssociatedInterfacePtr<NFCProvider>; |
| using NFCProviderAssociatedPtrInfo = |
| mojo::AssociatedInterfacePtrInfo<NFCProvider>; |
| using NFCProviderAssociatedRequest = |
| mojo::AssociatedInterfaceRequest<NFCProvider>; |
| |
| |
| class NFCProviderProxy; |
| |
| template <typename ImplRefTraits> |
| class NFCProviderStub; |
| |
| class NFCProviderRequestValidator; |
| |
| class BLINK_PLATFORM_EXPORT NFCProvider |
| : public NFCProviderInterfaceBase { |
| public: |
| static const char Name_[]; |
| static constexpr uint32_t Version_ = 0; |
| static constexpr bool PassesAssociatedKinds_ = false; |
| static constexpr bool HasSyncMethods_ = false; |
| |
| using Proxy_ = NFCProviderProxy; |
| |
| template <typename ImplRefTraits> |
| using Stub_ = NFCProviderStub<ImplRefTraits>; |
| |
| using RequestValidator_ = NFCProviderRequestValidator; |
| using ResponseValidator_ = mojo::PassThroughFilter; |
| enum MethodMinVersions : uint32_t { |
| kGetNFCForHostMinVersion = 0, |
| }; |
| virtual ~NFCProvider() {} |
| |
| virtual void GetNFCForHost(int32_t host_id, ::device::mojom::blink::NFCRequest nfc) = 0; |
| }; |
| class BLINK_PLATFORM_EXPORT NFCProviderInterceptorForTesting : public NFCProvider { |
| virtual NFCProvider* GetForwardingInterface() = 0; |
| void GetNFCForHost(int32_t host_id, ::device::mojom::blink::NFCRequest nfc) override; |
| }; |
| class BLINK_PLATFORM_EXPORT NFCProviderAsyncWaiter { |
| public: |
| explicit NFCProviderAsyncWaiter(NFCProvider* proxy); |
| ~NFCProviderAsyncWaiter(); |
| |
| private: |
| NFCProvider* const proxy_; |
| |
| DISALLOW_COPY_AND_ASSIGN(NFCProviderAsyncWaiter); |
| }; |
| |
| class BLINK_PLATFORM_EXPORT NFCProviderProxy |
| : public NFCProvider { |
| public: |
| explicit NFCProviderProxy(mojo::MessageReceiverWithResponder* receiver); |
| void GetNFCForHost(int32_t host_id, ::device::mojom::blink::NFCRequest nfc) final; |
| |
| private: |
| mojo::MessageReceiverWithResponder* receiver_; |
| }; |
| class BLINK_PLATFORM_EXPORT NFCProviderStubDispatch { |
| public: |
| static bool Accept(NFCProvider* impl, mojo::Message* message); |
| static bool AcceptWithResponder( |
| NFCProvider* impl, |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder); |
| }; |
| |
| template <typename ImplRefTraits = |
| mojo::RawPtrImplRefTraits<NFCProvider>> |
| class NFCProviderStub |
| : public mojo::MessageReceiverWithResponderStatus { |
| public: |
| using ImplPointerType = typename ImplRefTraits::PointerType; |
| |
| NFCProviderStub() {} |
| ~NFCProviderStub() override {} |
| |
| void set_sink(ImplPointerType sink) { sink_ = std::move(sink); } |
| ImplPointerType& sink() { return sink_; } |
| |
| bool Accept(mojo::Message* message) override { |
| if (ImplRefTraits::IsNull(sink_)) |
| return false; |
| return NFCProviderStubDispatch::Accept( |
| ImplRefTraits::GetRawPointer(&sink_), message); |
| } |
| |
| bool AcceptWithResponder( |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override { |
| if (ImplRefTraits::IsNull(sink_)) |
| return false; |
| return NFCProviderStubDispatch::AcceptWithResponder( |
| ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder)); |
| } |
| |
| private: |
| ImplPointerType sink_; |
| }; |
| class BLINK_PLATFORM_EXPORT NFCProviderRequestValidator : public mojo::MessageReceiver { |
| public: |
| bool Accept(mojo::Message* message) override; |
| }; |
| |
| |
| |
| |
| |
| } // namespace blink |
| } // namespace mojom |
| } // namespace device |
| |
| namespace mojo { |
| |
| } // namespace mojo |
| |
| #endif // SERVICES_DEVICE_PUBLIC_INTERFACES_NFC_PROVIDER_MOJOM_BLINK_H_ |