| OLD | NEW |
| 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/InjectedScript.h" | 8 #include "platform/v8_inspector/InjectedScript.h" |
| 9 #include "platform/v8_inspector/InspectedContext.h" | 9 #include "platform/v8_inspector/InspectedContext.h" |
| 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 void V8Console::lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) | 575 void V8Console::lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 576 { | 576 { |
| 577 ConsoleHelper helper(info); | 577 ConsoleHelper helper(info); |
| 578 InspectedContext* context = helper.ensureInspectedContext(); | 578 InspectedContext* context = helper.ensureInspectedContext(); |
| 579 if (!context) | 579 if (!context) |
| 580 return; | 580 return; |
| 581 if (InjectedScript* injectedScript = context->getInjectedScript()) | 581 if (InjectedScript* injectedScript = context->getInjectedScript()) |
| 582 info.GetReturnValue().Set(injectedScript->lastEvaluationResult()); | 582 info.GetReturnValue().Set(injectedScript->lastEvaluationResult()); |
| 583 } | 583 } |
| 584 | 584 |
| 585 static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, bool co
pyToClipboard) |
| 586 { |
| 587 if (info.Length() < 1) |
| 588 return; |
| 589 if (!copyToClipboard) |
| 590 info.GetReturnValue().Set(info[0]); |
| 591 |
| 592 ConsoleHelper helper(info); |
| 593 InspectedContext* context = helper.ensureInspectedContext(); |
| 594 if (!context) |
| 595 return; |
| 596 InjectedScript* injectedScript = context->getInjectedScript(); |
| 597 if (!injectedScript) |
| 598 return; |
| 599 ErrorString errorString; |
| 600 OwnPtr<protocol::Runtime::RemoteObject> wrappedObject = injectedScript->wrap
Object(&errorString, info[0], "", false /** forceValueType */, false /** generat
ePreview */); |
| 601 if (!wrappedObject || !errorString.isEmpty()) |
| 602 return; |
| 603 |
| 604 OwnPtr<protocol::DictionaryValue> hints = protocol::DictionaryValue::create(
); |
| 605 if (copyToClipboard) |
| 606 hints->setBoolean("copyToClipboard", true); |
| 607 if (V8InspectorSessionImpl* session = helper.currentSession()) |
| 608 session->runtimeAgentImpl()->inspect(wrappedObject.release(), hints.rele
ase()); |
| 609 } |
| 610 |
| 611 void V8Console::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 612 { |
| 613 inspectImpl(info, false); |
| 614 } |
| 615 |
| 616 void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 617 { |
| 618 inspectImpl(info, true); |
| 619 } |
| 620 |
| 585 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
unsigned num) | 621 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
unsigned num) |
| 586 { | 622 { |
| 587 ASSERT(num < V8InspectorSessionImpl::kInspectedObjectBufferSize); | 623 ASSERT(num < V8InspectorSessionImpl::kInspectedObjectBufferSize); |
| 588 ConsoleHelper helper(info); | 624 ConsoleHelper helper(info); |
| 589 if (V8InspectorSessionImpl* session = helper.currentSession()) { | 625 if (V8InspectorSessionImpl* session = helper.currentSession()) { |
| 590 V8RuntimeAgent::Inspectable* object = session->inspectedObject(num); | 626 V8RuntimeAgent::Inspectable* object = session->inspectedObject(num); |
| 591 v8::Isolate* isolate = info.GetIsolate(); | 627 v8::Isolate* isolate = info.GetIsolate(); |
| 592 if (object) | 628 if (object) |
| 593 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext()))
; | 629 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext()))
; |
| 594 else | 630 else |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "profil
eEnd", V8Console::profileEndCallback); | 694 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "profil
eEnd", V8Console::profileEndCallback); |
| 659 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "clear"
, V8Console::clearCallback); | 695 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "clear"
, V8Console::clearCallback); |
| 660 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "table"
, V8Console::tableCallback); | 696 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "table"
, V8Console::tableCallback); |
| 661 | 697 |
| 662 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "keys",
V8Console::keysCallback); | 698 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "keys",
V8Console::keysCallback); |
| 663 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "values
", V8Console::valuesCallback); | 699 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "values
", V8Console::valuesCallback); |
| 664 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "debug"
, V8Console::debugFunctionCallback); | 700 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "debug"
, V8Console::debugFunctionCallback); |
| 665 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "undebu
g", V8Console::undebugFunctionCallback); | 701 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "undebu
g", V8Console::undebugFunctionCallback); |
| 666 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "monito
r", V8Console::monitorFunctionCallback); | 702 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "monito
r", V8Console::monitorFunctionCallback); |
| 667 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "unmoni
tor", V8Console::unmonitorFunctionCallback); | 703 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "unmoni
tor", V8Console::unmonitorFunctionCallback); |
| 704 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "inspec
t", V8Console::inspectCallback); |
| 705 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "copy",
V8Console::copyCallback); |
| 668 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$_", V
8Console::lastEvaluationResultCallback); | 706 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$_", V
8Console::lastEvaluationResultCallback); |
| 669 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$0", V
8Console::inspectedObject0); | 707 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$0", V
8Console::inspectedObject0); |
| 670 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$1", V
8Console::inspectedObject1); | 708 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$1", V
8Console::inspectedObject1); |
| 671 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$2", V
8Console::inspectedObject2); | 709 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$2", V
8Console::inspectedObject2); |
| 672 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$3", V
8Console::inspectedObject3); | 710 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$3", V
8Console::inspectedObject3); |
| 673 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$4", V
8Console::inspectedObject4); | 711 createBoundFunctionProperty(context, commandLineAPI, commandLineAPI, "$4", V
8Console::inspectedObject4); |
| 674 | 712 |
| 675 commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8:
:External::New(isolate, inspectedContext)); | 713 commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8:
:External::New(isolate, inspectedContext)); |
| 676 return commandLineAPI; | 714 return commandLineAPI; |
| 677 } | 715 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 700 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); | 738 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); |
| 701 if (getters.size() == 0) { | 739 if (getters.size() == 0) { |
| 702 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; | 740 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; |
| 703 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) | 741 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) |
| 704 getters.add(members[i]); | 742 getters.add(members[i]); |
| 705 } | 743 } |
| 706 return getters.find(name) != getters.end(); | 744 return getters.find(name) != getters.end(); |
| 707 } | 745 } |
| 708 | 746 |
| 709 } // namespace blink | 747 } // namespace blink |
| OLD | NEW |