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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8Console.h" 5 #include "platform/v8_inspector/V8Console.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/InspectedContext.h" 8 #include "platform/v8_inspector/InspectedContext.h"
9 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 9 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
10 #include "platform/v8_inspector/V8DebuggerImpl.h" 10 #include "platform/v8_inspector/V8DebuggerImpl.h"
11 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 11 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
12 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" 12 #include "platform/v8_inspector/V8ProfilerAgentImpl.h"
13 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
13 #include "platform/v8_inspector/V8StackTraceImpl.h" 14 #include "platform/v8_inspector/V8StackTraceImpl.h"
14 #include "platform/v8_inspector/V8StringUtil.h" 15 #include "platform/v8_inspector/V8StringUtil.h"
15 #include "platform/v8_inspector/public/ConsoleAPITypes.h" 16 #include "platform/v8_inspector/public/ConsoleAPITypes.h"
16 #include "platform/v8_inspector/public/ConsoleTypes.h" 17 #include "platform/v8_inspector/public/ConsoleTypes.h"
17 #include "platform/v8_inspector/public/V8DebuggerClient.h" 18 #include "platform/v8_inspector/public/V8DebuggerClient.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 196 }
196 197
197 V8DebuggerAgentImpl* debuggerAgent() 198 V8DebuggerAgentImpl* debuggerAgent()
198 { 199 {
199 if (V8InspectorSessionImpl* session = currentSession()) { 200 if (V8InspectorSessionImpl* session = currentSession()) {
200 if (session && session->debuggerAgentImpl()->enabled()) 201 if (session && session->debuggerAgentImpl()->enabled())
201 return session->debuggerAgentImpl(); 202 return session->debuggerAgentImpl();
202 } 203 }
203 return nullptr; 204 return nullptr;
204 } 205 }
206
207 V8RuntimeAgentImpl* runtimeAgent()
208 {
209 if (V8InspectorSessionImpl* session = currentSession()) {
210 if (session && session->runtimeAgentImpl()->enabled())
211 return session->runtimeAgentImpl();
212 }
213 return nullptr;
214 }
205 private: 215 private:
206 const v8::FunctionCallbackInfo<v8::Value>& m_info; 216 const v8::FunctionCallbackInfo<v8::Value>& m_info;
207 v8::Isolate* m_isolate; 217 v8::Isolate* m_isolate;
208 v8::Local<v8::Context> m_context; 218 v8::Local<v8::Context> m_context;
209 v8::Local<v8::Object> m_console; 219 v8::Local<v8::Object> m_console;
210 InspectedContext* m_inspectedContext; 220 InspectedContext* m_inspectedContext;
211 V8DebuggerClient* m_debuggerClient; 221 V8DebuggerClient* m_debuggerClient;
212 222
213 bool checkAndSetPrivateFlagOnConsole(const char* name, bool defaultValue) 223 bool checkAndSetPrivateFlagOnConsole(const char* name, bool defaultValue)
214 { 224 {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 575
566 void V8Console::unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info) 576 void V8Console::unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info)
567 { 577 {
568 ConsoleHelper helper(info); 578 ConsoleHelper helper(info);
569 v8::Local<v8::Function> function; 579 v8::Local<v8::Function> function;
570 if (!helper.firstArgAsFunction().ToLocal(&function)) 580 if (!helper.firstArgAsFunction().ToLocal(&function))
571 return; 581 return;
572 setFunctionBreakpoint(helper, function, V8DebuggerAgentImpl::MonitorCommandB reakpointSource, String16(), false); 582 setFunctionBreakpoint(helper, function, V8DebuggerAgentImpl::MonitorCommandB reakpointSource, String16(), false);
573 } 583 }
574 584
585 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, unsigned num)
586 {
587 ASSERT(num < V8RuntimeAgentImpl::inspectedObjectBufferSize);
588 ConsoleHelper helper(info);
589 if (V8RuntimeAgentImpl* runtimeAgent = helper.runtimeAgent()) {
590 V8RuntimeAgent::Inspectable* object = runtimeAgent->inspectedObject(num) ;
591 v8::Isolate* isolate = info.GetIsolate();
592 if (object)
593 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ;
594 else
595 info.GetReturnValue().Set(v8::Undefined(isolate));
596 }
597 }
598
575 v8::MaybeLocal<v8::Object> V8Console::createConsole(v8::Local<v8::Context> conte xt, InspectedContext* inspectedContext, bool hasMemoryAttribute) 599 v8::MaybeLocal<v8::Object> V8Console::createConsole(v8::Local<v8::Context> conte xt, InspectedContext* inspectedContext, bool hasMemoryAttribute)
576 { 600 {
577 v8::Isolate* isolate = context->GetIsolate(); 601 v8::Isolate* isolate = context->GetIsolate();
578 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 602 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
579 603
580 v8::Local<v8::Object> console; 604 v8::Local<v8::Object> console;
581 if (!createObjectWithClassName(inspectedContext->debugger(), context, "Conso le").ToLocal(&console)) 605 if (!createObjectWithClassName(inspectedContext->debugger(), context, "Conso le").ToLocal(&console))
582 return v8::MaybeLocal<v8::Object>(); 606 return v8::MaybeLocal<v8::Object>();
583 607
584 v8::Local<v8::Object> prototype; 608 v8::Local<v8::Object> prototype;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "profil eEnd", V8Console::profileEndCallback); 656 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "profil eEnd", V8Console::profileEndCallback);
633 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "clear" , V8Console::clearCallback); 657 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "clear" , V8Console::clearCallback);
634 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "table" , V8Console::tableCallback); 658 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "table" , V8Console::tableCallback);
635 659
636 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "keys", V8Console::keysCallback); 660 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "keys", V8Console::keysCallback);
637 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "values ", V8Console::valuesCallback); 661 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "values ", V8Console::valuesCallback);
638 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "debug" , V8Console::debugFunctionCallback); 662 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "debug" , V8Console::debugFunctionCallback);
639 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "undebu g", V8Console::undebugFunctionCallback); 663 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "undebu g", V8Console::undebugFunctionCallback);
640 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "monito r", V8Console::monitorFunctionCallback); 664 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "monito r", V8Console::monitorFunctionCallback);
641 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "unmoni tor", V8Console::unmonitorFunctionCallback); 665 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "unmoni tor", V8Console::unmonitorFunctionCallback);
666 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$0", V 8Console::firstInspectedObject);
667 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$1", V 8Console::secondInspectedObject);
668 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$2", V 8Console::thirdInspectedObject);
669 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$3", V 8Console::fourthInspectedObject);
670 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$4", V 8Console::fifthInspectedObject);
642 671
643 commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8: :External::New(isolate, inspectedContext)); 672 commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8: :External::New(isolate, inspectedContext));
644 return commandLineAPI; 673 return commandLineAPI;
645 } 674 }
646 675
647 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console) 676 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console)
648 { 677 {
649 v8::Isolate* isolate = context->GetIsolate(); 678 v8::Isolate* isolate = context->GetIsolate();
650 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr)); 679 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr));
651 } 680 }
(...skipping 16 matching lines...) Expand all
668 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); 697 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ());
669 if (getters.size() == 0) { 698 if (getters.size() == 0) {
670 const char* members[] = { "$0", "$1", "$2", "$3", "$4" }; 699 const char* members[] = { "$0", "$1", "$2", "$3", "$4" };
671 for (size_t i = 0; i < sizeof(members) / sizeof(const char*); ++i) 700 for (size_t i = 0; i < sizeof(members) / sizeof(const char*); ++i)
672 getters.add(members[i]); 701 getters.add(members[i]);
673 } 702 }
674 return getters.find(name) != getters.end(); 703 return getters.find(name) != getters.end();
675 } 704 }
676 705
677 } // namespace blink 706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698