Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/inspector/injected-script.cc

Issue 2905543004: [inspector] Prepare some methods in V8InspectorImpl to multiple sessions (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/injected-script.h ('k') | src/inspector/v8-debugger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 v8::Local<v8::Object> InjectedScript::commandLineAPI() { 408 v8::Local<v8::Object> InjectedScript::commandLineAPI() {
409 if (m_commandLineAPI.IsEmpty()) { 409 if (m_commandLineAPI.IsEmpty()) {
410 m_commandLineAPI.Reset( 410 m_commandLineAPI.Reset(
411 m_context->isolate(), 411 m_context->isolate(),
412 m_context->inspector()->console()->createCommandLineAPI( 412 m_context->inspector()->console()->createCommandLineAPI(
413 m_context->context())); 413 m_context->context()));
414 } 414 }
415 return m_commandLineAPI.Get(m_context->isolate()); 415 return m_commandLineAPI.Get(m_context->isolate());
416 } 416 }
417 417
418 InjectedScript::Scope::Scope(V8InspectorImpl* inspector, int contextGroupId) 418 InjectedScript::Scope::Scope(V8InspectorSessionImpl* session)
419 : m_inspector(inspector), 419 : m_inspector(session->inspector()),
420 m_contextGroupId(contextGroupId),
421 m_injectedScript(nullptr), 420 m_injectedScript(nullptr),
422 m_handleScope(inspector->isolate()), 421 m_handleScope(m_inspector->isolate()),
423 m_tryCatch(inspector->isolate()), 422 m_tryCatch(m_inspector->isolate()),
424 m_ignoreExceptionsAndMuteConsole(false), 423 m_ignoreExceptionsAndMuteConsole(false),
425 m_previousPauseOnExceptionsState(v8::debug::NoBreakOnException), 424 m_previousPauseOnExceptionsState(v8::debug::NoBreakOnException),
426 m_userGesture(false) {} 425 m_userGesture(false),
426 m_contextGroupId(session->contextGroupId()),
427 m_sessionId(session->sessionId()) {}
427 428
428 Response InjectedScript::Scope::initialize() { 429 Response InjectedScript::Scope::initialize() {
429 cleanup(); 430 cleanup();
430 // TODO(dgozman): what if we reattach to the same context group during 431 V8InspectorSessionImpl* session = m_inspector->sessionById(m_sessionId);
431 // evaluate? Introduce a session id?
432 V8InspectorSessionImpl* session =
433 m_inspector->sessionForContextGroup(m_contextGroupId);
434 if (!session) return Response::InternalError(); 432 if (!session) return Response::InternalError();
435 Response response = findInjectedScript(session); 433 Response response = findInjectedScript(session);
436 if (!response.isSuccess()) return response; 434 if (!response.isSuccess()) return response;
437 m_context = m_injectedScript->context()->context(); 435 m_context = m_injectedScript->context()->context();
438 m_context->Enter(); 436 m_context->Enter();
439 return Response::OK(); 437 return Response::OK();
440 } 438 }
441 439
442 void InjectedScript::Scope::installCommandLineAPI() { 440 void InjectedScript::Scope::installCommandLineAPI() {
443 DCHECK(m_injectedScript && !m_context.IsEmpty() && 441 DCHECK(m_injectedScript && !m_context.IsEmpty() &&
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 InjectedScript::Scope::~Scope() { 480 InjectedScript::Scope::~Scope() {
483 if (m_ignoreExceptionsAndMuteConsole) { 481 if (m_ignoreExceptionsAndMuteConsole) {
484 setPauseOnExceptionsState(m_previousPauseOnExceptionsState); 482 setPauseOnExceptionsState(m_previousPauseOnExceptionsState);
485 m_inspector->client()->unmuteMetrics(m_contextGroupId); 483 m_inspector->client()->unmuteMetrics(m_contextGroupId);
486 m_inspector->unmuteExceptions(m_contextGroupId); 484 m_inspector->unmuteExceptions(m_contextGroupId);
487 } 485 }
488 if (m_userGesture) m_inspector->client()->endUserGesture(); 486 if (m_userGesture) m_inspector->client()->endUserGesture();
489 cleanup(); 487 cleanup();
490 } 488 }
491 489
492 InjectedScript::ContextScope::ContextScope(V8InspectorImpl* inspector, 490 InjectedScript::ContextScope::ContextScope(V8InspectorSessionImpl* session,
493 int contextGroupId,
494 int executionContextId) 491 int executionContextId)
495 : InjectedScript::Scope(inspector, contextGroupId), 492 : InjectedScript::Scope(session),
496 m_executionContextId(executionContextId) {} 493 m_executionContextId(executionContextId) {}
497 494
498 InjectedScript::ContextScope::~ContextScope() {} 495 InjectedScript::ContextScope::~ContextScope() {}
499 496
500 Response InjectedScript::ContextScope::findInjectedScript( 497 Response InjectedScript::ContextScope::findInjectedScript(
501 V8InspectorSessionImpl* session) { 498 V8InspectorSessionImpl* session) {
502 return session->findInjectedScript(m_executionContextId, m_injectedScript); 499 return session->findInjectedScript(m_executionContextId, m_injectedScript);
503 } 500 }
504 501
505 InjectedScript::ObjectScope::ObjectScope(V8InspectorImpl* inspector, 502 InjectedScript::ObjectScope::ObjectScope(V8InspectorSessionImpl* session,
506 int contextGroupId,
507 const String16& remoteObjectId) 503 const String16& remoteObjectId)
508 : InjectedScript::Scope(inspector, contextGroupId), 504 : InjectedScript::Scope(session), m_remoteObjectId(remoteObjectId) {}
509 m_remoteObjectId(remoteObjectId) {}
510 505
511 InjectedScript::ObjectScope::~ObjectScope() {} 506 InjectedScript::ObjectScope::~ObjectScope() {}
512 507
513 Response InjectedScript::ObjectScope::findInjectedScript( 508 Response InjectedScript::ObjectScope::findInjectedScript(
514 V8InspectorSessionImpl* session) { 509 V8InspectorSessionImpl* session) {
515 std::unique_ptr<RemoteObjectId> remoteId; 510 std::unique_ptr<RemoteObjectId> remoteId;
516 Response response = RemoteObjectId::parse(m_remoteObjectId, &remoteId); 511 Response response = RemoteObjectId::parse(m_remoteObjectId, &remoteId);
517 if (!response.isSuccess()) return response; 512 if (!response.isSuccess()) return response;
518 InjectedScript* injectedScript = nullptr; 513 InjectedScript* injectedScript = nullptr;
519 response = session->findInjectedScript(remoteId.get(), injectedScript); 514 response = session->findInjectedScript(remoteId.get(), injectedScript);
520 if (!response.isSuccess()) return response; 515 if (!response.isSuccess()) return response;
521 m_objectGroupName = injectedScript->objectGroupName(*remoteId); 516 m_objectGroupName = injectedScript->objectGroupName(*remoteId);
522 response = injectedScript->findObject(*remoteId, &m_object); 517 response = injectedScript->findObject(*remoteId, &m_object);
523 if (!response.isSuccess()) return response; 518 if (!response.isSuccess()) return response;
524 m_injectedScript = injectedScript; 519 m_injectedScript = injectedScript;
525 return Response::OK(); 520 return Response::OK();
526 } 521 }
527 522
528 InjectedScript::CallFrameScope::CallFrameScope(V8InspectorImpl* inspector, 523 InjectedScript::CallFrameScope::CallFrameScope(V8InspectorSessionImpl* session,
529 int contextGroupId,
530 const String16& remoteObjectId) 524 const String16& remoteObjectId)
531 : InjectedScript::Scope(inspector, contextGroupId), 525 : InjectedScript::Scope(session), m_remoteCallFrameId(remoteObjectId) {}
532 m_remoteCallFrameId(remoteObjectId) {}
533 526
534 InjectedScript::CallFrameScope::~CallFrameScope() {} 527 InjectedScript::CallFrameScope::~CallFrameScope() {}
535 528
536 Response InjectedScript::CallFrameScope::findInjectedScript( 529 Response InjectedScript::CallFrameScope::findInjectedScript(
537 V8InspectorSessionImpl* session) { 530 V8InspectorSessionImpl* session) {
538 std::unique_ptr<RemoteCallFrameId> remoteId; 531 std::unique_ptr<RemoteCallFrameId> remoteId;
539 Response response = RemoteCallFrameId::parse(m_remoteCallFrameId, &remoteId); 532 Response response = RemoteCallFrameId::parse(m_remoteCallFrameId, &remoteId);
540 if (!response.isSuccess()) return response; 533 if (!response.isSuccess()) return response;
541 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 534 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
542 return session->findInjectedScript(remoteId.get(), m_injectedScript); 535 return session->findInjectedScript(remoteId.get(), m_injectedScript);
543 } 536 }
544 537
545 } // namespace v8_inspector 538 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/injected-script.h ('k') | src/inspector/v8-debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698