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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 using protocol::Runtime::ExceptionDetails; | 49 using protocol::Runtime::ExceptionDetails; |
50 using protocol::Runtime::RemoteObject; | 50 using protocol::Runtime::RemoteObject; |
51 | 51 |
52 static bool hasInternalError(ErrorString* errorString, bool hasError) | 52 static bool hasInternalError(ErrorString* errorString, bool hasError) |
53 { | 53 { |
54 if (hasError) | 54 if (hasError) |
55 *errorString = "Internal error"; | 55 *errorString = "Internal error"; |
56 return hasError; | 56 return hasError; |
57 } | 57 } |
58 | 58 |
59 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8InspectorSessionImpl* session, protocol
::Runtime::Frontend* frontend, protocol::DictionaryValue* state) | 59 V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8InspectorSessionImpl* session, protocol
::FrontendChannel* FrontendChannel, protocol::DictionaryValue* state) |
60 : m_session(session) | 60 : m_session(session) |
61 , m_state(state) | 61 , m_state(state) |
62 , m_frontend(frontend) | 62 , m_frontend(FrontendChannel) |
63 , m_debugger(session->debugger()) | 63 , m_debugger(session->debugger()) |
64 , m_enabled(false) | 64 , m_enabled(false) |
65 { | 65 { |
66 } | 66 } |
67 | 67 |
68 V8RuntimeAgentImpl::~V8RuntimeAgentImpl() | 68 V8RuntimeAgentImpl::~V8RuntimeAgentImpl() |
69 { | 69 { |
70 } | 70 } |
71 | 71 |
72 void V8RuntimeAgentImpl::evaluate( | 72 void V8RuntimeAgentImpl::evaluate( |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Re-initialize after running client's code, as it could have destroyed con
text or session. | 340 // Re-initialize after running client's code, as it could have destroyed con
text or session. |
341 if (!scope.initialize()) | 341 if (!scope.initialize()) |
342 return; | 342 return; |
343 scope.injectedScript()->wrapEvaluateResult(errorString, maybeResultValue, sc
ope.tryCatch(), objectGroup.fromMaybe(""), false, false, result, nullptr, except
ionDetails); | 343 scope.injectedScript()->wrapEvaluateResult(errorString, maybeResultValue, sc
ope.tryCatch(), objectGroup.fromMaybe(""), false, false, result, nullptr, except
ionDetails); |
344 } | 344 } |
345 | 345 |
346 void V8RuntimeAgentImpl::restore() | 346 void V8RuntimeAgentImpl::restore() |
347 { | 347 { |
348 if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false
)) | 348 if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false
)) |
349 return; | 349 return; |
350 m_frontend->executionContextsCleared(); | 350 m_frontend.executionContextsCleared(); |
351 ErrorString error; | 351 ErrorString error; |
352 enable(&error); | 352 enable(&error); |
353 if (m_state->booleanProperty(V8RuntimeAgentImplState::customObjectFormatterE
nabled, false)) | 353 if (m_state->booleanProperty(V8RuntimeAgentImplState::customObjectFormatterE
nabled, false)) |
354 m_session->setCustomObjectFormatterEnabled(true); | 354 m_session->setCustomObjectFormatterEnabled(true); |
355 } | 355 } |
356 | 356 |
357 void V8RuntimeAgentImpl::enable(ErrorString* errorString) | 357 void V8RuntimeAgentImpl::enable(ErrorString* errorString) |
358 { | 358 { |
359 if (m_enabled) | 359 if (m_enabled) |
360 return; | 360 return; |
(...skipping 16 matching lines...) Expand all Loading... |
377 } | 377 } |
378 | 378 |
379 void V8RuntimeAgentImpl::reset() | 379 void V8RuntimeAgentImpl::reset() |
380 { | 380 { |
381 m_compiledScripts.clear(); | 381 m_compiledScripts.clear(); |
382 if (m_enabled) { | 382 if (m_enabled) { |
383 if (const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->context
Group(m_session->contextGroupId())) { | 383 if (const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->context
Group(m_session->contextGroupId())) { |
384 for (auto& idContext : *contexts) | 384 for (auto& idContext : *contexts) |
385 idContext.second->setReported(false); | 385 idContext.second->setReported(false); |
386 } | 386 } |
387 m_frontend->executionContextsCleared(); | 387 m_frontend.executionContextsCleared(); |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 void V8RuntimeAgentImpl::reportExecutionContextCreated(InspectedContext* context
) | 391 void V8RuntimeAgentImpl::reportExecutionContextCreated(InspectedContext* context
) |
392 { | 392 { |
393 if (!m_enabled) | 393 if (!m_enabled) |
394 return; | 394 return; |
395 context->setReported(true); | 395 context->setReported(true); |
396 std::unique_ptr<protocol::Runtime::ExecutionContextDescription> description
= protocol::Runtime::ExecutionContextDescription::create() | 396 std::unique_ptr<protocol::Runtime::ExecutionContextDescription> description
= protocol::Runtime::ExecutionContextDescription::create() |
397 .setId(context->contextId()) | 397 .setId(context->contextId()) |
398 .setIsDefault(context->isDefault()) | 398 .setIsDefault(context->isDefault()) |
399 .setName(context->humanReadableName()) | 399 .setName(context->humanReadableName()) |
400 .setOrigin(context->origin()) | 400 .setOrigin(context->origin()) |
401 .setFrameId(context->frameId()).build(); | 401 .setFrameId(context->frameId()).build(); |
402 m_frontend->executionContextCreated(std::move(description)); | 402 m_frontend.executionContextCreated(std::move(description)); |
403 } | 403 } |
404 | 404 |
405 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte
xt) | 405 void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* conte
xt) |
406 { | 406 { |
407 if (m_enabled && context->isReported()) { | 407 if (m_enabled && context->isReported()) { |
408 context->setReported(false); | 408 context->setReported(false); |
409 m_frontend->executionContextDestroyed(context->contextId()); | 409 m_frontend.executionContextDestroyed(context->contextId()); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) | 413 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) |
414 { | 414 { |
415 if (m_enabled) | 415 if (m_enabled) |
416 m_frontend->inspectRequested(std::move(objectToInspect), std::move(hints
)); | 416 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints)
); |
417 } | 417 } |
418 | 418 |
419 } // namespace blink | 419 } // namespace blink |
OLD | NEW |