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

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

Issue 2199943004: [DevTools] Rename V8Debugger to V8Inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/V8InjectedScriptHost.h" 5 #include "platform/v8_inspector/V8InjectedScriptHost.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/InjectedScriptNative.h" 8 #include "platform/v8_inspector/InjectedScriptNative.h"
9 #include "platform/v8_inspector/V8Compat.h" 9 #include "platform/v8_inspector/V8Compat.h"
10 #include "platform/v8_inspector/V8DebuggerImpl.h" 10 #include "platform/v8_inspector/V8InspectorImpl.h"
11 #include "platform/v8_inspector/V8InternalValueType.h" 11 #include "platform/v8_inspector/V8InternalValueType.h"
12 #include "platform/v8_inspector/V8StringUtil.h" 12 #include "platform/v8_inspector/V8StringUtil.h"
13 #include "platform/v8_inspector/public/V8DebuggerClient.h" 13 #include "platform/v8_inspector/public/V8InspectorClient.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 void setFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::Object> o bj, const char* name, v8::FunctionCallback callback, v8::Local<v8::External> ext ernal) 19 void setFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::Object> o bj, const char* name, v8::FunctionCallback callback, v8::Local<v8::External> ext ernal)
20 { 20 {
21 v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate( ), name); 21 v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate( ), name);
22 v8::Local<v8::Function> func; 22 v8::Local<v8::Function> func;
23 if (!v8::Function::New(context, callback, external, 0, v8::ConstructorBehavi or::kThrow).ToLocal(&func)) 23 if (!v8::Function::New(context, callback, external, 0, v8::ConstructorBehavi or::kThrow).ToLocal(&func))
24 return; 24 return;
25 func->SetName(funcName); 25 func->SetName(funcName);
26 if (!obj->Set(context, funcName, func).FromMaybe(false)) 26 if (!obj->Set(context, funcName, func).FromMaybe(false))
27 return; 27 return;
28 } 28 }
29 29
30 V8DebuggerImpl* unwrapDebugger(const v8::FunctionCallbackInfo<v8::Value>& info) 30 V8InspectorImpl* unwrapInspector(const v8::FunctionCallbackInfo<v8::Value>& info )
31 { 31 {
32 DCHECK(!info.Data().IsEmpty()); 32 DCHECK(!info.Data().IsEmpty());
33 DCHECK(info.Data()->IsExternal()); 33 DCHECK(info.Data()->IsExternal());
34 V8DebuggerImpl* debugger = static_cast<V8DebuggerImpl*>(info.Data().As<v8::E xternal>()->Value()); 34 V8InspectorImpl* inspector = static_cast<V8InspectorImpl*>(info.Data().As<v8 ::External>()->Value());
35 DCHECK(debugger); 35 DCHECK(inspector);
36 return debugger; 36 return inspector;
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex t, V8DebuggerImpl* debugger) 41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex t, V8InspectorImpl* inspector)
42 { 42 {
43 v8::Isolate* isolate = debugger->isolate(); 43 v8::Isolate* isolate = inspector->isolate();
44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); 44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate);
45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg er); 45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, inspec tor);
46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); 46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal);
47 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); 47 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal);
48 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS criptHost::isTypedArrayCallback, debuggerExternal); 48 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS criptHost::isTypedArrayCallback, debuggerExternal);
49 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript Host::subtypeCallback, debuggerExternal); 49 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript Host::subtypeCallback, debuggerExternal);
50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8 InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); 50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8 InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal);
51 setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", V8I njectedScriptHost::objectHasOwnPropertyCallback, debuggerExternal); 51 setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", V8I njectedScriptHost::objectHasOwnPropertyCallback, debuggerExternal);
52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos t::bindCallback, debuggerExternal); 52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos t::bindCallback, debuggerExternal);
53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec tedScriptHost::proxyTargetValueCallback, debuggerExternal); 53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec tedScriptHost::proxyTargetValueCallback, debuggerExternal);
54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri ptHost::prototypeCallback, debuggerExternal); 54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri ptHost::prototypeCallback, debuggerExternal);
55 return injectedScriptHost; 55 return injectedScriptHost;
(...skipping 10 matching lines...) Expand all
66 66
67 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac kInfo<v8::Value>& info) 67 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac kInfo<v8::Value>& info)
68 { 68 {
69 DCHECK_EQ(info.Length(), 2); 69 DCHECK_EQ(info.Length(), 2);
70 info.GetReturnValue().Set(false); 70 info.GetReturnValue().Set(false);
71 if (!info[1]->IsFunction()) 71 if (!info[1]->IsFunction())
72 return; 72 return;
73 // Check that function is user-defined. 73 // Check that function is user-defined.
74 if (info[1].As<v8::Function>()->ScriptId() != v8::UnboundScript::kNoScriptId ) 74 if (info[1].As<v8::Function>()->ScriptId() != v8::UnboundScript::kNoScriptId )
75 return; 75 return;
76 info.GetReturnValue().Set(unwrapDebugger(info)->client()->formatAccessorsAsP roperties(info[0])); 76 info.GetReturnValue().Set(unwrapInspector(info)->client()->formatAccessorsAs Properties(info[0]));
77 } 77 }
78 78
79 void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 79 void V8InjectedScriptHost::isTypedArrayCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
80 { 80 {
81 if (info.Length() < 1) 81 if (info.Length() < 1)
82 return; 82 return;
83 83
84 info.GetReturnValue().Set(info[0]->IsTypedArray()); 84 info.GetReturnValue().Set(info[0]->IsTypedArray());
85 } 85 }
86 86
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return; 127 return;
128 } 128 }
129 if (value->IsNativeError()) { 129 if (value->IsNativeError()) {
130 info.GetReturnValue().Set(toV8StringInternalized(isolate, "error")); 130 info.GetReturnValue().Set(toV8StringInternalized(isolate, "error"));
131 return; 131 return;
132 } 132 }
133 if (value->IsProxy()) { 133 if (value->IsProxy()) {
134 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy")); 134 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy"));
135 return; 135 return;
136 } 136 }
137 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value); 137 String16 subtype = unwrapInspector(info)->client()->valueSubtype(value);
138 if (!subtype.isEmpty()) { 138 if (!subtype.isEmpty()) {
139 info.GetReturnValue().Set(toV8String(isolate, subtype)); 139 info.GetReturnValue().Set(toV8String(isolate, subtype));
140 return; 140 return;
141 } 141 }
142 } 142 }
143 143
144 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info) 144 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info)
145 { 145 {
146 if (info.Length() < 1) 146 if (info.Length() < 1)
147 return; 147 return;
148 v8::Local<v8::Array> properties; 148 v8::Local<v8::Array> properties;
149 if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentCo ntext(), info[0]).ToLocal(&properties)) 149 if (unwrapInspector(info)->internalProperties(info.GetIsolate()->GetCurrentC ontext(), info[0]).ToLocal(&properties))
150 info.GetReturnValue().Set(properties); 150 info.GetReturnValue().Set(properties);
151 } 151 }
152 152
153 void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallba ckInfo<v8::Value>& info) 153 void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallba ckInfo<v8::Value>& info)
154 { 154 {
155 if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString()) 155 if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString())
156 return; 156 return;
157 bool result = info[0].As<v8::Object>()->HasOwnProperty(info.GetIsolate()->Ge tCurrentContext(), v8::Local<v8::String>::Cast(info[1])).FromMaybe(false); 157 bool result = info[0].As<v8::Object>()->HasOwnProperty(info.GetIsolate()->Ge tCurrentContext(), v8::Local<v8::String>::Cast(info[1])).FromMaybe(false);
158 info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result)); 158 info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result));
159 } 159 }
(...skipping 24 matching lines...) Expand all
184 info.GetReturnValue().Set(target); 184 info.GetReturnValue().Set(target);
185 } 185 }
186 186
187 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8:: Value>& info) 187 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8:: Value>& info)
188 { 188 {
189 DCHECK(info.Length() > 0 && info[0]->IsObject()); 189 DCHECK(info.Length() > 0 && info[0]->IsObject());
190 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); 190 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype());
191 } 191 }
192 192
193 } // namespace blink 193 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698