Files
react-native/ReactCommon/hermes/inspector/chrome/Connection.h
T
cpojer d7f5153cd8 Add Hermes support to React Native on Android (#25613)
Summary:
Yesterday we shipped hermesengine.dev as part of the current 0.60 release. This PR brings those changes to master.

## Changelog

[General] [Added] - Added support for Hermes
Pull Request resolved: https://github.com/facebook/react-native/pull/25613

Test Plan:
* CI is green both on GitHub and at FB
* Creating a new app from source can use Hermes on Android

Reviewed By: cpojer

Differential Revision: D16221777

Pulled By: willholen

fbshipit-source-id: aa6be10537863039cb666292465ba2e1d44b64ef
2019-07-25 23:05:53 -07:00

59 lines
1.7 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <hermes/hermes.h>
#include <hermes/inspector/RuntimeAdapter.h>
#include <hermes/inspector/chrome/MessageTypes.h>
#include <jsinspector/InspectorInterfaces.h>
namespace facebook {
namespace hermes {
namespace inspector {
namespace chrome {
/// Connection is a duplex connection between the client and the debugger.
class Connection {
public:
/// Connection constructor enables the debugger on the provided runtime. This
/// should generally called before you start running any JS in the runtime.
Connection(
std::unique_ptr<RuntimeAdapter> adapter,
const std::string &title,
bool waitForDebugger = false);
~Connection();
/// getRuntime returns the underlying runtime being debugged.
HermesRuntime &getRuntime();
/// getTitle returns the name of the friendly name of the runtime that's shown
/// to users in Nuclide.
std::string getTitle() const;
/// connect attaches this connection to the runtime's debugger. Requests to
/// the debugger sent via send(). Replies and notifications from the debugger
/// are sent back to the client via IRemoteConnection::onMessage.
bool connect(
std::unique_ptr<::facebook::react::IRemoteConnection> remoteConn);
/// disconnect disconnects this connection from the runtime's debugger
bool disconnect();
/// sendMessage delivers a JSON-encoded Chrome DevTools Protocol request to
/// the debugger.
void sendMessage(std::string str);
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace chrome
} // namespace inspector
} // namespace hermes
} // namespace facebook