| OLD | NEW |
| 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/V8DebuggerImpl.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 v8::Local<v8::Function> func; | 22 v8::Local<v8::Function> func; |
| 23 if (!v8::Function::New(context, callback, external).ToLocal(&func)) | 23 if (!v8::Function::New(context, callback, external).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 V8DebuggerImpl* unwrapDebugger(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 31 { | 31 { |
| 32 ASSERT(!info.Data().IsEmpty()); | 32 DCHECK(!info.Data().IsEmpty()); |
| 33 ASSERT(info.Data()->IsExternal()); | 33 DCHECK(info.Data()->IsExternal()); |
| 34 V8DebuggerImpl* debugger = static_cast<V8DebuggerImpl*>(info.Data().As<v8::E
xternal>()->Value()); | 34 V8DebuggerImpl* debugger = static_cast<V8DebuggerImpl*>(info.Data().As<v8::E
xternal>()->Value()); |
| 35 ASSERT(debugger); | 35 DCHECK(debugger); |
| 36 return debugger; | 36 return debugger; |
| 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, V8DebuggerImpl* debugger) |
| 42 { | 42 { |
| 43 v8::Isolate* isolate = debugger->isolate(); | 43 v8::Isolate* isolate = debugger->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, debugg
er); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!listeners->Length()) | 191 if (!listeners->Length()) |
| 192 continue; | 192 continue; |
| 193 result->Set(toV8String(info.GetIsolate(), it.first), listeners); | 193 result->Set(toV8String(info.GetIsolate(), it.first), listeners); |
| 194 } | 194 } |
| 195 info.GetReturnValue().Set(result); | 195 info.GetReturnValue().Set(result); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) | 198 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) |
| 199 { | 199 { |
| 200 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { | 200 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { |
| 201 ASSERT_NOT_REACHED(); | 201 NOTREACHED(); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { | 204 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { |
| 205 ASSERT_NOT_REACHED(); | 205 NOTREACHED(); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 | 208 |
| 209 v8::Isolate* isolate = info.GetIsolate(); | 209 v8::Isolate* isolate = info.GetIsolate(); |
| 210 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 210 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 211 | 211 |
| 212 v8::Local<v8::Function> function = info[0].As<v8::Function>(); | 212 v8::Local<v8::Function> function = info[0].As<v8::Function>(); |
| 213 v8::Local<v8::Value> receiver = info[1]; | 213 v8::Local<v8::Value> receiver = info[1]; |
| 214 OwnPtr<v8::Local<v8::Value>[]> argv = nullptr; | 214 OwnPtr<v8::Local<v8::Value>[]> argv = nullptr; |
| 215 size_t argc = 0; | 215 size_t argc = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 235 client->unmuteWarningsAndDeprecations(); | 235 client->unmuteWarningsAndDeprecations(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallback
Info<v8::Value>& info) | 238 void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallback
Info<v8::Value>& info) |
| 239 { | 239 { |
| 240 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) | 240 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) |
| 241 return; | 241 return; |
| 242 | 242 |
| 243 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | 243 v8::Local<v8::Object> object = info[0].As<v8::Object>(); |
| 244 v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCu
rrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum); | 244 v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCu
rrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum); |
| 245 ASSERT_UNUSED(!success.IsNothing(), !success.IsNothing()); | 245 DCHECK(!success.IsNothing()); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value
>& info) | 248 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value
>& info) |
| 249 { | 249 { |
| 250 if (info.Length() < 2 || !info[1]->IsString()) | 250 if (info.Length() < 2 || !info[1]->IsString()) |
| 251 return; | 251 return; |
| 252 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); | 252 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); |
| 253 if (!injectedScriptNative) | 253 if (!injectedScriptNative) |
| 254 return; | 254 return; |
| 255 | 255 |
| 256 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); | 256 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); |
| 257 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); | 257 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); |
| 258 int id = injectedScriptNative->bind(info[0], groupName); | 258 int id = injectedScriptNative->bind(info[0], groupName); |
| 259 info.GetReturnValue().Set(id); | 259 info.GetReturnValue().Set(id); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void V8InjectedScriptHost::proxyTargetValueCallback(const v8::FunctionCallbackIn
fo<v8::Value>& info) | 262 void V8InjectedScriptHost::proxyTargetValueCallback(const v8::FunctionCallbackIn
fo<v8::Value>& info) |
| 263 { | 263 { |
| 264 if (info.Length() != 1 || !info[0]->IsProxy()) { | 264 if (info.Length() != 1 || !info[0]->IsProxy()) { |
| 265 ASSERT_NOT_REACHED(); | 265 NOTREACHED(); |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); | 268 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); |
| 269 while (target->IsProxy()) | 269 while (target->IsProxy()) |
| 270 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); | 270 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); |
| 271 info.GetReturnValue().Set(target); | 271 info.GetReturnValue().Set(target); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) | 274 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 275 { | 275 { |
| 276 ASSERT(info.Length() > 0 && info[0]->IsObject()); | 276 DCHECK(info.Length() > 0 && info[0]->IsObject()); |
| 277 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); | 277 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); |
| 278 } | 278 } |
| 279 | 279 |
| 280 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) | 280 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) |
| 281 { | 281 { |
| 282 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); | 282 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |