Skip to content

Commit fbc8410

Browse files
lexsFacebook Github Bot
authored andcommitted
Add some documentation
Summary: Adds documentation about the Inspector. Reviewed By: passy, foghina Differential Revision: D4114673 fbshipit-source-id: fb1182c89c94f10a74d4589b6a24a06b376db92e
1 parent 1709043 commit fbc8410

File tree

8 files changed

+49
-2
lines changed

8 files changed

+49
-2
lines changed

ReactCommon/inspector/Agent.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
namespace facebook {
1010
namespace react {
1111

12+
/*
13+
* An dispatcher that makes it simple to implement an agent that serves a single domain.
14+
*/
1215
class Agent : public Dispatcher {
1316
public:
1417
void onConnect(std::shared_ptr<Channel> channel) override;

ReactCommon/inspector/ConsoleAgent.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class InjectedScriptManager;
1717
namespace facebook {
1818
namespace react {
1919

20+
/**
21+
* Implements the Console agent. Relies on Javascript to call the globally exposed method __inspectorLog
22+
* to send logging events.
23+
*/
2024
class ConsoleAgent : public Agent {
2125
public:
2226
ConsoleAgent(JSC::JSGlobalObject& globalObject, Inspector::InjectedScriptManager* injectedScriptManager);

ReactCommon/inspector/Dispatcher.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
namespace facebook {
1212
namespace react {
1313

14+
/*
15+
* A bidrectional channel that allows both sending events to the remote inspector and registering
16+
* to receive events for a specific domain.
17+
*/
1418
class Channel {
1519
public:
1620
using MessageHandler = std::function<void(std::string message, int callId, const std::string& methodName, folly::dynamic args)>;
@@ -21,6 +25,10 @@ class Channel {
2125
virtual void registerDomain(std::string domain, MessageHandler handler) = 0;
2226
};
2327

28+
/*
29+
* A dispatcher is responsible for one or multiple domains and registering them with the Channel
30+
* when it is connected.
31+
*/
2432
class Dispatcher {
2533
public:
2634
virtual ~Dispatcher() {}

ReactCommon/inspector/Inspector.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ namespace react {
1616

1717
class InspectorController;
1818
class Sender;
19-
19+
/**
20+
* The inspector exposes method to query for available 'pages' and connect to a specific one.
21+
* Available Javascript contextes needs to be registered when they are created and removed when
22+
* they are torn down.
23+
*/
2024
class Inspector {
2125
private:
2226
class DuplexConnection;
@@ -36,7 +40,7 @@ class Inspector {
3640
public:
3741
void sendMessage(std::string message);
3842
void disconnect();
39-
43+
4044
LocalConnection(std::shared_ptr<DuplexConnection> duplexConnection);
4145
private:
4246
std::shared_ptr<DuplexConnection> duplexConnection_;

ReactCommon/inspector/JSDispatcher.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class JSArray;
2121
namespace facebook {
2222
namespace react {
2323

24+
/*
25+
* A dispatcher that allows agents to be implemented in Javascript. Provides the global method
26+
* __registerInspectorAgent to register a JS agent.
27+
*/
2428
class JSDispatcher : public Dispatcher {
2529
public:
2630
JSDispatcher(JSC::JSGlobalObject& globalObject);

ReactCommon/inspector/LegacyAgents.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ namespace react {
1414
class LegacyInspectorEnvironment;
1515
class ConsoleAgent;
1616

17+
/*
18+
* An dispatcher that provides the existing agents in JavaScriptCore.
19+
*/
1720
class LegacyAgents : public LegacyDispatcher {
1821
public:
1922
LegacyAgents(

ReactCommon/inspector/LegacyDispatcher.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class JSGlobalObject;
2020
namespace facebook {
2121
namespace react {
2222

23+
/*
24+
* An dispatcher that is able to register JavaScriptCore agents that extend the InspectorAgentBase
25+
* base class.
26+
*/
2327
class LegacyDispatcher : public Dispatcher {
2428
public:
2529
LegacyDispatcher(JSC::JSGlobalObject& globalObject);

ReactCommon/inspector/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Inspector
2+
3+
This directory implements an the Chrome debugging protocol [1]. The version used is roughly 1.1 of
4+
the protocol. The code here doesn't specify a transport and doesn't implement an actual server. This
5+
is left up to higher parts of the stack.
6+
7+
The implementation uses multiple "dispatchers" to route messages for a specific domain. It reuses
8+
existing code in JavaScriptCore to handle the domains for Debugger and Runtime. For Console, Page
9+
and Inspector there are new implementations.
10+
11+
## Open source
12+
13+
The inspector currently doesn't compile in open source. This is due to how the build on Android
14+
where we download the JSC sources and build an artifact separately, later download the headers we
15+
need. The number of headers download would have to be expanded and verify that it builds correctly.
16+
17+
[1]: https://developer.chrome.com/devtools/docs/debugger-protocol

0 commit comments

Comments
 (0)