mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3aea05651d
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35771 [Changelog][Internal] Based on the internal discussion, we don't want to report `first-input` event types for RN (just use plain `event` instead), in the way that [Event Timing API standard suggests](https://www.w3.org/TR/event-timing), as this is doesn't have that clear semantics in the context of RN, also to keep it simpler. Reviewed By: rubennorte Differential Revision: D42341923 fbshipit-source-id: eff2487dee17ef082604e4c807b4d41485328114
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#include "NativePerformanceObserver.h"
|
|
#include "PerformanceEntryReporter.h"
|
|
|
|
namespace facebook::react {
|
|
|
|
static PerformanceEntryType stringToPerformanceEntryType(
|
|
const std::string &entryType) {
|
|
if (entryType == "mark") {
|
|
return PerformanceEntryType::MARK;
|
|
} else if (entryType == "measure") {
|
|
return PerformanceEntryType::MEASURE;
|
|
} else if (entryType == "event") {
|
|
return PerformanceEntryType::EVENT;
|
|
} else {
|
|
return PerformanceEntryType::UNDEFINED;
|
|
}
|
|
}
|
|
|
|
NativePerformanceObserver::NativePerformanceObserver(
|
|
std::shared_ptr<CallInvoker> jsInvoker)
|
|
: NativePerformanceObserverCxxSpec(std::move(jsInvoker)) {
|
|
setEventLogger(&PerformanceEntryReporter::getInstance());
|
|
}
|
|
|
|
NativePerformanceObserver::~NativePerformanceObserver() {
|
|
setEventLogger(nullptr);
|
|
}
|
|
|
|
void NativePerformanceObserver::startReporting(
|
|
jsi::Runtime &rt,
|
|
std::string entryType) {
|
|
PerformanceEntryReporter::getInstance().startReporting(
|
|
stringToPerformanceEntryType(entryType));
|
|
}
|
|
|
|
void NativePerformanceObserver::stopReporting(
|
|
jsi::Runtime &rt,
|
|
std::string entryType) {
|
|
PerformanceEntryReporter::getInstance().stopReporting(
|
|
stringToPerformanceEntryType(entryType));
|
|
}
|
|
|
|
GetPendingEntriesResult NativePerformanceObserver::popPendingEntries(
|
|
jsi::Runtime &rt) {
|
|
return PerformanceEntryReporter::getInstance().popPendingEntries();
|
|
}
|
|
|
|
void NativePerformanceObserver::setOnPerformanceEntryCallback(
|
|
jsi::Runtime &rt,
|
|
std::optional<AsyncCallback<>> callback) {
|
|
PerformanceEntryReporter::getInstance().setReportingCallback(callback);
|
|
}
|
|
|
|
} // namespace facebook::react
|