mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
API symmetry when passing PerformanceEntryType to/from native module
Summary: [Changelog][Internal] `NativePerformanceObserver` TurboModule API would get the type for performance entries as strings in one direction (`start/stopReporting`) and as integers in another direction (inside `RawPerformanceEntry`, for optimization on the native side). This makes is symmetrical and consistent, all the conversions are now handled on the JS side. Reviewed By: christophpurrer Differential Revision: D43236466 fbshipit-source-id: 08e1b62df90e6d26a11577d6b6b1d91a6bce8339
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e168db4c3b
commit
aef7194996
@@ -10,19 +10,6 @@
|
||||
|
||||
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)) {
|
||||
@@ -35,16 +22,16 @@ NativePerformanceObserver::~NativePerformanceObserver() {
|
||||
|
||||
void NativePerformanceObserver::startReporting(
|
||||
jsi::Runtime &rt,
|
||||
std::string entryType) {
|
||||
int32_t entryType) {
|
||||
PerformanceEntryReporter::getInstance().startReporting(
|
||||
stringToPerformanceEntryType(entryType));
|
||||
static_cast<PerformanceEntryType>(entryType));
|
||||
}
|
||||
|
||||
void NativePerformanceObserver::stopReporting(
|
||||
jsi::Runtime &rt,
|
||||
std::string entryType) {
|
||||
int32_t entryType) {
|
||||
PerformanceEntryReporter::getInstance().stopReporting(
|
||||
stringToPerformanceEntryType(entryType));
|
||||
static_cast<PerformanceEntryType>(entryType));
|
||||
}
|
||||
|
||||
GetPendingEntriesResult NativePerformanceObserver::popPendingEntries(
|
||||
|
||||
Reference in New Issue
Block a user