Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp

Issue 1916023002: [DevTools] Move last inspected objects to V8InspectorSessionImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-part-command-line-api-to-native
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp
index 701a60c58d37a387cb9aa5b8d6920b21165763b8..7e0c2f4f9fa6c26a56822c0c59cddbd0bb491ce7 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp
@@ -10,6 +10,7 @@
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/V8InspectorSessionImpl.h"
#include "platform/v8_inspector/V8ProfilerAgentImpl.h"
+#include "platform/v8_inspector/V8RuntimeAgentImpl.h"
#include "platform/v8_inspector/V8StackTraceImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "platform/v8_inspector/public/ConsoleAPITypes.h"
@@ -202,6 +203,15 @@ public:
}
return nullptr;
}
+
+ V8RuntimeAgentImpl* runtimeAgent()
+ {
+ if (V8InspectorSessionImpl* session = currentSession()) {
+ if (session && session->runtimeAgentImpl()->enabled())
+ return session->runtimeAgentImpl();
+ }
+ return nullptr;
+ }
private:
const v8::FunctionCallbackInfo<v8::Value>& m_info;
v8::Isolate* m_isolate;
@@ -572,6 +582,20 @@ void V8Console::unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Val
setFunctionBreakpoint(helper, function, V8DebuggerAgentImpl::MonitorCommandBreakpointSource, String16(), false);
}
+void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, unsigned num)
+{
+ ASSERT(num < V8RuntimeAgentImpl::inspectedObjectBufferSize);
+ ConsoleHelper helper(info);
+ if (V8RuntimeAgentImpl* runtimeAgent = helper.runtimeAgent()) {
+ V8RuntimeAgent::Inspectable* object = runtimeAgent->inspectedObject(num);
+ v8::Isolate* isolate = info.GetIsolate();
+ if (object)
+ info.GetReturnValue().Set(object->get(isolate->GetCurrentContext()));
+ else
+ info.GetReturnValue().Set(v8::Undefined(isolate));
+ }
+}
+
v8::MaybeLocal<v8::Object> V8Console::createConsole(v8::Local<v8::Context> context, InspectedContext* inspectedContext, bool hasMemoryAttribute)
{
v8::Isolate* isolate = context->GetIsolate();
@@ -639,6 +663,11 @@ v8::Local<v8::Object> V8Console::createCommandLineAPI(v8::Local<v8::Context> con
createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "undebug", V8Console::undebugFunctionCallback);
createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "monitor", V8Console::monitorFunctionCallback);
createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "unmonitor", V8Console::unmonitorFunctionCallback);
+ createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$0", V8Console::firstInspectedObject);
+ createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$1", V8Console::secondInspectedObject);
+ createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$2", V8Console::thirdInspectedObject);
+ createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$3", V8Console::fourthInspectedObject);
+ createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$4", V8Console::fifthInspectedObject);
commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext));
return commandLineAPI;

Powered by Google App Engine
This is Rietveld 408576698