/* * 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 namespace facebook::react { class PerformanceEntryReporter; #pragma mark - Structs using RawPerformanceEntry = NativePerformanceObserverCxxBaseRawPerformanceEntry< std::string, int32_t, double, double, // For "event" entries only: std::optional, std::optional, std::optional>; template <> struct Bridging : NativePerformanceObserverCxxBaseRawPerformanceEntryBridging< std::string, int32_t, double, double, std::optional, std::optional, std::optional> {}; using GetPendingEntriesResult = NativePerformanceObserverCxxBaseGetPendingEntriesResult< std::vector, uint32_t>; template <> struct Bridging : NativePerformanceObserverCxxBaseGetPendingEntriesResultBridging< std::vector, uint32_t> {}; #pragma mark - implementation class NativePerformanceObserver : public NativePerformanceObserverCxxSpec, std::enable_shared_from_this { public: NativePerformanceObserver(std::shared_ptr jsInvoker); ~NativePerformanceObserver(); void startReporting(jsi::Runtime &rt, int32_t entryType); void stopReporting(jsi::Runtime &rt, int32_t entryType); GetPendingEntriesResult popPendingEntries(jsi::Runtime &rt); void setOnPerformanceEntryCallback( jsi::Runtime &rt, std::optional> callback); void logRawEntry(jsi::Runtime &rt, RawPerformanceEntry entry); std::vector> getEventCounts( jsi::Runtime &rt); void setDurationThreshold( jsi::Runtime &rt, int32_t entryType, double durationThreshold); void clearEntries( jsi::Runtime &rt, int32_t entryType, std::optional entryName); std::vector getEntries( jsi::Runtime &rt, std::optional entryType, std::optional entryName); private: }; } // namespace facebook::react