summaryrefslogtreecommitdiff
path: root/src/inspector
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-07-16 23:34:55 +0200
committerAnna Henningsen <anna@addaleax.net>2018-08-01 17:16:48 +0200
commit3ac94dc977b232a4502307733af2b3af60e7b102 (patch)
treea88c9598caac2e8c65cec62417d6334a0a87b1fd /src/inspector
parentebfb52b14cf7e07388367ad4b66240f08d9dc5a6 (diff)
downloadandroid-node-v8-3ac94dc977b232a4502307733af2b3af60e7b102.tar.gz
android-node-v8-3ac94dc977b232a4502307733af2b3af60e7b102.tar.bz2
android-node-v8-3ac94dc977b232a4502307733af2b3af60e7b102.zip
src: refactor tracing agent code
Avoid unnecessary operations, add a bit of documentation, and turn the `ClientHandle` smart pointer alias into a real class. This should allow de-coupling the unnecessary combination of a single specific `file_writer` from `Agent`. PR-URL: https://github.com/nodejs/node/pull/21867 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'src/inspector')
-rw-r--r--src/inspector/tracing_agent.cc6
-rw-r--r--src/inspector/tracing_agent.h8
2 files changed, 4 insertions, 10 deletions
diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc
index c0425aab29..92c3597590 100644
--- a/src/inspector/tracing_agent.cc
+++ b/src/inspector/tracing_agent.cc
@@ -46,9 +46,7 @@ class InspectorTraceWriter : public node::tracing::AsyncTraceWriter {
} // namespace
TracingAgent::TracingAgent(Environment* env)
- : env_(env),
- trace_writer_(
- tracing::Agent::EmptyClientHandle()) {
+ : env_(env) {
}
TracingAgent::~TracingAgent() {
@@ -62,7 +60,7 @@ void TracingAgent::Wire(UberDispatcher* dispatcher) {
DispatchResponse TracingAgent::start(
std::unique_ptr<protocol::NodeTracing::TraceConfig> traceConfig) {
- if (trace_writer_ != nullptr) {
+ if (!trace_writer_.empty()) {
return DispatchResponse::Error(
"Call NodeTracing::end to stop tracing before updating the config");
}
diff --git a/src/inspector/tracing_agent.h b/src/inspector/tracing_agent.h
index 478107c5ac..029fce7c19 100644
--- a/src/inspector/tracing_agent.h
+++ b/src/inspector/tracing_agent.h
@@ -2,16 +2,13 @@
#define SRC_INSPECTOR_TRACING_AGENT_H_
#include "node/inspector/protocol/NodeTracing.h"
+#include "tracing/agent.h"
#include "v8.h"
namespace node {
class Environment;
-namespace tracing {
-class Agent;
-} // namespace tracing
-
namespace inspector {
namespace protocol {
@@ -32,8 +29,7 @@ class TracingAgent : public NodeTracing::Backend {
void DisconnectTraceClient();
Environment* env_;
- std::unique_ptr<std::pair<tracing::Agent*, int>,
- void (*)(std::pair<tracing::Agent*, int>*)> trace_writer_;
+ tracing::AgentWriterHandle trace_writer_;
std::unique_ptr<NodeTracing::Frontend> frontend_;
};