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/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
10 #include "platform/v8_inspector/InjectedScriptHost.h" | 10 #include "platform/v8_inspector/InjectedScriptHost.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | 286 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 ASSERT(isolate->InContext()); | 290 ASSERT(isolate->InContext()); |
291 v8::TryCatch tryCatch(isolate); | 291 v8::TryCatch tryCatch(isolate); |
292 v8::Local<v8::Value> result; | 292 v8::Local<v8::Value> result; |
293 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(isolate->GetCurrentC
ontext(), info.Holder()); | 293 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(isolate->GetCurrentC
ontext(), info.Holder()); |
294 if (!host->debugger()) | 294 if (!host->debugger()) |
295 return; | 295 return; |
296 if (!host->debugger()->compileAndRunInternalScript(isolate->GetCurrentContex
t(), expression).ToLocal(&result)) { | 296 if (!host->debugger()->client()->compileAndRunInternalScript(expression).ToL
ocal(&result)) { |
297 v8SetReturnValue(info, tryCatch.ReThrow()); | 297 v8SetReturnValue(info, tryCatch.ReThrow()); |
298 return; | 298 return; |
299 } | 299 } |
300 v8SetReturnValue(info, result); | 300 v8SetReturnValue(info, result); |
301 } | 301 } |
302 | 302 |
303 static void setExceptionAsReturnValue(const v8::FunctionCallbackInfo<v8::Value>&
info, v8::Local<v8::Object> returnValue, v8::TryCatch& tryCatch) | 303 static void setExceptionAsReturnValue(const v8::FunctionCallbackInfo<v8::Value>&
info, v8::Local<v8::Object> returnValue, v8::TryCatch& tryCatch) |
304 { | 304 { |
305 v8::Isolate* isolate = info.GetIsolate(); | 305 v8::Isolate* isolate = info.GetIsolate(); |
306 returnValue->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.Except
ion()); | 306 returnValue->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.Except
ion()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 return; | 339 return; |
340 } | 340 } |
341 | 341 |
342 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI
Symbol(isolate); | 342 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI
Symbol(isolate); |
343 v8::Local<v8::Object> global = context->Global(); | 343 v8::Local<v8::Object> global = context->Global(); |
344 if (info.Length() >= 2 && info[1]->IsObject()) { | 344 if (info.Length() >= 2 && info[1]->IsObject()) { |
345 v8::Local<v8::Object> commandLineAPI = info[1]->ToObject(isolate); | 345 v8::Local<v8::Object> commandLineAPI = info[1]->ToObject(isolate); |
346 global->Set(commandLineAPISymbolValue, commandLineAPI); | 346 global->Set(commandLineAPISymbolValue, commandLineAPI); |
347 } | 347 } |
348 | 348 |
349 v8::MaybeLocal<v8::Value> result = host->debugger()->runCompiledScript(conte
xt, script); | 349 v8::MaybeLocal<v8::Value> result = host->debugger()->client()->runCompiledSc
ript(context, script); |
350 if (result.IsEmpty()) { | 350 if (result.IsEmpty()) { |
351 global->Delete(context, commandLineAPISymbolValue); | 351 global->Delete(context, commandLineAPISymbolValue); |
352 setExceptionAsReturnValue(info, wrappedResult, tryCatch); | 352 setExceptionAsReturnValue(info, wrappedResult, tryCatch); |
353 return; | 353 return; |
354 } | 354 } |
355 | 355 |
356 global->Delete(context, commandLineAPISymbolValue); | 356 global->Delete(context, commandLineAPISymbolValue); |
357 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result.ToLoca
lChecked()); | 357 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result.ToLoca
lChecked()); |
358 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8:
:Undefined(isolate)); | 358 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8:
:Undefined(isolate)); |
359 v8SetReturnValue(info, wrappedResult); | 359 v8SetReturnValue(info, wrappedResult); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } // namespace | 592 } // namespace |
593 | 593 |
594 v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8::
Isolate* isolate) | 594 v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8::
Isolate* isolate) |
595 { | 595 { |
596 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR
RAY_LENGTH(V8InjectedScriptHostMethods)); | 596 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR
RAY_LENGTH(V8InjectedScriptHostMethods)); |
597 std::copy(V8InjectedScriptHostMethods, V8InjectedScriptHostMethods + WTF_ARR
AY_LENGTH(V8InjectedScriptHostMethods), methods.begin()); | 597 std::copy(V8InjectedScriptHostMethods, V8InjectedScriptHostMethods + WTF_ARR
AY_LENGTH(V8InjectedScriptHostMethods), methods.begin()); |
598 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes; | 598 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes; |
599 return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, at
tributes); | 599 return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, at
tributes); |
600 } | 600 } |
601 | 601 |
602 v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Local<v8::FunctionTemplate>
constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host) | 602 v8::Local<v8::Object> V8InjectedScriptHost::wrap(V8DebuggerClient* client, v8::L
ocal<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context,
InjectedScriptHost* host) |
603 { | 603 { |
604 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); | 604 return InjectedScriptHostWrapper::wrap(client, constructorTemplate, context,
host); |
605 } | 605 } |
606 | 606 |
607 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) | 607 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) |
608 { | 608 { |
609 return InjectedScriptHostWrapper::unwrap(context, object); | 609 return InjectedScriptHostWrapper::unwrap(context, object); |
610 } | 610 } |
611 | 611 |
612 } // namespace blink | 612 } // namespace blink |
OLD | NEW |