Record JavaScript calls in DevTools timeline on Node/ipc callback
authorRyohei Ikegami <iofg2100@gmail.com>
Wed, 7 Dec 2016 11:22:08 +0000 (20:22 +0900)
committerRyohei Ikegami <iofg2100@gmail.com>
Wed, 7 Dec 2016 11:22:13 +0000 (20:22 +0900)
atom/common/node_bindings.cc
atom/renderer/atom_render_view_observer.cc

index e869d2a..25d9db4 100644 (file)
@@ -17,6 +17,8 @@
 #include "base/files/file_path.h"
 #include "base/message_loop/message_loop.h"
 #include "base/path_service.h"
+#include "base/trace_event/trace_event.h"
+#include "base/trace_event/trace_event_argument.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/common/content_paths.h"
 #include "native_mate/dictionary.h"
@@ -239,8 +241,17 @@ void NodeBindings::UvRunOnce() {
   v8::MicrotasksScope script_scope(env->isolate(),
                                    v8::MicrotasksScope::kRunMicrotasks);
 
+  if (!is_browser_)
+    TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data",
+                       std::unique_ptr<base::trace_event::TracedValue>(
+                           new base::trace_event::TracedValue()));
+
   // Deal with uv events.
   int r = uv_run(uv_loop_, UV_RUN_NOWAIT);
+
+  if (!is_browser_)
+    TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
+
   if (r == 0)
     message_loop_->QuitWhenIdle();  // Quit from uv.
 
index 6ca8b3e..5e030b6 100644 (file)
@@ -18,6 +18,8 @@
 #include "atom/renderer/atom_renderer_client.h"
 #include "base/command_line.h"
 #include "base/strings/string_number_conversions.h"
+#include "base/trace_event/trace_event.h"
+#include "base/trace_event/trace_event_argument.h"
 #include "content/public/renderer/render_view.h"
 #include "ipc/ipc_message_macros.h"
 #include "native_mate/dictionary.h"
@@ -102,6 +104,9 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
 
   v8::Local<v8::Object> ipc;
   if (GetIPCObject(isolate, context, &ipc)) {
+    TRACE_EVENT1("devtools.timeline", "FunctionCall", "data",
+                 std::unique_ptr<base::trace_event::TracedValue>(
+                     new base::trace_event::TracedValue()));
     auto args_vector = ListValueToVector(isolate, args);
     // Insert the Event object, event.sender is ipc.
     mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);