| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 63611d0 commit be00058
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,11 +44,11 @@ const convertHeaderObject = (headers = {}) => { | |||
| 44 | 44 | }; | |
| 45 | 45 | ||
| 46 | 46 | /** | |
| 47 | - * When a client request starts, emit Network.requestWillBeSent event. | ||
| 47 | + * When a client request is created, emit Network.requestWillBeSent event. | ||
| 48 | 48 | * https://chromedevtools.github.io/devtools-protocol/1-3/Network/#event-requestWillBeSent | |
| 49 | 49 | * @param {{ request: import('http').ClientRequest }} event | |
| 50 | 50 | */ | |
| 51 | - function onClientRequestStart({ request }) { | ||
| 51 | + function onClientRequestCreated({ request }) { | ||
| 52 | 52 | request[kInspectorRequestId] = getNextRequestId(); | |
| 53 | 53 | ||
| 54 | 54 | const { 0: host, 1: headers } = convertHeaderObject(request.getHeaders()); | |
@@ -115,13 +115,13 @@ function onClientResponseFinish({ request, response }) { | |||
| 115 | 115 | } | |
| 116 | 116 | ||
| 117 | 117 | function enable() { | |
| 118 | - dc.subscribe('http.client.request.start', onClientRequestStart); | ||
| 118 | + dc.subscribe('http.client.request.created', onClientRequestCreated); | ||
| 119 | 119 | dc.subscribe('http.client.request.error', onClientRequestError); | |
| 120 | 120 | dc.subscribe('http.client.response.finish', onClientResponseFinish); | |
| 121 | 121 | } | |
| 122 | 122 | ||
| 123 | 123 | function disable() { | |
| 124 | - dc.unsubscribe('http.client.request.start', onClientRequestStart); | ||
| 124 | + dc.unsubscribe('http.client.request.created', onClientRequestCreated); | ||
| 125 | 125 | dc.unsubscribe('http.client.request.error', onClientRequestError); | |
| 126 | 126 | dc.unsubscribe('http.client.response.finish', onClientResponseFinish); | |
| 127 | 127 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,10 +129,10 @@ function enable() { | |||
| 129 | 129 | } | |
| 130 | 130 | ||
| 131 | 131 | function disable() { | |
| 132 | - dc.subscribe('undici:request:create', onClientRequestStart); | ||
| 133 | - dc.subscribe('undici:request:error', onClientRequestError); | ||
| 134 | - dc.subscribe('undici:request:headers', onClientResponseHeaders); | ||
| 135 | - dc.subscribe('undici:request:trailers', onClientResponseFinish); | ||
| 132 | + dc.unsubscribe('undici:request:create', onClientRequestStart); | ||
| 133 | + dc.unsubscribe('undici:request:error', onClientRequestError); | ||
| 134 | + dc.unsubscribe('undici:request:headers', onClientResponseHeaders); | ||
| 135 | + dc.unsubscribe('undici:request:trailers', onClientResponseFinish); | ||
| 136 | 136 | } | |
| 137 | 137 | ||
| 138 | 138 | module.exports = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,8 +29,9 @@ std::unique_ptr<Network::Response> createResponse( | |||
| 29 | 29 | .build(); | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | - NetworkAgent::NetworkAgent(NetworkInspector* inspector) | ||
| 33 | - : inspector_(inspector) { | ||
| 32 | + NetworkAgent::NetworkAgent(NetworkInspector* inspector, | ||
| 33 | + v8_inspector::V8Inspector* v8_inspector) | ||
| 34 | + : inspector_(inspector), v8_inspector_(v8_inspector) { | ||
| 34 | 35 | event_notifier_map_["requestWillBeSent"] = &NetworkAgent::requestWillBeSent; | |
| 35 | 36 | event_notifier_map_["responseReceived"] = &NetworkAgent::responseReceived; | |
| 36 | 37 | event_notifier_map_["loadingFailed"] = &NetworkAgent::loadingFailed; | |
@@ -75,6 +76,13 @@ void NetworkAgent::requestWillBeSent( | |||
| 75 | 76 | String method; | |
| 76 | 77 | request->getString("method", &method); | |
| 77 | 78 | ||
| 79 | + std::unique_ptr<Network::Initiator> initiator = | ||
| 80 | + Network::Initiator::create() | ||
| 81 | + .setType(Network::Initiator::TypeEnum::Script) | ||
| 82 | + .setStack( | ||
| 83 | + v8_inspector_->captureStackTrace(true)->buildInspectorObject(0)) | ||
| 84 | + .build(); | ||
| 85 | + | ||
| 78 | 86 | ErrorSupport errors; | |
| 79 | 87 | errors.Push(); | |
| 80 | 88 | errors.SetName("headers"); | |
@@ -86,6 +94,7 @@ void NetworkAgent::requestWillBeSent( | |||
| 86 | 94 | ||
| 87 | 95 | frontend_->requestWillBeSent(request_id, | |
| 88 | 96 | createRequest(url, method, std::move(headers)), | |
| 97 | + std::move(initiator), | ||
| 89 | 98 | timestamp, | |
| 90 | 99 | wall_time); | |
| 91 | 100 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,8 @@ namespace protocol { | |||
| 14 | 14 | ||
| 15 | 15 | class NetworkAgent : public Network::Backend { | |
| 16 | 16 | public: | |
| 17 | - explicit NetworkAgent(NetworkInspector* inspector); | ||
| 17 | + explicit NetworkAgent(NetworkInspector* inspector, | ||
| 18 | + v8_inspector::V8Inspector* v8_inspector); | ||
| 18 | 19 | ||
| 19 | 20 | void Wire(UberDispatcher* dispatcher); | |
| 20 | 21 | ||
@@ -35,6 +36,7 @@ class NetworkAgent : public Network::Backend { | |||
| 35 | 36 | ||
| 36 | 37 | private: | |
| 37 | 38 | NetworkInspector* inspector_; | |
| 39 | + v8_inspector::V8Inspector* v8_inspector_; | ||
| 38 | 40 | std::shared_ptr<Network::Frontend> frontend_; | |
| 39 | 41 | using EventNotifier = | |
| 40 | 42 | void (NetworkAgent::*)(std::unique_ptr<protocol::DictionaryValue>); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,9 +3,10 @@ | |||
| 3 | 3 | namespace node { | |
| 4 | 4 | namespace inspector { | |
| 5 | 5 | ||
| 6 | - NetworkInspector::NetworkInspector(Environment* env) | ||
| 6 | + NetworkInspector::NetworkInspector(Environment* env, | ||
| 7 | + v8_inspector::V8Inspector* v8_inspector) | ||
| 7 | 8 | : enabled_(false), env_(env) { | |
| 8 | - network_agent_ = std::make_unique<protocol::NetworkAgent>(this); | ||
| 9 | + network_agent_ = std::make_unique<protocol::NetworkAgent>(this, v8_inspector); | ||
| 9 | 10 | } | |
| 10 | 11 | NetworkInspector::~NetworkInspector() { | |
| 11 | 12 | network_agent_.reset(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,8 @@ namespace inspector { | |||
| 11 | 11 | ||
| 12 | 12 | class NetworkInspector { | |
| 13 | 13 | public: | |
| 14 | - explicit NetworkInspector(Environment* env); | ||
| 14 | + explicit NetworkInspector(Environment* env, | ||
| 15 | + v8_inspector::V8Inspector* v8_inspector); | ||
| 15 | 16 | ~NetworkInspector(); | |
| 16 | 17 | ||
| 17 | 18 | void Wire(protocol::UberDispatcher* dispatcher); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,6 +97,7 @@ | |||
| 97 | 97 | 'action_name': 'node_protocol_generated_sources', | |
| 98 | 98 | 'inputs': [ | |
| 99 | 99 | 'node_protocol_config.json', | |
| 100 | + 'node_protocol.pdl', | ||
| 100 | 101 | '<(SHARED_INTERMEDIATE_DIR)/src/node_protocol.json', | |
| 101 | 102 | '<@(node_protocol_files)', | |
| 102 | 103 | '<(protocol_tool_path)/code_generator.py', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,6 +101,8 @@ experimental domain NodeWorker | |||
| 101 | 101 | # Partial support for Network domain of ChromeDevTools Protocol. | |
| 102 | 102 | # https://chromedevtools.github.io/devtools-protocol/tot/Network | |
| 103 | 103 | experimental domain Network | |
| 104 | + depends on Runtime | ||
| 105 | + | ||
| 104 | 106 | # Resource type as it was perceived by the rendering engine. | |
| 105 | 107 | type ResourceType extends string | |
| 106 | 108 | enum | |
@@ -132,6 +134,31 @@ experimental domain Network | |||
| 132 | 134 | # Monotonically increasing time in seconds since an arbitrary point in the past. | |
| 133 | 135 | type MonotonicTime extends number | |
| 134 | 136 | ||
| 137 | + # Information about the request initiator. | ||
| 138 | + type Initiator extends object | ||
| 139 | + properties | ||
| 140 | + # Type of this initiator. | ||
| 141 | + enum type | ||
| 142 | + parser | ||
| 143 | + script | ||
| 144 | + preload | ||
| 145 | + SignedExchange | ||
| 146 | + preflight | ||
| 147 | + other | ||
| 148 | + # Initiator JavaScript stack trace, set for Script only. | ||
| 149 | + # Requires the Debugger domain to be enabled. | ||
| 150 | + optional Runtime.StackTrace stack | ||
| 151 | + # Initiator URL, set for Parser type or for Script type (when script is importing module) or for SignedExchange type. | ||
| 152 | + optional string url | ||
| 153 | + # Initiator line number, set for Parser type or for Script type (when script is importing | ||
| 154 | + # module) (0-based). | ||
| 155 | + optional number lineNumber | ||
| 156 | + # Initiator column number, set for Parser type or for Script type (when script is importing | ||
| 157 | + # module) (0-based). | ||
| 158 | + optional number columnNumber | ||
| 159 | + # Set if another request triggered this request (e.g. preflight). | ||
| 160 | + optional RequestId requestId | ||
| 161 | + | ||
| 135 | 162 | # HTTP request data. | |
| 136 | 163 | type Request extends object | |
| 137 | 164 | properties | |
@@ -163,6 +190,8 @@ experimental domain Network | |||
| 163 | 190 | RequestId requestId | |
| 164 | 191 | # Request data. | |
| 165 | 192 | Request request | |
| 193 | + # Request initiator. | ||
| 194 | + Initiator initiator | ||
| 166 | 195 | # Timestamp. | |
| 167 | 196 | MonotonicTime timestamp | |
| 168 | 197 | # Timestamp. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,17 @@ | |||
| 5 | 5 | "output": "node/inspector/protocol", | |
| 6 | 6 | "namespace": ["node", "inspector", "protocol"] | |
| 7 | 7 | }, | |
| 8 | + "imported": { | ||
| 9 | + "path": "../../deps/v8/include/js_protocol.pdl", | ||
| 10 | + "header": "<v8-inspector-protocol.h>", | ||
| 11 | + "namespace": ["v8_inspector", "protocol"], | ||
| 12 | + "options": [ | ||
| 13 | + { | ||
| 14 | + "domain": "Runtime", | ||
| 15 | + "imported": ["StackTrace"] | ||
| 16 | + } | ||
| 17 | + ] | ||
| 18 | + }, | ||
| 8 | 19 | "exported": { | |
| 9 | 20 | "package": "include/inspector", | |
| 10 | 21 | "output": "../../include/inspector", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,7 +241,8 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, | |||
| 241 | 241 | } | |
| 242 | 242 | runtime_agent_ = std::make_unique<protocol::RuntimeAgent>(); | |
| 243 | 243 | runtime_agent_->Wire(node_dispatcher_.get()); | |
| 244 | - network_inspector_ = std::make_unique<NetworkInspector>(env); | ||
| 244 | + network_inspector_ = | ||
| 245 | + std::make_unique<NetworkInspector>(env, inspector.get()); | ||
| 245 | 246 | network_inspector_->Wire(node_dispatcher_.get()); | |
| 246 | 247 | } | |
| 247 | 248 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments