Skip to content

Commit 65ef8fe

Browse files
Jiawei Lüfacebook-github-bot
authored andcommitted
Revert D72649815: Replace DOMHighResTimeStamp alias in ReactCommon with new abstractions
Differential Revision: D72649815 Original commit changeset: 96bcfaf909d4 Original Phabricator Diff: D72649815 fbshipit-source-id: 491579e20fed41f0f31639f51d6051022ae9de55
1 parent cbfa2ec commit 65ef8fe

38 files changed

+334
-625
lines changed

packages/react-native/ReactCommon/cxxreact/JSExecutor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include "RAMBundleRegistry.h"
1111

1212
#include <jsinspector-modern/ReactCdp.h>
13+
#include <react/timing/primitives.h>
1314

1415
#include <array>
16+
#include <chrono>
1517

1618
namespace facebook::react {
1719

@@ -27,8 +29,8 @@ std::string JSExecutor::getSyntheticBundlePath(
2729
return buffer.data();
2830
}
2931

30-
HighResTimeStamp JSExecutor::performanceNow() {
31-
return HighResTimeStamp::now();
32+
double JSExecutor::performanceNow() {
33+
return chronoToDOMHighResTimeStamp(std::chrono::steady_clock::now());
3234
}
3335

3436
jsinspector_modern::RuntimeTargetDelegate&

packages/react-native/ReactCommon/cxxreact/JSExecutor.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <folly/dynamic.h>
1515
#include <jsinspector-modern/InspectorInterfaces.h>
1616
#include <jsinspector-modern/ReactCdp.h>
17-
#include <react/timing/primitives.h>
1817

1918
#ifndef RN_EXPORT
2019
#define RN_EXPORT __attribute__((visibility("default")))
@@ -139,7 +138,7 @@ class RN_EXPORT JSExecutor {
139138
uint32_t bundleId,
140139
const std::string& bundlePath);
141140

142-
static HighResTimeStamp performanceNow();
141+
static double performanceNow();
143142

144143
/**
145144
* Get a reference to the \c RuntimeTargetDelegate owned (or implemented) by

packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,7 @@ void bindNativePerformanceNow(Runtime& runtime) {
556556
[](jsi::Runtime& runtime,
557557
const jsi::Value&,
558558
const jsi::Value* args,
559-
size_t /*count*/) {
560-
return JSExecutor::performanceNow().toDOMHighResTimeStamp();
561-
}));
559+
size_t count) { return Value(JSExecutor::performanceNow()); }));
562560
}
563561

564562
} // namespace facebook::react

packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void NetworkReporter::reportRequestStart(
7878
int encodedDataLength,
7979
const std::optional<ResponseInfo>& redirectResponse) {
8080
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
81-
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
81+
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
8282

8383
// All builds: Annotate PerformanceResourceTiming metadata
8484
{
@@ -127,7 +127,7 @@ void NetworkReporter::reportRequestStart(
127127

128128
void NetworkReporter::reportConnectionTiming(const std::string& requestId) {
129129
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
130-
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
130+
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
131131

132132
// All builds: Annotate PerformanceResourceTiming metadata
133133
{
@@ -168,7 +168,7 @@ void NetworkReporter::reportResponseStart(
168168
const ResponseInfo& responseInfo,
169169
int encodedDataLength) {
170170
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
171-
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
171+
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
172172

173173
// All builds: Annotate PerformanceResourceTiming metadata
174174
{
@@ -205,7 +205,7 @@ void NetworkReporter::reportResponseStart(
205205

206206
void NetworkReporter::reportDataReceived(const std::string& requestId) {
207207
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
208-
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
208+
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
209209

210210
// All builds: Annotate PerformanceResourceTiming metadata
211211
{
@@ -233,7 +233,7 @@ void NetworkReporter::reportResponseEnd(
233233
const std::string& requestId,
234234
int encodedDataLength) {
235235
if (ReactNativeFeatureFlags::enableResourceTimingAPI()) {
236-
auto now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
236+
double now = PerformanceEntryReporter::getInstance()->getCurrentTimeStamp();
237237

238238
// All builds: Report PerformanceResourceTiming event
239239
{

packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ using FrontendChannel = std::function<void(std::string_view messageJson)>;
3535
*/
3636
struct ResourceTimingData {
3737
std::string url;
38-
HighResTimeStamp fetchStart;
39-
HighResTimeStamp requestStart;
40-
std::optional<HighResTimeStamp> connectStart;
41-
std::optional<HighResTimeStamp> connectEnd;
42-
std::optional<HighResTimeStamp> responseStart;
38+
DOMHighResTimeStamp fetchStart;
39+
DOMHighResTimeStamp requestStart;
40+
std::optional<DOMHighResTimeStamp> connectStart;
41+
std::optional<DOMHighResTimeStamp> connectEnd;
42+
std::optional<DOMHighResTimeStamp> responseStart;
4343
std::optional<int> responseStatus;
4444
};
4545

packages/react-native/ReactCommon/jsinspector-modern/tracing/EventLoopReporter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "EventLoopReporter.h"
99

1010
#if defined(REACT_NATIVE_DEBUGGER_ENABLED)
11-
#include <react/timing/primitives.h>
1211
#include "PerformanceTracer.h"
1312
#endif
1413

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "Timing.h"
1010

1111
#include <oscompat/OSCompat.h>
12-
#include <react/timing/primitives.h>
1312

1413
#include <folly/json.h>
1514

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include <react/timing/primitives.h>
1515

16-
#include <react/timing/primitives.h>
17-
1816
#include <folly/dynamic.h>
1917
#include <functional>
2018
#include <mutex>

packages/react-native/ReactCommon/react/bridging/tests/BridgingTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ TEST_F(BridgingTest, highResTimeStampTest) {
784784
bridging::fromJs<HighResTimeStamp>(
785785
rt, bridging::toJs(rt, timestamp), invoker));
786786

787-
auto duration = HighResDuration::fromNanoseconds(1);
787+
HighResDuration duration = HighResDuration::fromNanoseconds(1);
788788
EXPECT_EQ(
789789
duration,
790790
bridging::fromJs<HighResDuration>(

packages/react-native/ReactCommon/react/nativemodule/intersectionobserver/NativeIntersectionObserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ using NativeIntersectionObserverEntry =
5151
// isIntersectingAboveThresholds
5252
bool,
5353
// time
54-
HighResTimeStamp>;
54+
double>;
5555

5656
template <>
5757
struct Bridging<NativeIntersectionObserverEntry>

0 commit comments

Comments
 (0)