mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Track domain enable/disable bit in shared state across Agents (#42746)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42746 Changelog: [Internal] Formally introduces the concept of "session state" to the modern CDP backend, with the simplest possible implementation: * `PageTargetSession` has a mutable `SessionState` member. * All agents receive the same `SessionState&` in their constructor (with `SessionState`'s lifetime being the caller's responsibility). * It's only legal to read/write to `SessionState` on the thread where requests are handled and Agents are created (the "main" thread). * Agents are expected to play nice and not clobber each other's state in `SessionState`; this is *not* protected with visibility or `const`ness, however. * We'll probably want to come up with some API-level mechanism to control this as the complexity of our agents grows. ## Current use case: `<Domain>.enable` The first use case for session state is to let `PageAgent` manage the `Log.enable` and `Runtime.enable` state for the session. This will allow agents created later in the session (or recreated as part of a reload) to emit Log and Runtime notifications without waiting for additional `enable` messages (that the client is not required to send). We'll likely want to generalise this design to arbitrary domains in some way (e.g. add a top-level domain router that agents register with explicitly?) but I went with the simplest implementation for our current needs. NOTE: The CDP spec doesn't state this explicitly, but it's clear from Chrome's behaviour that a `<Domain>.enable` command is intended to be session-scoped and survive reloads. ## Future use case: Instance/Runtime state persistence The `<Domain>.enable` use case could have been solved with passing *immutable* state to Agents (`const SessionState&`). We make the state mutable in anticipation of `HermesRuntimeAgent` needing to store its own state in the session down the line, which we know is going to be needed in order for breakpoints to survive reloads. Agents that never need to mutate state SHOULD only store this as a const reference. Reviewed By: huntie Differential Revision: D53006916 fbshipit-source-id: a0443c507294faa94efdf25b2f1670129774dc78
This commit is contained in:
committed by
Facebook GitHub Bot
parent
adec8d303b
commit
97723efc8d
@@ -317,8 +317,9 @@ void Instance::JSCallInvoker::scheduleAsync(
|
||||
}
|
||||
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent> Instance::createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) {
|
||||
return nativeToJsBridge_->createRuntimeAgent(frontendChannel);
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) {
|
||||
return nativeToJsBridge_->createRuntimeAgent(frontendChannel, sessionState);
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -153,7 +153,8 @@ class RN_EXPORT Instance : private jsinspector_modern::InstanceTargetDelegate {
|
||||
|
||||
// From InstanceTargetDelegate
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent> createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) override;
|
||||
jsinspector_modern::FrontendChannel channel,
|
||||
jsinspector_modern::SessionState& sessionState) override;
|
||||
|
||||
std::shared_ptr<InstanceCallback> callback_;
|
||||
std::shared_ptr<NativeToJsBridge> nativeToJsBridge_;
|
||||
|
||||
@@ -36,8 +36,10 @@ double JSExecutor::performanceNow() {
|
||||
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent>
|
||||
JSExecutor::createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) {
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) {
|
||||
(void)frontendChannel;
|
||||
(void)sessionState;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <cxxreact/NativeModule.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <jsinspector-modern/InspectorInterfaces.h>
|
||||
#include <jsinspector-modern/RuntimeAgent.h>
|
||||
#include <jsinspector-modern/ReactCdp.h>
|
||||
|
||||
#ifndef RN_EXPORT
|
||||
#define RN_EXPORT __attribute__((visibility("default")))
|
||||
@@ -144,7 +144,8 @@ class RN_EXPORT JSExecutor {
|
||||
* Create a RuntimeAgent that can be used to debug the JS VM instance.
|
||||
*/
|
||||
virtual std::unique_ptr<jsinspector_modern::RuntimeAgent> createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel);
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState);
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -345,8 +345,10 @@ NativeToJsBridge::getDecoratedNativeMethodCallInvoker(
|
||||
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent>
|
||||
NativeToJsBridge::createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) {
|
||||
auto agent = m_executor->createRuntimeAgent(std::move(frontendChannel));
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) {
|
||||
auto agent =
|
||||
m_executor->createRuntimeAgent(std::move(frontendChannel), sessionState);
|
||||
return agent;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <cxxreact/JSExecutor.h>
|
||||
#include <jsinspector-modern/RuntimeAgent.h>
|
||||
#include <jsinspector-modern/ReactCdp.h>
|
||||
|
||||
namespace folly {
|
||||
struct dynamic;
|
||||
@@ -112,7 +112,8 @@ class NativeToJsBridge {
|
||||
* instance.
|
||||
*/
|
||||
virtual std::unique_ptr<jsinspector_modern::RuntimeAgent> createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel);
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState);
|
||||
|
||||
private:
|
||||
// This is used to avoid a race condition where a proxyCallback gets queued
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "InstanceAgent.h"
|
||||
#include "SessionState.h"
|
||||
|
||||
#include <jsinspector-modern/InstanceTarget.h>
|
||||
|
||||
@@ -19,8 +20,9 @@ InstanceTarget::InstanceTarget(InstanceTargetDelegate& delegate)
|
||||
InstanceTargetDelegate::~InstanceTargetDelegate() {}
|
||||
|
||||
std::unique_ptr<InstanceAgent> InstanceTarget::createAgent(
|
||||
FrontendChannel channel) {
|
||||
auto runtimeAgent = delegate_.createRuntimeAgent(channel);
|
||||
FrontendChannel channel,
|
||||
SessionState& sessionState) {
|
||||
auto runtimeAgent = delegate_.createRuntimeAgent(channel, sessionState);
|
||||
return std::make_unique<InstanceAgent>(
|
||||
channel, *this, std::move(runtimeAgent));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SessionState.h"
|
||||
|
||||
#include <jsinspector-modern/InspectorInterfaces.h>
|
||||
#include <jsinspector-modern/RuntimeAgent.h>
|
||||
|
||||
@@ -41,7 +43,8 @@ class InstanceTargetDelegate {
|
||||
* debugging.
|
||||
*/
|
||||
virtual std::unique_ptr<RuntimeAgent> createRuntimeAgent(
|
||||
FrontendChannel channel) = 0;
|
||||
FrontendChannel channel,
|
||||
SessionState& sessionState) = 0;
|
||||
virtual ~InstanceTargetDelegate();
|
||||
};
|
||||
|
||||
@@ -62,7 +65,9 @@ class InstanceTarget {
|
||||
InstanceTarget& operator=(const InstanceTarget&) = delete;
|
||||
InstanceTarget& operator=(InstanceTarget&&) = delete;
|
||||
|
||||
std::unique_ptr<InstanceAgent> createAgent(FrontendChannel channel);
|
||||
std::unique_ptr<InstanceAgent> createAgent(
|
||||
FrontendChannel channel,
|
||||
SessionState& sessionState);
|
||||
|
||||
private:
|
||||
InstanceTargetDelegate& delegate_;
|
||||
|
||||
@@ -32,16 +32,22 @@ static constexpr auto kModernCDPBackendNotice =
|
||||
PageAgent::PageAgent(
|
||||
FrontendChannel frontendChannel,
|
||||
PageTargetController& targetController,
|
||||
PageTarget::SessionMetadata sessionMetadata)
|
||||
PageTarget::SessionMetadata sessionMetadata,
|
||||
SessionState& sessionState)
|
||||
: frontendChannel_(frontendChannel),
|
||||
targetController_(targetController),
|
||||
sessionMetadata_(std::move(sessionMetadata)) {}
|
||||
sessionMetadata_(std::move(sessionMetadata)),
|
||||
sessionState_(sessionState) {}
|
||||
|
||||
void PageAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
bool shouldSendOKResponse = false;
|
||||
bool isFinishedHandlingRequest = false;
|
||||
|
||||
// Domain enable/disable requests: write to state (because we're the top-level
|
||||
// Agent in the Session), trigger any side effects, and decide whether we are
|
||||
// finished handling the request (or need to delegate to the InstanceAgent).
|
||||
if (req.method == "Log.enable") {
|
||||
// Send an "OK" response.
|
||||
frontendChannel_(
|
||||
folly::toJson(folly::dynamic::object("id", req.id)("result", nullptr)));
|
||||
sessionState_.isLogDomainEnabled = true;
|
||||
|
||||
// Send a log entry identifying the modern CDP backend.
|
||||
sendInfoLogEntry(kModernCDPBackendNotice);
|
||||
@@ -51,10 +57,27 @@ void PageAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
sendInfoLogEntry("Integration: " + *sessionMetadata_.integrationName);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = false;
|
||||
} else if (req.method == "Log.disable") {
|
||||
sessionState_.isLogDomainEnabled = false;
|
||||
|
||||
if (req.method == "Page.reload") {
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = false;
|
||||
} else if (req.method == "Runtime.enable") {
|
||||
sessionState_.isRuntimeDomainEnabled = true;
|
||||
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = false;
|
||||
} else if (req.method == "Runtime.disable") {
|
||||
sessionState_.isRuntimeDomainEnabled = false;
|
||||
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = false;
|
||||
}
|
||||
// Methods other than domain enables/disables: handle anything we know how
|
||||
// to handle, and delegate to the InstanceAgent otherwise.
|
||||
else if (req.method == "Page.reload") {
|
||||
targetController_.getDelegate().onReload({
|
||||
.ignoreCache = req.params.isObject() && req.params.count("ignoreCache")
|
||||
? std::optional(req.params.at("ignoreCache").asBool())
|
||||
@@ -64,37 +87,13 @@ void PageAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
? std::optional(req.params.at("scriptToEvaluateOnLoad").asString())
|
||||
: std::nullopt,
|
||||
});
|
||||
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
||||
"result", folly::dynamic::object());
|
||||
std::string json = folly::toJson(res);
|
||||
frontendChannel_(json);
|
||||
return;
|
||||
}
|
||||
|
||||
bool shouldSendOKResponse = false;
|
||||
|
||||
if (req.method == "Runtime.enable") {
|
||||
runtimeEnabled_ = true;
|
||||
|
||||
// Fall through to letting the instance handle this request and send a
|
||||
// response, but remember that we need to send a response in case the
|
||||
// instance doesn't handle the request.
|
||||
shouldSendOKResponse = true;
|
||||
}
|
||||
if (req.method == "Runtime.disable") {
|
||||
runtimeEnabled_ = false;
|
||||
folly::dynamic res = folly::dynamic::object("id", req.id)(
|
||||
"result", folly::dynamic::object());
|
||||
std::string json = folly::toJson(res);
|
||||
frontendChannel_(json);
|
||||
|
||||
// Fall through to letting the instance handle this request and send a
|
||||
// response, but remember that we need to send a response in case the
|
||||
// instance doesn't handle the request.
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = true;
|
||||
}
|
||||
|
||||
if (instanceAgent_ && instanceAgent_->handleRequest(req)) {
|
||||
if (!isFinishedHandlingRequest && instanceAgent_ &&
|
||||
instanceAgent_->handleRequest(req)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,7 +131,7 @@ void PageAgent::setCurrentInstanceAgent(
|
||||
std::unique_ptr<InstanceAgent> instanceAgent) {
|
||||
auto previousInstanceAgent = std::move(instanceAgent_);
|
||||
instanceAgent_ = std::move(instanceAgent);
|
||||
if (!runtimeEnabled_) {
|
||||
if (!sessionState_.isRuntimeDomainEnabled) {
|
||||
return;
|
||||
}
|
||||
if (previousInstanceAgent != nullptr) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "PageTarget.h"
|
||||
#include "SessionState.h"
|
||||
|
||||
#include <jsinspector-modern/InspectorInterfaces.h>
|
||||
#include <jsinspector-modern/InstanceAgent.h>
|
||||
@@ -37,11 +38,14 @@ class PageAgent {
|
||||
* \param targetController An interface to the PageTarget that this agent is
|
||||
* attached to. The caller is responsible for ensuring that the
|
||||
* PageTargetDelegate and underlying PageTarget both outlive the agent.
|
||||
* \param sessionMetadata Metadata about the session that created this agent.
|
||||
* \param sessionState The state of the session that created this agent.
|
||||
*/
|
||||
PageAgent(
|
||||
FrontendChannel frontendChannel,
|
||||
PageTargetController& targetController,
|
||||
PageTarget::SessionMetadata sessionMetadata);
|
||||
PageTarget::SessionMetadata sessionMetadata,
|
||||
SessionState& sessionState);
|
||||
|
||||
/**
|
||||
* Handle a CDP request. The response will be sent over the provided
|
||||
@@ -74,7 +78,12 @@ class PageAgent {
|
||||
PageTargetController& targetController_;
|
||||
const PageTarget::SessionMetadata sessionMetadata_;
|
||||
std::unique_ptr<InstanceAgent> instanceAgent_;
|
||||
bool runtimeEnabled_{false};
|
||||
|
||||
/**
|
||||
* A shared reference to the session's state. This is only safe to access
|
||||
* during handleRequest and other method calls on the same thread.
|
||||
*/
|
||||
SessionState& sessionState_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "InstanceTarget.h"
|
||||
#include "PageAgent.h"
|
||||
#include "Parsing.h"
|
||||
#include "SessionState.h"
|
||||
|
||||
#include <folly/dynamic.h>
|
||||
#include <folly/json.h>
|
||||
@@ -39,7 +40,8 @@ class PageTargetSession {
|
||||
pageAgent_(
|
||||
frontendChannel_,
|
||||
targetController,
|
||||
std::move(sessionMetadata)) {}
|
||||
std::move(sessionMetadata),
|
||||
state_) {}
|
||||
|
||||
/**
|
||||
* Called by CallbackLocalConnection to send a message to this Session's
|
||||
@@ -83,7 +85,7 @@ class PageTargetSession {
|
||||
void setCurrentInstance(InstanceTarget* instance) {
|
||||
if (instance) {
|
||||
pageAgent_.setCurrentInstanceAgent(
|
||||
instance->createAgent(frontendChannel_));
|
||||
instance->createAgent(frontendChannel_, state_));
|
||||
} else {
|
||||
pageAgent_.setCurrentInstanceAgent(nullptr);
|
||||
}
|
||||
@@ -94,6 +96,7 @@ class PageTargetSession {
|
||||
std::shared_ptr<RAIIRemoteConnection> remote_;
|
||||
FrontendChannel frontendChannel_;
|
||||
PageAgent pageAgent_;
|
||||
SessionState state_;
|
||||
};
|
||||
|
||||
PageTarget::PageTarget(PageTargetDelegate& delegate) : delegate_(delegate) {}
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
#include <jsinspector-modern/InstanceTarget.h>
|
||||
#include <jsinspector-modern/PageTarget.h>
|
||||
#include <jsinspector-modern/RuntimeAgent.h>
|
||||
#include <jsinspector-modern/SessionState.h>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 <string_view>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
struct SessionState {
|
||||
public:
|
||||
// TODO: Generalise this to arbitrary domains
|
||||
bool isLogDomainEnabled;
|
||||
bool isRuntimeDomainEnabled;
|
||||
|
||||
// Here, we will eventually allow RuntimeAgents to store their own arbitrary
|
||||
// state (e.g. some sort of K/V storage of folly::dynamic?)
|
||||
|
||||
// TODO: Figure out a good model for restricting write access / preventing
|
||||
// agents from unintentionally clobbering each other's state.
|
||||
};
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
@@ -127,14 +127,17 @@ class MockInstanceTargetDelegate : public InstanceTargetDelegate {
|
||||
MOCK_METHOD(
|
||||
std::unique_ptr<RuntimeAgent>,
|
||||
createRuntimeAgent,
|
||||
(FrontendChannel channel),
|
||||
(FrontendChannel channel, SessionState& sessionState),
|
||||
(override));
|
||||
};
|
||||
|
||||
class MockRuntimeAgent : public RuntimeAgent {
|
||||
public:
|
||||
inline MockRuntimeAgent(FrontendChannel frontendChannel)
|
||||
: frontendChannel(std::move(frontendChannel)) {}
|
||||
inline MockRuntimeAgent(
|
||||
FrontendChannel frontendChannel,
|
||||
SessionState& sessionState)
|
||||
: frontendChannel(std::move(frontendChannel)),
|
||||
sessionState(sessionState) {}
|
||||
|
||||
// RuntimeAgent methods
|
||||
MOCK_METHOD(
|
||||
@@ -144,6 +147,7 @@ class MockRuntimeAgent : public RuntimeAgent {
|
||||
(override));
|
||||
|
||||
const FrontendChannel frontendChannel;
|
||||
SessionState& sessionState;
|
||||
};
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace {
|
||||
class PageTargetTest : public Test {
|
||||
protected:
|
||||
PageTargetTest() {
|
||||
EXPECT_CALL(instanceTargetDelegate_, createRuntimeAgent(_))
|
||||
.WillRepeatedly(runtimeAgents_.lazily_make_unique<FrontendChannel>());
|
||||
EXPECT_CALL(instanceTargetDelegate_, createRuntimeAgent(_, _))
|
||||
.WillRepeatedly(
|
||||
runtimeAgents_
|
||||
.lazily_make_unique<FrontendChannel, SessionState&>());
|
||||
}
|
||||
|
||||
void connect() {
|
||||
@@ -133,12 +135,6 @@ TEST_F(PageTargetProtocolTest, MalformedJson) {
|
||||
TEST_F(PageTargetProtocolTest, InjectLogsToIdentifyBackend) {
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
||||
"id": 1,
|
||||
"result": null
|
||||
})")))
|
||||
.RetiresOnSaturation();
|
||||
|
||||
EXPECT_CALL(
|
||||
fromPage(),
|
||||
onMessage(JsonParsed(AllOf(
|
||||
@@ -146,6 +142,11 @@ TEST_F(PageTargetProtocolTest, InjectLogsToIdentifyBackend) {
|
||||
AtJsonPtr("/params/entry", Not(IsEmpty()))))))
|
||||
.Times(2)
|
||||
.RetiresOnSaturation();
|
||||
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
||||
"id": 1,
|
||||
"result": {}
|
||||
})")))
|
||||
.RetiresOnSaturation();
|
||||
toPage_->sendMessage(R"({
|
||||
"id": 1,
|
||||
"method": "Log.enable"
|
||||
@@ -385,7 +386,7 @@ TEST_F(PageTargetProtocolTest, MessageRoutingWhileNoRuntimeAgent) {
|
||||
TEST_F(PageTargetProtocolTest, InstanceWithNullRuntimeAgent) {
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(instanceTargetDelegate_, createRuntimeAgent(_))
|
||||
EXPECT_CALL(instanceTargetDelegate_, createRuntimeAgent(_, _))
|
||||
.WillRepeatedly(ReturnNull());
|
||||
|
||||
auto& instanceTarget = page_.registerInstance(instanceTargetDelegate_);
|
||||
@@ -406,4 +407,41 @@ TEST_F(PageTargetProtocolTest, InstanceWithNullRuntimeAgent) {
|
||||
page_.unregisterInstance(instanceTarget);
|
||||
}
|
||||
|
||||
TEST_F(PageTargetProtocolTest, RuntimeAgentHasAccessToSessionState) {
|
||||
InSequence s;
|
||||
|
||||
// Send Runtime.enable before registering the Instance (which in turns creates
|
||||
// the RuntimeAgent).
|
||||
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
||||
"id": 1,
|
||||
"result": {}
|
||||
})")));
|
||||
toPage_->sendMessage(R"({
|
||||
"id": 1,
|
||||
"method": "Runtime.enable"
|
||||
})");
|
||||
|
||||
page_.registerInstance(instanceTargetDelegate_);
|
||||
ASSERT_TRUE(runtimeAgents_[0]);
|
||||
|
||||
EXPECT_TRUE(runtimeAgents_[0]->sessionState.isRuntimeDomainEnabled);
|
||||
|
||||
// Send Runtime.disable while the RuntimeAgent exists - it receives the
|
||||
// message and can also observe the updated state.
|
||||
EXPECT_CALL(*runtimeAgents_[0], handleRequest(Eq(cdp::preparse(R"({
|
||||
"id": 2,
|
||||
"method": "Runtime.disable"
|
||||
})"))));
|
||||
EXPECT_CALL(fromPage(), onMessage(JsonEq(R"({
|
||||
"id": 2,
|
||||
"result": {}
|
||||
})")));
|
||||
toPage_->sendMessage(R"({
|
||||
"id": 2,
|
||||
"method": "Runtime.disable"
|
||||
})");
|
||||
|
||||
EXPECT_FALSE(runtimeAgents_[0]->sessionState.isRuntimeDomainEnabled);
|
||||
}
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
|
||||
@@ -20,8 +20,10 @@ JSIRuntimeHolder::JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime)
|
||||
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent>
|
||||
JSIRuntimeHolder::createInspectorAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) {
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) {
|
||||
(void)frontendChannel;
|
||||
(void)sessionState;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ class JSRuntime {
|
||||
* \see InspectorTargetDelegate::createRuntimeAgent
|
||||
*/
|
||||
virtual std::unique_ptr<jsinspector_modern::RuntimeAgent>
|
||||
createInspectorAgent(jsinspector_modern::FrontendChannel frontendChannel) = 0;
|
||||
createInspectorAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) = 0;
|
||||
|
||||
virtual ~JSRuntime() = default;
|
||||
};
|
||||
@@ -50,7 +52,8 @@ class JSIRuntimeHolder : public JSRuntime {
|
||||
public:
|
||||
jsi::Runtime& getRuntime() noexcept override;
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent> createInspectorAgent(
|
||||
jsinspector_modern::FrontendChannel frontendChannel) override;
|
||||
jsinspector_modern::FrontendChannel frontendChannel,
|
||||
jsinspector_modern::SessionState& sessionState) override;
|
||||
|
||||
explicit JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime);
|
||||
|
||||
|
||||
@@ -461,8 +461,10 @@ void ReactInstance::handleMemoryPressureJs(int pressureLevel) {
|
||||
}
|
||||
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent>
|
||||
ReactInstance::createRuntimeAgent(jsinspector_modern::FrontendChannel channel) {
|
||||
auto agent = runtime_->createInspectorAgent(std::move(channel));
|
||||
ReactInstance::createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel channel,
|
||||
jsinspector_modern::SessionState& sessionState) {
|
||||
auto agent = runtime_->createInspectorAgent(std::move(channel), sessionState);
|
||||
return agent;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ class ReactInstance final : private jsinspector_modern::InstanceTargetDelegate {
|
||||
void unregisterFromInspector();
|
||||
|
||||
private:
|
||||
// From InstanceTargetDelegate
|
||||
std::unique_ptr<jsinspector_modern::RuntimeAgent> createRuntimeAgent(
|
||||
jsinspector_modern::FrontendChannel channel) override;
|
||||
jsinspector_modern::FrontendChannel channel,
|
||||
jsinspector_modern::SessionState& sessionState) override;
|
||||
|
||||
std::shared_ptr<JSRuntime> runtime_;
|
||||
std::shared_ptr<MessageQueueThread> jsMessageQueueThread_;
|
||||
|
||||
Reference in New Issue
Block a user