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

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

Issue 2139393002: Revert of Remove constructor from remaining functions that aren't constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 259 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
260 { 260 {
261 info.GetReturnValue().Set(info.Data()); 261 info.GetReturnValue().Set(info.Data());
262 } 262 }
263 263
264 void createBoundFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::O bject> console, const char* name, v8::FunctionCallback callback, const char* des cription = nullptr) 264 void createBoundFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::O bject> console, const char* name, v8::FunctionCallback callback, const char* des cription = nullptr)
265 { 265 {
266 v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate( ), name); 266 v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate( ), name);
267 v8::Local<v8::Function> func; 267 v8::Local<v8::Function> func;
268 if (!v8::Function::New(context, callback, console, 0, v8::ConstructorBehavio r::kThrow).ToLocal(&func)) 268 if (!v8::Function::New(context, callback, console).ToLocal(&func))
269 return; 269 return;
270 func->SetName(funcName); 270 func->SetName(funcName);
271 if (description) { 271 if (description) {
272 v8::Local<v8::String> returnValue = toV8String(context->GetIsolate(), de scription); 272 v8::Local<v8::String> returnValue = toV8String(context->GetIsolate(), de scription);
273 v8::Local<v8::Function> toStringFunction; 273 v8::Local<v8::Function> toStringFunction;
274 if (v8::Function::New(context, returnDataCallback, returnValue, 0, v8::C onstructorBehavior::kThrow).ToLocal(&toStringFunction)) 274 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal( &toStringFunction))
275 func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction); 275 func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction);
276 } 276 }
277 if (!console->Set(context, funcName, func).FromMaybe(false)) 277 if (!console->Set(context, funcName, func).FromMaybe(false))
278 return; 278 return;
279 } 279 }
280 280
281 } // namespace 281 } // namespace
282 282
283 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 283 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
284 { 284 {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback); 669 createBoundFunctionProperty(context, console, "timeline", V8Console::timelin eCallback);
670 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback); 670 createBoundFunctionProperty(context, console, "timelineEnd", V8Console::time lineEndCallback);
671 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k); 671 createBoundFunctionProperty(context, console, "time", V8Console::timeCallbac k);
672 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback); 672 createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndC allback);
673 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback); 673 createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeSt ampCallback);
674 674
675 bool success = console->SetPrototype(context, v8::Object::New(isolate)).From Maybe(false); 675 bool success = console->SetPrototype(context, v8::Object::New(isolate)).From Maybe(false);
676 DCHECK(success); 676 DCHECK(success);
677 677
678 if (hasMemoryAttribute) 678 if (hasMemoryAttribute)
679 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, v8::Cons tructorBehavior::kThrow).ToLocalChecked(), v8::Function::New(context, V8Console: :memorySetterCallback, v8::Local<v8::Value>(), 0, v8::ConstructorBehavior::kThro w).ToLocalChecked(), static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT); 679 console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Functi on::New(isolate, V8Console::memorySetterCallback), static_cast<v8::PropertyAttri bute>(v8::None), v8::DEFAULT);
680 680
681 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext)); 681 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, inspectedContext));
682 return console; 682 return console;
683 } 683 }
684 684
685 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console) 685 void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8 ::Local<v8::Object> console)
686 { 686 {
687 v8::Isolate* isolate = context->GetIsolate(); 687 v8::Isolate* isolate = context->GetIsolate();
688 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr)); 688 console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::Extern al::New(isolate, nullptr));
689 } 689 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 continue; 809 continue;
810 if (name->IsString()) { 810 if (name->IsString()) {
811 v8::Local<v8::Value> descriptor; 811 v8::Local<v8::Value> descriptor;
812 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor); 812 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor);
813 DCHECK(success); 813 DCHECK(success);
814 } 814 }
815 } 815 }
816 } 816 }
817 817
818 } // namespace blink 818 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698