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

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 354023002: DevTools: disable DOMAgent when profiler is active (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 hideHighlight(&error); 269 hideHighlight(&error);
270 270
271 m_frontend = 0; 271 m_frontend = 0;
272 m_instrumentingAgents->setInspectorDOMAgent(0); 272 m_instrumentingAgents->setInspectorDOMAgent(0);
273 disable(0); 273 disable(0);
274 reset(); 274 reset();
275 } 275 }
276 276
277 void InspectorDOMAgent::restore() 277 void InspectorDOMAgent::restore()
278 { 278 {
279 if (!enabled())
pfeldman 2014/06/27 11:35:23 restore should always be if (m_state->getBoolean(
280 return;
279 // Reset document to avoid early return from setDocument. 281 // Reset document to avoid early return from setDocument.
280 m_document = nullptr; 282 m_document = nullptr;
281 setDocument(m_pageAgent->mainFrame()->document()); 283 setDocument(m_pageAgent->mainFrame()->document());
282 } 284 }
283 285
284 Vector<Document*> InspectorDOMAgent::documents() 286 Vector<Document*> InspectorDOMAgent::documents()
285 { 287 {
286 Vector<Document*> result; 288 Vector<Document*> result;
287 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) { 289 for (Frame* frame = m_document->frame(); frame; frame = frame->tree().traver seNext()) {
288 if (!frame->isLocalFrame()) 290 if (!frame->isLocalFrame())
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 481 }
480 482
481 if (element->isPseudoElement()) { 483 if (element->isPseudoElement()) {
482 *errorString = "Cannot edit pseudo elements"; 484 *errorString = "Cannot edit pseudo elements";
483 return 0; 485 return 0;
484 } 486 }
485 487
486 return element; 488 return element;
487 } 489 }
488 490
489 void InspectorDOMAgent::enable(ErrorString*) 491 void InspectorDOMAgent::innerEnable()
490 { 492 {
491 if (enabled()) 493 if (enabled())
pfeldman 2014/06/27 11:35:23 innerEnable should not check for enabled, enable s
492 return; 494 return;
493 m_state->setBoolean(DOMAgentState::domAgentEnabled, true); 495 m_state->setBoolean(DOMAgentState::domAgentEnabled, true);
494 if (m_listener) 496 if (m_listener)
495 m_listener->domAgentWasEnabled(); 497 m_listener->domAgentWasEnabled();
496 } 498 }
497 499
500 void InspectorDOMAgent::enable(ErrorString*)
501 {
502 innerEnable();
503 m_document = nullptr;
504 setDocument(m_pageAgent->mainFrame()->document());
pfeldman 2014/06/27 11:35:23 This should be a part of innerEnable.
505 }
506
498 bool InspectorDOMAgent::enabled() const 507 bool InspectorDOMAgent::enabled() const
499 { 508 {
500 return m_state->getBoolean(DOMAgentState::domAgentEnabled); 509 return m_state->getBoolean(DOMAgentState::domAgentEnabled);
501 } 510 }
502 511
503 void InspectorDOMAgent::disable(ErrorString*) 512 void InspectorDOMAgent::disable(ErrorString*)
504 { 513 {
505 if (!enabled()) 514 if (!enabled())
506 return; 515 return;
507 m_state->setBoolean(DOMAgentState::domAgentEnabled, false); 516 m_state->setBoolean(DOMAgentState::domAgentEnabled, false);
508 reset(); 517 reset();
509 if (m_listener) 518 if (m_listener)
510 m_listener->domAgentWasDisabled(); 519 m_listener->domAgentWasDisabled();
511 } 520 }
512 521
513 void InspectorDOMAgent::getDocument(ErrorString* errorString, RefPtr<TypeBuilder ::DOM::Node>& root) 522 void InspectorDOMAgent::getDocument(ErrorString* errorString, RefPtr<TypeBuilder ::DOM::Node>& root)
514 { 523 {
515 // Backward compatibility. Mark agent as enabled when it requests document. 524 // Backward compatibility. Mark agent as enabled when it requests document.
516 enable(errorString); 525 innerEnable();
517 526
518 if (!m_document) { 527 if (!m_document) {
519 *errorString = "Document is not available"; 528 *errorString = "Document is not available";
520 return; 529 return;
521 } 530 }
522 531
523 discardFrontendBindings(); 532 discardFrontendBindings();
524 533
525 root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get()); 534 root = buildObjectForNode(m_document.get(), 2, m_documentNodeToIdMap.get());
526 } 535 }
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 if (!m_documentNodeToIdMap->contains(m_document.get())) { 2110 if (!m_documentNodeToIdMap->contains(m_document.get())) {
2102 RefPtr<TypeBuilder::DOM::Node> root; 2111 RefPtr<TypeBuilder::DOM::Node> root;
2103 getDocument(errorString, root); 2112 getDocument(errorString, root);
2104 return errorString->isEmpty(); 2113 return errorString->isEmpty();
2105 } 2114 }
2106 return true; 2115 return true;
2107 } 2116 }
2108 2117
2109 } // namespace WebCore 2118 } // namespace WebCore
2110 2119
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698