mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Apply clang-tidy setting: jsinspectormodern (#52741)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52741 Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D78634934 fbshipit-source-id: 03c4c8f5287452fb19fdce69e93686a04525eba5
This commit is contained in:
1 parent
70f7a50e2f
commit
546e27684e
21 files changed
+105
-83
No files matched your search
+9
-8
@@ -14,9 +14,10 @@
|
||||
|
||||
#include <jsinspector-modern/InspectorInterfaces.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::hermes::inspector_modern::chrome {
|
||||
|
||||
using ::facebook::react::jsinspector_modern::IInspector;
|
||||
using ::facebook::react::jsinspector_modern::ILocalConnection;
|
||||
using ::facebook::react::jsinspector_modern::IRemoteConnection;
|
||||
|
||||
@@ -27,7 +28,7 @@ class LocalConnection : public ILocalConnection {
|
||||
LocalConnection(
|
||||
std::shared_ptr<hermes::inspector_modern::chrome::CDPHandler> conn,
|
||||
std::shared_ptr<std::unordered_set<std::string>> inspectedContexts);
|
||||
~LocalConnection();
|
||||
~LocalConnection() override;
|
||||
|
||||
void sendMessage(std::string message) override;
|
||||
void disconnect() override;
|
||||
@@ -40,14 +41,14 @@ class LocalConnection : public ILocalConnection {
|
||||
LocalConnection::LocalConnection(
|
||||
std::shared_ptr<hermes::inspector_modern::chrome::CDPHandler> conn,
|
||||
std::shared_ptr<std::unordered_set<std::string>> inspectedContexts)
|
||||
: conn_(conn), inspectedContexts_(inspectedContexts) {
|
||||
: conn_(conn), inspectedContexts_(std::move(inspectedContexts)) {
|
||||
inspectedContexts_->insert(conn->getTitle());
|
||||
}
|
||||
|
||||
LocalConnection::~LocalConnection() = default;
|
||||
|
||||
void LocalConnection::sendMessage(std::string str) {
|
||||
conn_->handle(std::move(str));
|
||||
void LocalConnection::sendMessage(std::string message) {
|
||||
conn_->handle(std::move(message));
|
||||
}
|
||||
|
||||
void LocalConnection::disconnect() {
|
||||
@@ -76,9 +77,9 @@ DebugSessionToken ConnectionDemux::enableDebugging(
|
||||
// register the new CS VM instance, check for any previous CS VM (via strcmp
|
||||
// of title) and remove them.
|
||||
std::vector<int> pagesToDelete;
|
||||
for (auto it = conns_.begin(); it != conns_.end(); ++it) {
|
||||
if (it->second->getTitle() == title) {
|
||||
pagesToDelete.push_back(it->first);
|
||||
for (auto& conn : conns_) {
|
||||
if (conn.second->getTitle() == title) {
|
||||
pagesToDelete.push_back(conn.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -14,6 +14,8 @@
|
||||
#include <hermes/hermes.h>
|
||||
#include <jsinspector-modern/ReactCdp.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace facebook::hermes;
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
@@ -25,7 +27,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate {
|
||||
explicit HermesStateWrapper(HermesState state) : state_(std::move(state)) {}
|
||||
|
||||
static HermesState unwrapDestructively(ExportedState* wrapper) {
|
||||
if (!wrapper) {
|
||||
if (wrapper == nullptr) {
|
||||
return {};
|
||||
}
|
||||
if (auto* typedWrapper = dynamic_cast<HermesStateWrapper*>(wrapper)) {
|
||||
@@ -58,7 +60,7 @@ class HermesRuntimeAgentDelegate::Impl final : public RuntimeAgentDelegate {
|
||||
runtimeExecutor(
|
||||
[&runtime, fn = std::move(fn)](auto&) { fn(runtime); });
|
||||
},
|
||||
frontendChannel,
|
||||
std::move(frontendChannel),
|
||||
HermesStateWrapper::unwrapDestructively(
|
||||
previouslyExportedState.get()))) {
|
||||
if (sessionState.isRuntimeDomainEnabled) {
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using namespace std::chrono;
|
||||
using namespace std::literals::string_view_literals;
|
||||
@@ -26,7 +27,8 @@ FallbackRuntimeAgentDelegate::FallbackRuntimeAgentDelegate(
|
||||
FrontendChannel frontendChannel,
|
||||
const SessionState& sessionState,
|
||||
std::string engineDescription)
|
||||
: frontendChannel_(frontendChannel), engineDescription_(engineDescription) {
|
||||
: frontendChannel_(std::move(frontendChannel)),
|
||||
engineDescription_(std::move(engineDescription)) {
|
||||
if (sessionState.isLogDomainEnabled) {
|
||||
sendFallbackRuntimeWarning();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <folly/json.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
@@ -180,7 +181,7 @@ HostTarget::~HostTarget() {
|
||||
"HostTargetSession objects must be destroyed before their HostTarget. Did you call getInspectorInstance().removePage()?");
|
||||
}
|
||||
|
||||
HostTargetDelegate::~HostTargetDelegate() {}
|
||||
HostTargetDelegate::~HostTargetDelegate() = default;
|
||||
|
||||
InstanceTarget& HostTarget::registerInstance(InstanceTargetDelegate& delegate) {
|
||||
assert(!currentInstance_ && "Only one instance allowed");
|
||||
|
||||
@@ -10,17 +10,18 @@
|
||||
#include <cassert>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
// pure destructors in C++ are odd. You would think they don't want an
|
||||
// implementation, but in fact the linker requires one. Define them to be
|
||||
// empty so that people don't count on them for any particular behaviour.
|
||||
IDestructible::~IDestructible() {}
|
||||
ILocalConnection::~ILocalConnection() {}
|
||||
IRemoteConnection::~IRemoteConnection() {}
|
||||
IInspector::~IInspector() {}
|
||||
IPageStatusListener::~IPageStatusListener() {}
|
||||
IDestructible::~IDestructible() = default;
|
||||
ILocalConnection::~ILocalConnection() = default;
|
||||
IRemoteConnection::~IRemoteConnection() = default;
|
||||
IInspector::~IInspector() = default;
|
||||
IPageStatusListener::~IPageStatusListener() = default;
|
||||
|
||||
folly::dynamic targetCapabilitiesToDynamic(
|
||||
const InspectorTargetCapabilities& capabilities) {
|
||||
@@ -54,8 +55,8 @@ class InspectorImpl : public IInspector {
|
||||
public:
|
||||
Page(
|
||||
int id,
|
||||
const std::string& description,
|
||||
const std::string& vm,
|
||||
std::string description,
|
||||
std::string vm,
|
||||
ConnectFunc connectFunc,
|
||||
InspectorTargetCapabilities capabilities);
|
||||
operator InspectorPageDescription() const;
|
||||
@@ -77,13 +78,13 @@ class InspectorImpl : public IInspector {
|
||||
|
||||
InspectorImpl::Page::Page(
|
||||
int id,
|
||||
const std::string& description,
|
||||
const std::string& vm,
|
||||
std::string description,
|
||||
std::string vm,
|
||||
ConnectFunc connectFunc,
|
||||
InspectorTargetCapabilities capabilities)
|
||||
: id_(id),
|
||||
description_(description),
|
||||
vm_(vm),
|
||||
description_(std::move(description)),
|
||||
vm_(std::move(vm)),
|
||||
connectFunc_(std::move(connectFunc)),
|
||||
capabilities_(capabilities) {}
|
||||
|
||||
@@ -122,7 +123,7 @@ void InspectorImpl::removePage(int pageId) {
|
||||
std::scoped_lock lock(mutex_);
|
||||
|
||||
if (pages_.erase(pageId) != 0) {
|
||||
for (auto& listenerWeak : listeners_) {
|
||||
for (const auto& listenerWeak : listeners_) {
|
||||
if (auto listener = listenerWeak.lock()) {
|
||||
listener->onPageRemoved(pageId);
|
||||
}
|
||||
|
||||
+23
-13
@@ -14,6 +14,7 @@
|
||||
#include <glog/logging.h>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <utility>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
@@ -34,7 +35,10 @@ InspectorPackagerConnection::Impl::create(
|
||||
// No make_shared because the constructor is private
|
||||
std::shared_ptr<InspectorPackagerConnection::Impl> impl(
|
||||
new InspectorPackagerConnection::Impl(
|
||||
url, deviceName, appName, std::move(delegate)));
|
||||
std::move(url),
|
||||
std::move(deviceName),
|
||||
std::move(appName),
|
||||
std::move(delegate)));
|
||||
getInspectorInstance().registerPageStatusListener(impl);
|
||||
return impl;
|
||||
}
|
||||
@@ -50,7 +54,7 @@ InspectorPackagerConnection::Impl::Impl(
|
||||
delegate_(std::move(delegate)) {}
|
||||
|
||||
void InspectorPackagerConnection::Impl::handleProxyMessage(
|
||||
folly::const_dynamic_view message) {
|
||||
const folly::const_dynamic_view& message) {
|
||||
std::string event = message.descend("event").string_or(INVALID);
|
||||
if (event == "getPages") {
|
||||
sendToPackager(
|
||||
@@ -67,7 +71,7 @@ void InspectorPackagerConnection::Impl::handleProxyMessage(
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::sendEventToAllConnections(
|
||||
std::string event) {
|
||||
const std::string& event) {
|
||||
for (auto& connection : inspectorSessions_) {
|
||||
connection.second.localConnection->sendMessage(event);
|
||||
}
|
||||
@@ -81,7 +85,7 @@ void InspectorPackagerConnection::Impl::closeAllConnections() {
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::handleConnect(
|
||||
folly::const_dynamic_view payload) {
|
||||
const folly::const_dynamic_view& payload) {
|
||||
std::string pageId = payload.descend("pageId").string_or(INVALID);
|
||||
auto existingConnectionIt = inspectorSessions_.find(pageId);
|
||||
if (existingConnectionIt != inspectorSessions_.end()) {
|
||||
@@ -91,7 +95,7 @@ void InspectorPackagerConnection::Impl::handleConnect(
|
||||
LOG(WARNING) << "Already connected: " << pageId;
|
||||
return;
|
||||
}
|
||||
int pageIdInt;
|
||||
int pageIdInt = 0;
|
||||
try {
|
||||
pageIdInt = std::stoi(pageId);
|
||||
} catch (...) {
|
||||
@@ -123,7 +127,7 @@ void InspectorPackagerConnection::Impl::handleConnect(
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::handleDisconnect(
|
||||
folly::const_dynamic_view payload) {
|
||||
const folly::const_dynamic_view& payload) {
|
||||
std::string pageId = payload.descend("pageId").string_or(INVALID);
|
||||
auto inspectorConnection = removeConnectionForPage(pageId);
|
||||
if (inspectorConnection) {
|
||||
@@ -132,7 +136,8 @@ void InspectorPackagerConnection::Impl::handleDisconnect(
|
||||
}
|
||||
|
||||
std::unique_ptr<ILocalConnection>
|
||||
InspectorPackagerConnection::Impl::removeConnectionForPage(std::string pageId) {
|
||||
InspectorPackagerConnection::Impl::removeConnectionForPage(
|
||||
const std::string& pageId) {
|
||||
auto it = inspectorSessions_.find(pageId);
|
||||
if (it != inspectorSessions_.end()) {
|
||||
auto connection = std::move(it->second);
|
||||
@@ -143,7 +148,7 @@ InspectorPackagerConnection::Impl::removeConnectionForPage(std::string pageId) {
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::handleWrappedEvent(
|
||||
folly::const_dynamic_view payload) {
|
||||
const folly::const_dynamic_view& payload) {
|
||||
std::string pageId = payload.descend("pageId").string_or(INVALID);
|
||||
std::string wrappedEvent = payload.descend("wrappedEvent").string_or(INVALID);
|
||||
auto connectionIt = inspectorSessions_.find(pageId);
|
||||
@@ -195,7 +200,7 @@ void InspectorPackagerConnection::Impl::didReceiveMessage(
|
||||
<< e.what();
|
||||
return;
|
||||
}
|
||||
handleProxyMessage(std::move(parsedJSON));
|
||||
handleProxyMessage(parsedJSON);
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::didOpen() {
|
||||
@@ -277,7 +282,8 @@ void InspectorPackagerConnection::Impl::closeQuietly() {
|
||||
disposeWebSocket();
|
||||
}
|
||||
|
||||
void InspectorPackagerConnection::Impl::sendToPackager(folly::dynamic message) {
|
||||
void InspectorPackagerConnection::Impl::sendToPackager(
|
||||
const folly::dynamic& message) {
|
||||
if (!webSocket_) {
|
||||
return;
|
||||
}
|
||||
@@ -288,7 +294,7 @@ void InspectorPackagerConnection::Impl::sendToPackager(folly::dynamic message) {
|
||||
void InspectorPackagerConnection::Impl::scheduleSendToPackager(
|
||||
folly::dynamic message,
|
||||
SessionId sourceSessionId,
|
||||
std::string sourcePageId) {
|
||||
const std::string& sourcePageId) {
|
||||
delegate_->scheduleCallback(
|
||||
[weakSelf = weak_from_this(),
|
||||
message = std::move(message),
|
||||
@@ -331,7 +337,7 @@ InspectorPackagerConnection::Impl::RemoteConnection::RemoteConnection(
|
||||
std::weak_ptr<InspectorPackagerConnection::Impl> owningPackagerConnection,
|
||||
std::string pageId,
|
||||
SessionId sessionId)
|
||||
: owningPackagerConnection_(owningPackagerConnection),
|
||||
: owningPackagerConnection_(std::move(owningPackagerConnection)),
|
||||
pageId_(std::move(pageId)),
|
||||
sessionId_(sessionId) {}
|
||||
|
||||
@@ -367,7 +373,11 @@ InspectorPackagerConnection::InspectorPackagerConnection(
|
||||
std::string deviceName,
|
||||
std::string appName,
|
||||
std::unique_ptr<InspectorPackagerConnectionDelegate> delegate)
|
||||
: impl_(Impl::create(url, deviceName, appName, std::move(delegate))) {}
|
||||
: impl_(Impl::create(
|
||||
std::move(url),
|
||||
std::move(deviceName),
|
||||
std::move(appName),
|
||||
std::move(delegate))) {}
|
||||
|
||||
bool InspectorPackagerConnection::isConnected() const {
|
||||
return impl_->isConnected();
|
||||
|
||||
+9
-8
@@ -39,8 +39,9 @@ class InspectorPackagerConnection::Impl
|
||||
bool isConnected() const;
|
||||
void connect();
|
||||
void closeQuietly();
|
||||
void sendEventToAllConnections(std::string event);
|
||||
std::unique_ptr<ILocalConnection> removeConnectionForPage(std::string pageId);
|
||||
void sendEventToAllConnections(const std::string& event);
|
||||
std::unique_ptr<ILocalConnection> removeConnectionForPage(
|
||||
const std::string& pageId);
|
||||
|
||||
/**
|
||||
* Send a message to the packager as soon as possible. This method is safe
|
||||
@@ -51,7 +52,7 @@ class InspectorPackagerConnection::Impl
|
||||
void scheduleSendToPackager(
|
||||
folly::dynamic message,
|
||||
SessionId sourceSessionId,
|
||||
std::string sourcePageId);
|
||||
const std::string& sourcePageId);
|
||||
|
||||
private:
|
||||
struct Session {
|
||||
@@ -68,15 +69,15 @@ class InspectorPackagerConnection::Impl
|
||||
Impl(const Impl&) = delete;
|
||||
Impl& operator=(const Impl&) = delete;
|
||||
|
||||
void handleDisconnect(folly::const_dynamic_view payload);
|
||||
void handleConnect(folly::const_dynamic_view payload);
|
||||
void handleWrappedEvent(folly::const_dynamic_view wrappedEvent);
|
||||
void handleProxyMessage(folly::const_dynamic_view message);
|
||||
void handleDisconnect(const folly::const_dynamic_view& payload);
|
||||
void handleConnect(const folly::const_dynamic_view& payload);
|
||||
void handleWrappedEvent(const folly::const_dynamic_view& payload);
|
||||
void handleProxyMessage(const folly::const_dynamic_view& message);
|
||||
folly::dynamic pages();
|
||||
void reconnect();
|
||||
void closeAllConnections();
|
||||
void disposeWebSocket();
|
||||
void sendToPackager(folly::dynamic message);
|
||||
void sendToPackager(const folly::dynamic& message);
|
||||
|
||||
void abort(
|
||||
std::optional<int> posixCode,
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <jsinspector-modern/cdp/CdpJson.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
InstanceAgent::InstanceAgent(
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <jsinspector-modern/InstanceTarget.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
std::shared_ptr<InstanceTarget> InstanceTarget::create(
|
||||
@@ -30,10 +32,10 @@ InstanceTarget::InstanceTarget(
|
||||
(void)delegate_;
|
||||
}
|
||||
|
||||
InstanceTargetDelegate::~InstanceTargetDelegate() {}
|
||||
InstanceTargetDelegate::~InstanceTargetDelegate() = default;
|
||||
|
||||
std::shared_ptr<InstanceAgent> InstanceTarget::createAgent(
|
||||
FrontendChannel channel,
|
||||
const FrontendChannel& channel,
|
||||
SessionState& sessionState) {
|
||||
auto instanceAgent =
|
||||
std::make_shared<InstanceAgent>(channel, *this, sessionState);
|
||||
@@ -61,7 +63,7 @@ RuntimeTarget& InstanceTarget::registerRuntime(
|
||||
.name = "main",
|
||||
.uniqueId = std::nullopt},
|
||||
delegate,
|
||||
jsExecutor,
|
||||
std::move(jsExecutor),
|
||||
makeVoidExecutor(executorFromThis()));
|
||||
|
||||
agents_.forEach([currentRuntime = &*currentRuntime_](InstanceAgent& agent) {
|
||||
|
||||
@@ -65,7 +65,7 @@ class InstanceTarget : public EnableExecutorFromThis<InstanceTarget> {
|
||||
~InstanceTarget();
|
||||
|
||||
std::shared_ptr<InstanceAgent> createAgent(
|
||||
FrontendChannel channel,
|
||||
const FrontendChannel& channel,
|
||||
SessionState& sessionState);
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ class Stream : public NetworkRequestListener,
|
||||
Stream(const Stream& other) = delete;
|
||||
Stream& operator=(const Stream& other) = delete;
|
||||
Stream(Stream&& other) = default;
|
||||
Stream& operator=(Stream&& other) = default;
|
||||
Stream& operator=(Stream&& other) noexcept = default;
|
||||
|
||||
/**
|
||||
* Factory method to create a Stream with a callback for the initial result
|
||||
@@ -72,9 +72,9 @@ class Stream : public NetworkRequestListener,
|
||||
*/
|
||||
static std::shared_ptr<Stream> create(
|
||||
VoidExecutor executor,
|
||||
StreamInitCallback initCb) {
|
||||
const StreamInitCallback& initCb) {
|
||||
std::shared_ptr<Stream> stream{new Stream(initCb)};
|
||||
stream->setExecutor(executor);
|
||||
stream->setExecutor(std::move(executor));
|
||||
return stream;
|
||||
}
|
||||
|
||||
@@ -87,8 +87,7 @@ class Stream : public NetworkRequestListener,
|
||||
* with the result of the read, or an error string.
|
||||
*/
|
||||
void read(long maxBytesToRead, const IOReadCallback& callback) {
|
||||
pendingReadRequests_.emplace_back(
|
||||
std::make_tuple(maxBytesToRead, callback));
|
||||
pendingReadRequests_.emplace_back(maxBytesToRead, callback);
|
||||
processPending();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,19 +8,21 @@
|
||||
#include "RuntimeAgent.h"
|
||||
#include "SessionState.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
RuntimeAgent::RuntimeAgent(
|
||||
FrontendChannel frontendChannel,
|
||||
RuntimeTargetController& targetController,
|
||||
const ExecutionContextDescription& executionContextDescription,
|
||||
ExecutionContextDescription executionContextDescription,
|
||||
SessionState& sessionState,
|
||||
std::unique_ptr<RuntimeAgentDelegate> delegate)
|
||||
: frontendChannel_(std::move(frontendChannel)),
|
||||
targetController_(targetController),
|
||||
sessionState_(sessionState),
|
||||
delegate_(std::move(delegate)),
|
||||
executionContextDescription_(executionContextDescription) {
|
||||
executionContextDescription_(std::move(executionContextDescription)) {
|
||||
for (auto& [name, contextSelectors] : sessionState_.subscribedBindings) {
|
||||
if (matchesAny(executionContextDescription_, contextSelectors)) {
|
||||
targetController_.installBindingHandler(name);
|
||||
@@ -43,7 +45,7 @@ bool RuntimeAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
// Right now, there's only ever one context (Runtime) in a Host, so we can
|
||||
// handle it here for simplicity, and use session state to propagate
|
||||
// bindings to the next RuntimeAgent.
|
||||
if (req.params.count("executionContextId")) {
|
||||
if (req.params.count("executionContextId") != 0u) {
|
||||
auto executionContextId = req.params["executionContextId"].getInt();
|
||||
if (executionContextId < (int64_t)std::numeric_limits<int32_t>::min() ||
|
||||
executionContextId > (int64_t)std::numeric_limits<int32_t>::max()) {
|
||||
@@ -56,14 +58,14 @@ bool RuntimeAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
contextSelector =
|
||||
ExecutionContextSelector::byId((int32_t)executionContextId);
|
||||
|
||||
if (req.params.count("executionContextName")) {
|
||||
if (req.params.count("executionContextName") != 0u) {
|
||||
frontendChannel_(cdp::jsonError(
|
||||
req.id,
|
||||
cdp::ErrorCode::InvalidParams,
|
||||
"executionContextName is mutually exclusive with executionContextId"));
|
||||
return true;
|
||||
}
|
||||
} else if (req.params.count("executionContextName")) {
|
||||
} else if (req.params.count("executionContextName") != 0u) {
|
||||
contextSelector = ExecutionContextSelector::byName(
|
||||
req.params["executionContextName"].getString());
|
||||
}
|
||||
@@ -119,7 +121,7 @@ void RuntimeAgent::notifyBindingCalled(
|
||||
// React Native intentionally replicates this behavior for the sake of
|
||||
// bug-for-bug compatibility with Chrome, but clients should probably not rely
|
||||
// on it.
|
||||
if (!sessionState_.subscribedBindings.count(bindingName)) {
|
||||
if (sessionState_.subscribedBindings.count(bindingName) == 0u) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class RuntimeAgent final {
|
||||
RuntimeAgent(
|
||||
FrontendChannel frontendChannel,
|
||||
RuntimeTargetController& targetController,
|
||||
const ExecutionContextDescription& executionContextDescription,
|
||||
ExecutionContextDescription executionContextDescription,
|
||||
SessionState& sessionState,
|
||||
std::unique_ptr<RuntimeAgentDelegate> delegate);
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <jsinspector-modern/RuntimeTarget.h>
|
||||
#include <jsinspector-modern/tracing/PerformanceTracer.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace facebook::jsi;
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
@@ -34,20 +36,20 @@ std::shared_ptr<RuntimeTarget> RuntimeTarget::create(
|
||||
RuntimeTargetDelegate& delegate,
|
||||
RuntimeExecutor jsExecutor,
|
||||
VoidExecutor selfExecutor) {
|
||||
std::shared_ptr<RuntimeTarget> runtimeTarget{
|
||||
new RuntimeTarget(executionContextDescription, delegate, jsExecutor)};
|
||||
runtimeTarget->setExecutor(selfExecutor);
|
||||
std::shared_ptr<RuntimeTarget> runtimeTarget{new RuntimeTarget(
|
||||
executionContextDescription, delegate, std::move(jsExecutor))};
|
||||
runtimeTarget->setExecutor(std::move(selfExecutor));
|
||||
runtimeTarget->installGlobals();
|
||||
return runtimeTarget;
|
||||
}
|
||||
|
||||
RuntimeTarget::RuntimeTarget(
|
||||
const ExecutionContextDescription& executionContextDescription,
|
||||
ExecutionContextDescription executionContextDescription,
|
||||
RuntimeTargetDelegate& delegate,
|
||||
RuntimeExecutor jsExecutor)
|
||||
: executionContextDescription_(executionContextDescription),
|
||||
: executionContextDescription_(std::move(executionContextDescription)),
|
||||
delegate_(delegate),
|
||||
jsExecutor_(jsExecutor) {}
|
||||
jsExecutor_(std::move(jsExecutor)) {}
|
||||
|
||||
void RuntimeTarget::installGlobals() {
|
||||
// NOTE: RuntimeTarget::installConsoleHandler is in RuntimeTargetConsole.cpp
|
||||
@@ -56,7 +58,7 @@ void RuntimeTarget::installGlobals() {
|
||||
}
|
||||
|
||||
std::shared_ptr<RuntimeAgent> RuntimeTarget::createAgent(
|
||||
FrontendChannel channel,
|
||||
const FrontendChannel& channel,
|
||||
SessionState& sessionState) {
|
||||
auto runtimeAgentState =
|
||||
std::move(sessionState.lastRuntimeAgentExportedState);
|
||||
|
||||
@@ -205,7 +205,7 @@ class JSINSPECTOR_EXPORT RuntimeTarget
|
||||
* \returns The new agent, or nullptr if the runtime is not debuggable.
|
||||
*/
|
||||
std::shared_ptr<RuntimeAgent> createAgent(
|
||||
FrontendChannel channel,
|
||||
const FrontendChannel& channel,
|
||||
SessionState& sessionState);
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ class JSINSPECTOR_EXPORT RuntimeTarget
|
||||
* constructor should be executed before any user code is run).
|
||||
*/
|
||||
RuntimeTarget(
|
||||
const ExecutionContextDescription& executionContextDescription,
|
||||
ExecutionContextDescription executionContextDescription,
|
||||
RuntimeTargetDelegate& delegate,
|
||||
RuntimeExecutor jsExecutor);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase<
|
||||
onMessage(
|
||||
JsonParsed(AllOf(AtJsonPtr("/method", "Debugger.scriptParsed")))))
|
||||
.Times(AnyNumber())
|
||||
.WillRepeatedly(Invoke<>([this](std::string message) {
|
||||
.WillRepeatedly(Invoke<>([this](const std::string& message) {
|
||||
auto params = folly::parseJson(message);
|
||||
// Store the script ID and URL for later use.
|
||||
scriptUrlsById_.emplace(
|
||||
@@ -114,7 +114,8 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase<
|
||||
* paramsMatcher, only if the Runtime domain is currently disabled ( = the
|
||||
* call will be buffered and reported later upon enabling the domain).
|
||||
*/
|
||||
void expectConsoleApiCallBuffered(Matcher<folly::dynamic> paramsMatcher) {
|
||||
void expectConsoleApiCallBuffered(
|
||||
const Matcher<folly::dynamic>& paramsMatcher) {
|
||||
if (!runtimeEnabled_) {
|
||||
expectedConsoleApiCalls_.emplace_back(paramsMatcher);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ class ConsoleApiTest : public JsiIntegrationPortableTestBase<
|
||||
}
|
||||
|
||||
private:
|
||||
std::optional<std::string> getScriptUrlById(std::string scriptId) {
|
||||
std::optional<std::string> getScriptUrlById(const std::string& scriptId) {
|
||||
auto it = scriptUrlsById_.find(scriptId);
|
||||
if (it == scriptUrlsById_.end()) {
|
||||
return std::nullopt;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace facebook::folly_dynamic_matchers_utils {
|
||||
std::string as_string(std::string value) {
|
||||
return value;
|
||||
}
|
||||
std::string as_string(folly::dynamic value) {
|
||||
std::string as_string(const folly::dynamic& value) {
|
||||
return value.asString();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace facebook {
|
||||
namespace folly_dynamic_matchers_utils {
|
||||
|
||||
std::string as_string(std::string value);
|
||||
std::string as_string(folly::dynamic value);
|
||||
std::string as_string(const folly::dynamic& value);
|
||||
std::string explain_error(
|
||||
folly::dynamic::json_pointer_resolution_error<const folly::dynamic> error);
|
||||
|
||||
|
||||
@@ -642,7 +642,7 @@ TEST_F(HostTargetTest, HostCommands) {
|
||||
std::unique_ptr<RuntimeAgentDelegate::ExportedState>
|
||||
exportedState,
|
||||
const ExecutionContextDescription& context,
|
||||
RuntimeExecutor runtimeExecutor) {
|
||||
const RuntimeExecutor& runtimeExecutor) {
|
||||
auto delegate = runtimeAgentDelegates_.make_unique(
|
||||
std::move(frontendChannel),
|
||||
sessionState,
|
||||
@@ -1417,7 +1417,7 @@ TEST_F(HostTargetTest, NetworkLoadNetworkResourceNotImplementedByDelegate) {
|
||||
Field(&LoadNetworkResourceRequest::url, "http://example.com"), _))
|
||||
.Times(1)
|
||||
.WillOnce([](const LoadNetworkResourceRequest& /*params*/,
|
||||
ScopedExecutor<NetworkRequestListener> /*executor*/) {
|
||||
const ScopedExecutor<NetworkRequestListener>& /*executor*/) {
|
||||
throw NotImplementedException(
|
||||
"This delegate does not implement loadNetworkResource.");
|
||||
})
|
||||
|
||||
-2
@@ -10,8 +10,6 @@
|
||||
|
||||
#include "JsiIntegrationTestGenericEngineAdapter.h"
|
||||
|
||||
using facebook::hermes::makeHermesRuntime;
|
||||
|
||||
namespace facebook::react::jsinspector_modern {
|
||||
|
||||
JsiIntegrationTestGenericEngineAdapter::JsiIntegrationTestGenericEngineAdapter(
|
||||
|
||||
@@ -157,8 +157,7 @@ void PerformanceTracer::reportMark(
|
||||
folly::dynamic eventArgs = folly::dynamic::object();
|
||||
if (detail != nullptr) {
|
||||
eventArgs = folly::dynamic::object(
|
||||
"data",
|
||||
folly::dynamic::object("detail", folly::toJson(std::move(detail))));
|
||||
"data", folly::dynamic::object("detail", folly::toJson(detail)));
|
||||
}
|
||||
|
||||
buffer_.emplace_back(TraceEvent{
|
||||
@@ -183,8 +182,7 @@ void PerformanceTracer::reportMeasure(
|
||||
|
||||
folly::dynamic beginEventArgs = folly::dynamic::object();
|
||||
if (detail != nullptr) {
|
||||
beginEventArgs =
|
||||
folly::dynamic::object("detail", folly::toJson(std::move(detail)));
|
||||
beginEventArgs = folly::dynamic::object("detail", folly::toJson(detail));
|
||||
}
|
||||
|
||||
auto currentThreadId = oscompat::getCurrentThreadId();
|
||||
|
||||
Reference in new issue
Block a user