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