| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "platform/v8_inspector/InjectedScript.h" | 35 #include "platform/v8_inspector/InjectedScript.h" |
| 36 #include "platform/v8_inspector/InjectedScriptHost.h" | 36 #include "platform/v8_inspector/InjectedScriptHost.h" |
| 37 #include "platform/v8_inspector/InjectedScriptManager.h" | 37 #include "platform/v8_inspector/InjectedScriptManager.h" |
| 38 #include "platform/v8_inspector/RemoteObjectId.h" | 38 #include "platform/v8_inspector/RemoteObjectId.h" |
| 39 #include "platform/v8_inspector/V8DebuggerImpl.h" | 39 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 40 #include "platform/v8_inspector/V8StackTraceImpl.h" | 40 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 41 #include "platform/v8_inspector/V8StringUtil.h" | 41 #include "platform/v8_inspector/V8StringUtil.h" |
| 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 43 #include "wtf/Optional.h" | 43 #include "wtf/Optional.h" |
| 44 | 44 |
| 45 using blink::protocol::TypeBuilder::Runtime::ExceptionDetails; | |
| 46 using blink::protocol::TypeBuilder::Runtime::ExecutionContextDescription; | |
| 47 using blink::protocol::TypeBuilder::Runtime::RemoteObject; | |
| 48 using blink::protocol::TypeBuilder::Runtime::ScriptId; | |
| 49 | |
| 50 namespace blink { | 45 namespace blink { |
| 51 | 46 |
| 52 namespace V8RuntimeAgentImplState { | 47 namespace V8RuntimeAgentImplState { |
| 53 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; | 48 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; |
| 54 }; | 49 }; |
| 55 | 50 |
| 56 inline static bool asBool(const bool* const b) | 51 using protocol::Runtime::ExceptionDetails; |
| 57 { | 52 using protocol::Runtime::RemoteObject; |
| 58 return b ? *b : false; | |
| 59 } | |
| 60 | 53 |
| 61 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger) | 54 PassOwnPtr<V8RuntimeAgent> V8RuntimeAgent::create(V8Debugger* debugger) |
| 62 { | 55 { |
| 63 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger
))); | 56 return adoptPtr(new V8RuntimeAgentImpl(static_cast<V8DebuggerImpl*>(debugger
))); |
| 64 } | 57 } |
| 65 | 58 |
| 66 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger) | 59 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8DebuggerImpl* debugger) |
| 67 : m_state(nullptr) | 60 : m_state(nullptr) |
| 68 , m_frontend(nullptr) | 61 , m_frontend(nullptr) |
| 69 , m_injectedScriptManager(InjectedScriptManager::create(debugger)) | 62 , m_injectedScriptManager(InjectedScriptManager::create(debugger)) |
| 70 , m_debugger(debugger) | 63 , m_debugger(debugger) |
| 71 , m_enabled(false) | 64 , m_enabled(false) |
| 72 { | 65 { |
| 73 } | 66 } |
| 74 | 67 |
| 75 V8RuntimeAgentImpl::~V8RuntimeAgentImpl() | 68 V8RuntimeAgentImpl::~V8RuntimeAgentImpl() |
| 76 { | 69 { |
| 77 } | 70 } |
| 78 | 71 |
| 79 void V8RuntimeAgentImpl::evaluate(ErrorString* errorString, const String& expres
sion, const String* const objectGroup, const bool* const includeCommandLineAPI,
const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* executionCont
extId, const bool* const returnByValue, const bool* generatePreview, RefPtr<prot
ocol::TypeBuilder::Runtime::RemoteObject>& result, protocol::TypeBuilder::OptOut
put<bool>* wasThrown, RefPtr<protocol::TypeBuilder::Runtime::ExceptionDetails>&
exceptionDetails) | 72 void V8RuntimeAgentImpl::evaluate( |
| 73 ErrorString* errorString, |
| 74 const String& expression, |
| 75 const OptionalValue<String>& objectGroup, |
| 76 const OptionalValue<bool>& includeCommandLineAPI, |
| 77 const OptionalValue<bool>& doNotPauseOnExceptionsAndMuteConsole, |
| 78 const OptionalValue<int>& executionContextId, |
| 79 const OptionalValue<bool>& returnByValue, |
| 80 const OptionalValue<bool>& generatePreview, |
| 81 OwnPtr<RemoteObject>* result, |
| 82 OptionalValue<bool>* wasThrown, |
| 83 OwnPtr<ExceptionDetails>* exceptionDetails) |
| 80 { | 84 { |
| 81 if (!executionContextId) { | 85 if (!executionContextId.hasValue()) { |
| 82 *errorString = "Cannot find default execution context"; | 86 *errorString = "Cannot find default execution context"; |
| 83 return; | 87 return; |
| 84 } | 88 } |
| 85 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(*executionContextId); | 89 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(executionContextId.get()); |
| 86 if (!injectedScript) { | 90 if (!injectedScript) { |
| 87 *errorString = "Cannot find execution context with given id"; | 91 *errorString = "Cannot find execution context with given id"; |
| 88 return; | 92 return; |
| 89 } | 93 } |
| 90 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; | 94 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; |
| 91 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 95 if (doNotPauseOnExceptionsAndMuteConsole.get(false)) |
| 92 ignoreExceptionsScope.emplace(m_debugger); | 96 ignoreExceptionsScope.emplace(m_debugger); |
| 93 injectedScript->evaluate(errorString, expression, objectGroup ? *objectGroup
: "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePrev
iew), &result, wasThrown, &exceptionDetails); | 97 injectedScript->evaluate(errorString, expression, objectGroup.get(""), inclu
deCommandLineAPI.get(false), returnByValue.get(false), generatePreview.get(false
), result, wasThrown, exceptionDetails); |
| 94 } | 98 } |
| 95 | 99 |
| 96 void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, const String&
objectId, const String& expression, const RefPtr<JSONArray>* const optionalArgum
ents, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const
returnByValue, const bool* generatePreview, RefPtr<protocol::TypeBuilder::Runtim
e::RemoteObject>& result, protocol::TypeBuilder::OptOutput<bool>* wasThrown) | 100 void V8RuntimeAgentImpl::callFunctionOn(ErrorString* errorString, |
| 101 const String& objectId, |
| 102 const String& expression, |
| 103 PassOwnPtr<protocol::Array<protocol::Runtime::CallArgument>> optionalArgumen
ts, |
| 104 const OptionalValue<bool>& doNotPauseOnExceptionsAndMuteConsole, |
| 105 const OptionalValue<bool>& returnByValue, |
| 106 const OptionalValue<bool>& generatePreview, |
| 107 OwnPtr<RemoteObject>* result, |
| 108 OptionalValue<bool>* wasThrown) |
| 97 { | 109 { |
| 98 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); | 110 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); |
| 99 if (!remoteId) { | 111 if (!remoteId) { |
| 100 *errorString = "Invalid object id"; | 112 *errorString = "Invalid object id"; |
| 101 return; | 113 return; |
| 102 } | 114 } |
| 103 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 115 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
| 104 if (!injectedScript) { | 116 if (!injectedScript) { |
| 105 *errorString = "Inspected frame has gone"; | 117 *errorString = "Inspected frame has gone"; |
| 106 return; | 118 return; |
| 107 } | 119 } |
| 108 String arguments; | 120 String arguments; |
| 109 if (optionalArguments) | 121 if (optionalArguments) |
| 110 arguments = (*optionalArguments)->toJSONString(); | 122 arguments = protocol::toValue(optionalArguments)->toJSONString(); |
| 111 | 123 |
| 112 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; | 124 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; |
| 113 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 125 if (doNotPauseOnExceptionsAndMuteConsole.get(false)) |
| 114 ignoreExceptionsScope.emplace(m_debugger); | 126 ignoreExceptionsScope.emplace(m_debugger); |
| 115 injectedScript->callFunctionOn(errorString, objectId, expression, arguments,
asBool(returnByValue), asBool(generatePreview), &result, wasThrown); | 127 injectedScript->callFunctionOn(errorString, objectId, expression, arguments,
returnByValue.get(false), generatePreview.get(false), result, wasThrown); |
| 116 } | 128 } |
| 117 | 129 |
| 118 void V8RuntimeAgentImpl::getProperties(ErrorString* errorString, const String& o
bjectId, const bool* ownProperties, const bool* accessorPropertiesOnly, const bo
ol* generatePreview, RefPtr<protocol::TypeBuilder::Array<protocol::TypeBuilder::
Runtime::PropertyDescriptor>>& result, RefPtr<protocol::TypeBuilder::Array<proto
col::TypeBuilder::Runtime::InternalPropertyDescriptor>>& internalProperties, Ref
Ptr<protocol::TypeBuilder::Runtime::ExceptionDetails>& exceptionDetails) | 130 void V8RuntimeAgentImpl::getProperties( |
| 131 ErrorString* errorString, |
| 132 const String& objectId, |
| 133 const OptionalValue<bool>& ownProperties, |
| 134 const OptionalValue<bool>& accessorPropertiesOnly, |
| 135 const OptionalValue<bool>& generatePreview, |
| 136 OwnPtr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result, |
| 137 OwnPtr<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>* inte
rnalProperties, |
| 138 OwnPtr<ExceptionDetails>* exceptionDetails) |
| 119 { | 139 { |
| 120 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); | 140 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); |
| 121 if (!remoteId) { | 141 if (!remoteId) { |
| 122 *errorString = "Invalid object id"; | 142 *errorString = "Invalid object id"; |
| 123 return; | 143 return; |
| 124 } | 144 } |
| 125 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 145 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
| 126 if (!injectedScript) { | 146 if (!injectedScript) { |
| 127 *errorString = "Inspected frame has gone"; | 147 *errorString = "Inspected frame has gone"; |
| 128 return; | 148 return; |
| 129 } | 149 } |
| 130 | 150 |
| 131 IgnoreExceptionsScope ignoreExceptionsScope(m_debugger); | 151 IgnoreExceptionsScope ignoreExceptionsScope(m_debugger); |
| 132 | 152 |
| 133 injectedScript->getProperties(errorString, objectId, asBool(ownProperties),
asBool(accessorPropertiesOnly), asBool(generatePreview), &result, &exceptionDeta
ils); | 153 injectedScript->getProperties(errorString, objectId, ownProperties.get(false
), accessorPropertiesOnly.get(false), generatePreview.get(false), result, except
ionDetails); |
| 134 | 154 |
| 135 if (!exceptionDetails && !asBool(accessorPropertiesOnly)) | 155 if (!exceptionDetails->get() && !accessorPropertiesOnly.get(false)) |
| 136 injectedScript->getInternalProperties(errorString, objectId, &internalPr
operties, &exceptionDetails); | 156 injectedScript->getInternalProperties(errorString, objectId, internalPro
perties, exceptionDetails); |
| 137 } | 157 } |
| 138 | 158 |
| 139 void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String& o
bjectId) | 159 void V8RuntimeAgentImpl::releaseObject(ErrorString* errorString, const String& o
bjectId) |
| 140 { | 160 { |
| 141 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); | 161 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); |
| 142 if (!remoteId) { | 162 if (!remoteId) { |
| 143 *errorString = "Invalid object id"; | 163 *errorString = "Invalid object id"; |
| 144 return; | 164 return; |
| 145 } | 165 } |
| 146 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 166 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 173 { | 193 { |
| 174 *out_result = false; | 194 *out_result = false; |
| 175 } | 195 } |
| 176 | 196 |
| 177 void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enab
led) | 197 void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enab
led) |
| 178 { | 198 { |
| 179 m_state->setBoolean(V8RuntimeAgentImplState::customObjectFormatterEnabled, e
nabled); | 199 m_state->setBoolean(V8RuntimeAgentImplState::customObjectFormatterEnabled, e
nabled); |
| 180 m_injectedScriptManager->setCustomObjectFormatterEnabled(enabled); | 200 m_injectedScriptManager->setCustomObjectFormatterEnabled(enabled); |
| 181 } | 201 } |
| 182 | 202 |
| 183 void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, const String& e
xpression, const String& sourceURL, bool persistScript, int executionContextId,
protocol::TypeBuilder::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>&
exceptionDetails) | 203 void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, |
| 204 const String& expression, |
| 205 const String& sourceURL, |
| 206 bool persistScript, |
| 207 int executionContextId, |
| 208 OptionalValue<protocol::Runtime::ScriptId>* scriptId, |
| 209 OwnPtr<ExceptionDetails>* exceptionDetails) |
| 184 { | 210 { |
| 185 if (!m_enabled) { | 211 if (!m_enabled) { |
| 186 *errorString = "Runtime agent is not enabled"; | 212 *errorString = "Runtime agent is not enabled"; |
| 187 return; | 213 return; |
| 188 } | 214 } |
| 189 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(executionContextId); | 215 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(executionContextId); |
| 190 if (!injectedScript) { | 216 if (!injectedScript) { |
| 191 *errorString = "Inspected frame has gone"; | 217 *errorString = "Inspected frame has gone"; |
| 192 return; | 218 return; |
| 193 } | 219 } |
| 194 | 220 |
| 195 v8::Isolate* isolate = injectedScript->isolate(); | 221 v8::Isolate* isolate = injectedScript->isolate(); |
| 196 v8::HandleScope handles(isolate); | 222 v8::HandleScope handles(isolate); |
| 197 v8::Context::Scope scope(injectedScript->context()); | 223 v8::Context::Scope scope(injectedScript->context()); |
| 198 v8::TryCatch tryCatch(isolate); | 224 v8::TryCatch tryCatch(isolate); |
| 199 v8::Local<v8::Script> script = m_debugger->compileInternalScript(injectedScr
ipt->context(), toV8String(isolate, expression), sourceURL); | 225 v8::Local<v8::Script> script = m_debugger->compileInternalScript(injectedScr
ipt->context(), toV8String(isolate, expression), sourceURL); |
| 200 if (script.IsEmpty()) { | 226 if (script.IsEmpty()) { |
| 201 v8::Local<v8::Message> message = tryCatch.Message(); | 227 v8::Local<v8::Message> message = tryCatch.Message(); |
| 202 if (!message.IsEmpty()) | 228 if (!message.IsEmpty()) |
| 203 exceptionDetails = createExceptionDetails(isolate, message); | 229 *exceptionDetails = createExceptionDetails(isolate, message); |
| 204 else | 230 else |
| 205 *errorString = "Script compilation failed"; | 231 *errorString = "Script compilation failed"; |
| 206 return; | 232 return; |
| 207 } | 233 } |
| 208 | 234 |
| 209 if (!persistScript) | 235 if (!persistScript) |
| 210 return; | 236 return; |
| 211 | 237 |
| 212 String scriptValueId = String::number(script->GetUnboundScript()->GetId()); | 238 String scriptValueId = String::number(script->GetUnboundScript()->GetId()); |
| 213 OwnPtr<v8::Global<v8::Script>> global = adoptPtr(new v8::Global<v8::Script>(
isolate, script)); | 239 OwnPtr<v8::Global<v8::Script>> global = adoptPtr(new v8::Global<v8::Script>(
isolate, script)); |
| 214 m_compiledScripts.set(scriptValueId, global.release()); | 240 m_compiledScripts.set(scriptValueId, global.release()); |
| 215 *scriptId = scriptValueId; | 241 *scriptId = scriptValueId; |
| 216 } | 242 } |
| 217 | 243 |
| 218 void V8RuntimeAgentImpl::runScript(ErrorString* errorString, const ScriptId& scr
iptId, int executionContextId, const String* const objectGroup, const bool* cons
t doNotPauseOnExceptionsAndMuteConsole, const bool* includeCommandLineAPI, RefPt
r<RemoteObject>& result, RefPtr<ExceptionDetails>& exceptionDetails) | 244 void V8RuntimeAgentImpl::runScript(ErrorString* errorString, |
| 245 const protocol::Runtime::ScriptId& scriptId, |
| 246 int executionContextId, |
| 247 const OptionalValue<String>& objectGroup, |
| 248 const OptionalValue<bool>& doNotPauseOnExceptionsAndMuteConsole, |
| 249 const OptionalValue<bool>& includeCommandLineAPI, |
| 250 OwnPtr<RemoteObject>* result, |
| 251 OwnPtr<ExceptionDetails>* exceptionDetails) |
| 219 { | 252 { |
| 220 if (!m_enabled) { | 253 if (!m_enabled) { |
| 221 *errorString = "Runtime agent is not enabled"; | 254 *errorString = "Runtime agent is not enabled"; |
| 222 return; | 255 return; |
| 223 } | 256 } |
| 224 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(executionContextId); | 257 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(executionContextId); |
| 225 if (!injectedScript) { | 258 if (!injectedScript) { |
| 226 *errorString = "Inspected frame has gone"; | 259 *errorString = "Inspected frame has gone"; |
| 227 return; | 260 return; |
| 228 } | 261 } |
| 229 | 262 |
| 230 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; | 263 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; |
| 231 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | 264 if (doNotPauseOnExceptionsAndMuteConsole.get(false)) |
| 232 ignoreExceptionsScope.emplace(m_debugger); | 265 ignoreExceptionsScope.emplace(m_debugger); |
| 233 | 266 |
| 234 if (!m_compiledScripts.contains(scriptId)) { | 267 if (!m_compiledScripts.contains(scriptId)) { |
| 235 *errorString = "Script execution failed"; | 268 *errorString = "Script execution failed"; |
| 236 return; | 269 return; |
| 237 } | 270 } |
| 238 | 271 |
| 239 v8::Isolate* isolate = injectedScript->isolate(); | 272 v8::Isolate* isolate = injectedScript->isolate(); |
| 240 v8::HandleScope handles(isolate); | 273 v8::HandleScope handles(isolate); |
| 241 v8::Local<v8::Context> context = injectedScript->context(); | 274 v8::Local<v8::Context> context = injectedScript->context(); |
| 242 v8::Context::Scope scope(context); | 275 v8::Context::Scope scope(context); |
| 243 OwnPtr<v8::Global<v8::Script>> scriptWrapper = m_compiledScripts.take(script
Id); | 276 OwnPtr<v8::Global<v8::Script>> scriptWrapper = m_compiledScripts.take(script
Id); |
| 244 v8::Local<v8::Script> script = scriptWrapper->Get(isolate); | 277 v8::Local<v8::Script> script = scriptWrapper->Get(isolate); |
| 245 | 278 |
| 246 if (script.IsEmpty()) { | 279 if (script.IsEmpty()) { |
| 247 *errorString = "Script execution failed"; | 280 *errorString = "Script execution failed"; |
| 248 return; | 281 return; |
| 249 } | 282 } |
| 250 v8::TryCatch tryCatch(isolate); | 283 v8::TryCatch tryCatch(isolate); |
| 251 | 284 |
| 252 v8::Local<v8::Value> value; | 285 v8::Local<v8::Value> value; |
| 253 v8::MaybeLocal<v8::Value> maybeValue = injectedScript->runCompiledScript(scr
ipt, asBool(includeCommandLineAPI)); | 286 v8::MaybeLocal<v8::Value> maybeValue = injectedScript->runCompiledScript(scr
ipt, includeCommandLineAPI.get(false)); |
| 254 if (maybeValue.IsEmpty()) { | 287 if (maybeValue.IsEmpty()) { |
| 255 value = tryCatch.Exception(); | 288 value = tryCatch.Exception(); |
| 256 v8::Local<v8::Message> message = tryCatch.Message(); | 289 v8::Local<v8::Message> message = tryCatch.Message(); |
| 257 if (!message.IsEmpty()) | 290 if (!message.IsEmpty()) |
| 258 exceptionDetails = createExceptionDetails(isolate, message); | 291 *exceptionDetails = createExceptionDetails(isolate, message); |
| 259 } else { | 292 } else { |
| 260 value = maybeValue.ToLocalChecked(); | 293 value = maybeValue.ToLocalChecked(); |
| 261 } | 294 } |
| 262 | 295 |
| 263 if (value.IsEmpty()) { | 296 if (value.IsEmpty()) { |
| 264 *errorString = "Script execution failed"; | 297 *errorString = "Script execution failed"; |
| 265 return; | 298 return; |
| 266 } | 299 } |
| 267 | 300 |
| 268 result = injectedScript->wrapObject(value, objectGroup ? *objectGroup : ""); | 301 *result = injectedScript->wrapObject(value, objectGroup.get("")); |
| 269 } | 302 } |
| 270 | 303 |
| 271 void V8RuntimeAgentImpl::setInspectorState(PassRefPtr<JSONObject> state) | 304 void V8RuntimeAgentImpl::setInspectorState(PassRefPtr<JSONObject> state) |
| 272 { | 305 { |
| 273 m_state = state; | 306 m_state = state; |
| 274 } | 307 } |
| 275 | 308 |
| 276 void V8RuntimeAgentImpl::setFrontend(protocol::Frontend::Runtime* frontend) | 309 void V8RuntimeAgentImpl::setFrontend(protocol::Frontend::Runtime* frontend) |
| 277 { | 310 { |
| 278 m_frontend = frontend; | 311 m_frontend = frontend; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 void V8RuntimeAgentImpl::setClearConsoleCallback(PassOwnPtr<V8RuntimeAgent::Clea
rConsoleCallback> callback) | 350 void V8RuntimeAgentImpl::setClearConsoleCallback(PassOwnPtr<V8RuntimeAgent::Clea
rConsoleCallback> callback) |
| 318 { | 351 { |
| 319 m_injectedScriptManager->injectedScriptHost()->setClearConsoleCallback(callb
ack); | 352 m_injectedScriptManager->injectedScriptHost()->setClearConsoleCallback(callb
ack); |
| 320 } | 353 } |
| 321 | 354 |
| 322 void V8RuntimeAgentImpl::setInspectObjectCallback(PassOwnPtr<V8RuntimeAgent::Ins
pectCallback> callback) | 355 void V8RuntimeAgentImpl::setInspectObjectCallback(PassOwnPtr<V8RuntimeAgent::Ins
pectCallback> callback) |
| 323 { | 356 { |
| 324 m_injectedScriptManager->injectedScriptHost()->setInspectObjectCallback(call
back); | 357 m_injectedScriptManager->injectedScriptHost()->setInspectObjectCallback(call
back); |
| 325 } | 358 } |
| 326 | 359 |
| 327 PassRefPtr<protocol::TypeBuilder::Runtime::RemoteObject> V8RuntimeAgentImpl::wra
pObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String
& groupName, bool generatePreview) | 360 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapObject(v8::Local<v8::Context> c
ontext, v8::Local<v8::Value> value, const String& groupName, bool generatePrevie
w) |
| 328 { | 361 { |
| 329 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); | 362 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); |
| 330 if (!injectedScript) | 363 if (!injectedScript) |
| 331 return nullptr; | 364 return nullptr; |
| 332 return injectedScript->wrapObject(value, groupName, generatePreview); | 365 return injectedScript->wrapObject(value, groupName, generatePreview); |
| 333 } | 366 } |
| 334 | 367 |
| 335 PassRefPtr<protocol::TypeBuilder::Runtime::RemoteObject> V8RuntimeAgentImpl::wra
pTable(v8::Local<v8::Context> context, v8::Local<v8::Value> table, v8::Local<v8:
:Value> columns) | 368 PassOwnPtr<RemoteObject> V8RuntimeAgentImpl::wrapTable(v8::Local<v8::Context> co
ntext, v8::Local<v8::Value> table, v8::Local<v8::Value> columns) |
| 336 { | 369 { |
| 337 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); | 370 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); |
| 338 if (!injectedScript) | 371 if (!injectedScript) |
| 339 return nullptr; | 372 return nullptr; |
| 340 return injectedScript->wrapTable(table, columns); | 373 return injectedScript->wrapTable(table, columns); |
| 341 } | 374 } |
| 342 | 375 |
| 343 void V8RuntimeAgentImpl::disposeObjectGroup(const String& groupName) | 376 void V8RuntimeAgentImpl::disposeObjectGroup(const String& groupName) |
| 344 { | 377 { |
| 345 m_injectedScriptManager->releaseObjectGroup(groupName); | 378 m_injectedScriptManager->releaseObjectGroup(groupName); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 372 | 405 |
| 373 void V8RuntimeAgentImpl::reportExecutionContextCreated(v8::Local<v8::Context> co
ntext, const String& type, const String& origin, const String& humanReadableName
, const String& frameId) | 406 void V8RuntimeAgentImpl::reportExecutionContextCreated(v8::Local<v8::Context> co
ntext, const String& type, const String& origin, const String& humanReadableName
, const String& frameId) |
| 374 { | 407 { |
| 375 if (!m_enabled) | 408 if (!m_enabled) |
| 376 return; | 409 return; |
| 377 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); | 410 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
context); |
| 378 if (!injectedScript) | 411 if (!injectedScript) |
| 379 return; | 412 return; |
| 380 int contextId = injectedScript->contextId(); | 413 int contextId = injectedScript->contextId(); |
| 381 injectedScript->setOrigin(origin); | 414 injectedScript->setOrigin(origin); |
| 382 RefPtr<ExecutionContextDescription> description = ExecutionContextDescriptio
n::create() | 415 OwnPtr<protocol::Runtime::ExecutionContextDescription> description = protoco
l::Runtime::ExecutionContextDescription::create() |
| 383 .setId(contextId) | 416 .setId(contextId) |
| 384 .setName(humanReadableName) | 417 .setName(humanReadableName) |
| 385 .setOrigin(origin) | 418 .setOrigin(origin) |
| 386 .setFrameId(frameId); | 419 .setFrameId(frameId).build(); |
| 387 if (!type.isEmpty()) | 420 if (!type.isEmpty()) |
| 388 description->setType(type); | 421 description->setType(type); |
| 389 m_frontend->executionContextCreated(description.release()); | 422 m_frontend->executionContextCreated(description.release()); |
| 390 } | 423 } |
| 391 | 424 |
| 392 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context>
context) | 425 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(v8::Local<v8::Context>
context) |
| 393 { | 426 { |
| 394 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); | 427 int contextId = m_injectedScriptManager->discardInjectedScriptFor(context); |
| 395 if (!m_enabled) | 428 if (!m_enabled) |
| 396 return; | 429 return; |
| 397 m_frontend->executionContextDestroyed(contextId); | 430 m_frontend->executionContextDestroyed(contextId); |
| 398 } | 431 } |
| 399 | 432 |
| 400 PassRefPtr<protocol::TypeBuilder::Runtime::ExceptionDetails> V8RuntimeAgentImpl:
:createExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) | 433 PassOwnPtr<ExceptionDetails> V8RuntimeAgentImpl::createExceptionDetails(v8::Isol
ate* isolate, v8::Local<v8::Message> message) |
| 401 { | 434 { |
| 402 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toWTFStringWithTypeCheck(message->Get())); | 435 OwnPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toWTFStringWithTypeCheck(message->Get())).build(); |
| 403 exceptionDetails->setLine(message->GetLineNumber()); | 436 exceptionDetails->setLine(message->GetLineNumber()); |
| 404 exceptionDetails->setColumn(message->GetStartColumn()); | 437 exceptionDetails->setColumn(message->GetStartColumn()); |
| 405 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); | 438 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); |
| 406 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) | 439 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) |
| 407 exceptionDetails->setStack(m_debugger->createStackTrace(messageStackTrac
e, messageStackTrace->GetFrameCount())->buildInspectorObject()); | 440 exceptionDetails->setStack(m_debugger->createStackTrace(messageStackTrac
e, messageStackTrace->GetFrameCount())->buildInspectorObject()); |
| 408 return exceptionDetails.release(); | 441 return exceptionDetails.release(); |
| 409 } | 442 } |
| 410 | 443 |
| 411 } // namespace blink | 444 } // namespace blink |
| OLD | NEW |