mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Implement Network.loadingFailed (#53023)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53023 Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D79555222 fbshipit-source-id: bfbe36edc867b1fc7a44d8e998489ef1d8896331
This commit is contained in:
1 parent
ea50245e1e
commit
fa66e314b2
4 files changed
+25
No files matched your search
+7
@@ -82,6 +82,13 @@ internal object InspectorNetworkReporter {
|
||||
*/
|
||||
@JvmStatic external fun reportResponseEnd(requestId: Int, encodedDataLength: Long)
|
||||
|
||||
/**
|
||||
* Report when a network request has failed.
|
||||
*
|
||||
* Corresponds to `Network.loadingFailed` in CDP.
|
||||
*/
|
||||
@JvmStatic external fun reportRequestFailed(requestId: Int, cancelled: Boolean)
|
||||
|
||||
/**
|
||||
* Store response body preview. This is an optional reporting method, and is a no-op if CDP
|
||||
* debugging is disabled.
|
||||
|
||||
+3
@@ -141,6 +141,9 @@ internal object NetworkEventUtil {
|
||||
error: String?,
|
||||
e: Throwable?
|
||||
) {
|
||||
if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
||||
InspectorNetworkReporter.reportRequestFailed(requestId, false)
|
||||
}
|
||||
reactContext?.emitDeviceEvent(
|
||||
"didCompleteNetworkResponse",
|
||||
buildReadableArray {
|
||||
|
||||
+10
@@ -134,6 +134,14 @@ static std::unordered_map<int, std::string> responseBuffers;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ void InspectorNetworkReporter::reportRequestFailed(
|
||||
jni::alias_ref<jclass> /*unused*/,
|
||||
jint requestId,
|
||||
jboolean cancelled) {
|
||||
NetworkReporter::getInstance().reportRequestFailed(
|
||||
std::to_string(requestId), cancelled);
|
||||
}
|
||||
|
||||
/* static */ void InspectorNetworkReporter::maybeStoreResponseBodyImpl(
|
||||
jni::alias_ref<jclass> /*unused*/,
|
||||
jint requestId,
|
||||
@@ -184,6 +192,8 @@ InspectorNetworkReporter::maybeStoreResponseBodyIncrementalImpl(
|
||||
InspectorNetworkReporter::reportDataReceivedImpl),
|
||||
makeNativeMethod(
|
||||
"reportResponseEnd", InspectorNetworkReporter::reportResponseEnd),
|
||||
makeNativeMethod(
|
||||
"reportRequestFailed", InspectorNetworkReporter::reportRequestFailed),
|
||||
makeNativeMethod(
|
||||
"maybeStoreResponseBodyImpl",
|
||||
InspectorNetworkReporter::maybeStoreResponseBodyImpl),
|
||||
|
||||
@@ -51,6 +51,11 @@ class InspectorNetworkReporter
|
||||
jint requestId,
|
||||
jlong encodedDataLength);
|
||||
|
||||
static void reportRequestFailed(
|
||||
jni::alias_ref<jclass> /*unused*/,
|
||||
jint requestId,
|
||||
jboolean cancelled);
|
||||
|
||||
static void maybeStoreResponseBodyImpl(
|
||||
jni::alias_ref<jclass> /*unused*/,
|
||||
jint requestId,
|
||||
|
||||
Reference in new issue
Block a user