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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp

Issue 2205913002: [DevTools] Split a part of V8Inspector into V8Debugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-inspector-rename
Patch Set: context scope! Created 4 years, 4 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/Platform.h" 7 #include "platform/inspector_protocol/Platform.h"
8 #include "platform/inspector_protocol/String16.h" 8 #include "platform/inspector_protocol/String16.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InspectedContext.h" 10 #include "platform/v8_inspector/InspectedContext.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes sage)); 101 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes sage));
102 reportCall(type, arguments); 102 reportCall(type, arguments);
103 } 103 }
104 104
105 void reportCall(ConsoleAPIType type, const std::vector<v8::Local<v8::Value>> & arguments) 105 void reportCall(ConsoleAPIType type, const std::vector<v8::Local<v8::Value>> & arguments)
106 { 106 {
107 InspectedContext* inspectedContext = ensureInspectedContext(); 107 InspectedContext* inspectedContext = ensureInspectedContext();
108 if (!inspectedContext) 108 if (!inspectedContext)
109 return; 109 return;
110 V8InspectorImpl* inspector = inspectedContext->inspector(); 110 V8InspectorImpl* inspector = inspectedContext->inspector();
111 std::unique_ptr<V8ConsoleMessage> message = V8ConsoleMessage::createForC onsoleAPI(inspector->client()->currentTimeMS(), type, arguments, inspector->capt ureStackTraceImpl(false), inspectedContext); 111 std::unique_ptr<V8ConsoleMessage> message = V8ConsoleMessage::createForC onsoleAPI(inspector->client()->currentTimeMS(), type, arguments, inspector->debu gger()->captureStackTrace(false), inspectedContext);
112 inspector->ensureConsoleMessageStorage(inspectedContext->contextGroupId( ))->addMessage(std::move(message)); 112 inspector->ensureConsoleMessageStorage(inspectedContext->contextGroupId( ))->addMessage(std::move(message));
113 } 113 }
114 114
115 void reportDeprecatedCall(const char* id, const String16& message) 115 void reportDeprecatedCall(const char* id, const String16& message)
116 { 116 {
117 if (checkAndSetPrivateFlagOnConsole(id, false)) 117 if (checkAndSetPrivateFlagOnConsole(id, false))
118 return; 118 return;
119 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes sage)); 119 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes sage));
120 reportCall(ConsoleAPIType::kWarning, arguments); 120 reportCall(ConsoleAPIType::kWarning, arguments);
121 } 121 }
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (object) 649 if (object)
650 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ; 650 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ;
651 else 651 else
652 info.GetReturnValue().Set(v8::Undefined(isolate)); 652 info.GetReturnValue().Set(v8::Undefined(isolate));
653 } 653 }
654 } 654 }
655 655
656 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute) 656 v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex t, bool hasMemoryAttribute)
657 { 657 {
658 v8::Local<v8::Context> context = inspectedContext->context(); 658 v8::Local<v8::Context> context = inspectedContext->context();
659 v8::Context::Scope contextScope(context);
659 v8::Isolate* isolate = context->GetIsolate(); 660 v8::Isolate* isolate = context->GetIsolate();
660 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks); 661 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
661 662
662 v8::Local<v8::Object> console = v8::Object::New(isolate); 663 v8::Local<v8::Object> console = v8::Object::New(isolate);
663 664
664 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack); 665 createBoundFunctionProperty(context, console, "debug", V8Console::debugCallb ack);
665 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack); 666 createBoundFunctionProperty(context, console, "error", V8Console::errorCallb ack);
666 createBoundFunctionProperty(context, console, "info", V8Console::infoCallbac k); 667 createBoundFunctionProperty(context, console, "info", V8Console::infoCallbac k);
667 createBoundFunctionProperty(context, console, "log", V8Console::logCallback) ; 668 createBoundFunctionProperty(context, console, "log", V8Console::logCallback) ;
668 createBoundFunctionProperty(context, console, "warn", V8Console::warnCallbac k); 669 createBoundFunctionProperty(context, console, "warn", V8Console::warnCallbac k);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 continue; 823 continue;
823 if (name->IsString()) { 824 if (name->IsString()) {
824 v8::Local<v8::Value> descriptor; 825 v8::Local<v8::Value> descriptor;
825 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor); 826 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor);
826 DCHECK(success); 827 DCHECK(success);
827 } 828 }
828 } 829 }
829 } 830 }
830 831
831 } // namespace blink 832 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698