| // 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_GEOLOCATION_CONTEXT_MOJOM_H_ |
| #define SERVICES_DEVICE_PUBLIC_INTERFACES_GEOLOCATION_CONTEXT_MOJOM_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/geolocation_context.mojom-shared.h" |
| #include "services/device/public/interfaces/geolocation.mojom.h" |
| #include "services/device/public/interfaces/geoposition.mojom.h" |
| #include <string> |
| #include <vector> |
| |
| #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 "mojo/public/cpp/bindings/lib/native_enum_serialization.h" |
| #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" |
| |
| |
| namespace device { |
| namespace mojom { |
| class GeolocationContext; |
| using GeolocationContextPtr = mojo::InterfacePtr<GeolocationContext>; |
| using GeolocationContextPtrInfo = mojo::InterfacePtrInfo<GeolocationContext>; |
| using ThreadSafeGeolocationContextPtr = |
| mojo::ThreadSafeInterfacePtr<GeolocationContext>; |
| using GeolocationContextRequest = mojo::InterfaceRequest<GeolocationContext>; |
| using GeolocationContextAssociatedPtr = |
| mojo::AssociatedInterfacePtr<GeolocationContext>; |
| using ThreadSafeGeolocationContextAssociatedPtr = |
| mojo::ThreadSafeAssociatedInterfacePtr<GeolocationContext>; |
| using GeolocationContextAssociatedPtrInfo = |
| mojo::AssociatedInterfacePtrInfo<GeolocationContext>; |
| using GeolocationContextAssociatedRequest = |
| mojo::AssociatedInterfaceRequest<GeolocationContext>; |
| |
| |
| class GeolocationContextProxy; |
| |
| template <typename ImplRefTraits> |
| class GeolocationContextStub; |
| |
| class GeolocationContextRequestValidator; |
| |
| class GeolocationContext |
| : public GeolocationContextInterfaceBase { |
| public: |
| static const char Name_[]; |
| static constexpr uint32_t Version_ = 0; |
| static constexpr bool PassesAssociatedKinds_ = false; |
| static constexpr bool HasSyncMethods_ = false; |
| |
| using Proxy_ = GeolocationContextProxy; |
| |
| template <typename ImplRefTraits> |
| using Stub_ = GeolocationContextStub<ImplRefTraits>; |
| |
| using RequestValidator_ = GeolocationContextRequestValidator; |
| using ResponseValidator_ = mojo::PassThroughFilter; |
| enum MethodMinVersions : uint32_t { |
| kBindGeolocationMinVersion = 0, |
| kSetOverrideMinVersion = 0, |
| kClearOverrideMinVersion = 0, |
| }; |
| virtual ~GeolocationContext() {} |
| |
| virtual void BindGeolocation(::device::mojom::GeolocationRequest request) = 0; |
| |
| virtual void SetOverride(::device::mojom::GeopositionPtr geoposition) = 0; |
| |
| virtual void ClearOverride() = 0; |
| }; |
| class GeolocationContextInterceptorForTesting : public GeolocationContext { |
| virtual GeolocationContext* GetForwardingInterface() = 0; |
| void BindGeolocation(::device::mojom::GeolocationRequest request) override; |
| void SetOverride(::device::mojom::GeopositionPtr geoposition) override; |
| void ClearOverride() override; |
| }; |
| class GeolocationContextAsyncWaiter { |
| public: |
| explicit GeolocationContextAsyncWaiter(GeolocationContext* proxy); |
| ~GeolocationContextAsyncWaiter(); |
| |
| private: |
| GeolocationContext* const proxy_; |
| |
| DISALLOW_COPY_AND_ASSIGN(GeolocationContextAsyncWaiter); |
| }; |
| |
| class GeolocationContextProxy |
| : public GeolocationContext { |
| public: |
| explicit GeolocationContextProxy(mojo::MessageReceiverWithResponder* receiver); |
| void BindGeolocation(::device::mojom::GeolocationRequest request) final; |
| void SetOverride(::device::mojom::GeopositionPtr geoposition) final; |
| void ClearOverride() final; |
| |
| private: |
| mojo::MessageReceiverWithResponder* receiver_; |
| }; |
| class GeolocationContextStubDispatch { |
| public: |
| static bool Accept(GeolocationContext* impl, mojo::Message* message); |
| static bool AcceptWithResponder( |
| GeolocationContext* impl, |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder); |
| }; |
| |
| template <typename ImplRefTraits = |
| mojo::RawPtrImplRefTraits<GeolocationContext>> |
| class GeolocationContextStub |
| : public mojo::MessageReceiverWithResponderStatus { |
| public: |
| using ImplPointerType = typename ImplRefTraits::PointerType; |
| |
| GeolocationContextStub() {} |
| ~GeolocationContextStub() 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 GeolocationContextStubDispatch::Accept( |
| ImplRefTraits::GetRawPointer(&sink_), message); |
| } |
| |
| bool AcceptWithResponder( |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override { |
| if (ImplRefTraits::IsNull(sink_)) |
| return false; |
| return GeolocationContextStubDispatch::AcceptWithResponder( |
| ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder)); |
| } |
| |
| private: |
| ImplPointerType sink_; |
| }; |
| class GeolocationContextRequestValidator : public mojo::MessageReceiver { |
| public: |
| bool Accept(mojo::Message* message) override; |
| }; |
| |
| |
| |
| |
| |
| } // namespace mojom |
| } // namespace device |
| |
| namespace mojo { |
| |
| } // namespace mojo |
| |
| #endif // SERVICES_DEVICE_PUBLIC_INTERFACES_GEOLOCATION_CONTEXT_MOJOM_H_ |