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

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

Issue 464293002: [DevTools] ConsoleMessage storage moved from ConsoleAgent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@remove-can-generate
Patch Set: Created 6 years, 3 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 | « Source/core/inspector/PageConsoleAgent.h ('k') | Source/core/inspector/WorkerConsoleAgent.h » ('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) 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/inspector/PageConsoleAgent.h" 32 #include "core/inspector/PageConsoleAgent.h"
33 33
34 #include "core/dom/Node.h" 34 #include "core/dom/Node.h"
35 #include "core/dom/NodeTraversal.h" 35 #include "core/dom/NodeTraversal.h"
36 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/frame/FrameConsole.h"
37 #include "core/inspector/InjectedScriptHost.h" 38 #include "core/inspector/InjectedScriptHost.h"
38 #include "core/inspector/InjectedScriptManager.h" 39 #include "core/inspector/InjectedScriptManager.h"
39 #include "core/inspector/InspectorDOMAgent.h" 40 #include "core/inspector/InspectorDOMAgent.h"
41 #include "core/page/Page.h"
40 42
41 namespace blink { 43 namespace blink {
42 44
43 PageConsoleAgent::PageConsoleAgent(InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent, InspectorTimelineAgent* timelineAgent, InspectorTr acingAgent* tracingAgent) 45 PageConsoleAgent::PageConsoleAgent(InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent, InspectorTimelineAgent* timelineAgent, InspectorTr acingAgent* tracingAgent, Page* page)
44 : InspectorConsoleAgent(timelineAgent, tracingAgent, injectedScriptManager) 46 : InspectorConsoleAgent(timelineAgent, tracingAgent, injectedScriptManager)
45 , m_inspectorDOMAgent(domAgent) 47 , m_inspectorDOMAgent(domAgent)
48 , m_page(page)
46 { 49 {
47 } 50 }
48 51
49 PageConsoleAgent::~PageConsoleAgent() 52 PageConsoleAgent::~PageConsoleAgent()
50 { 53 {
51 #if !ENABLE(OILPAN) 54 #if !ENABLE(OILPAN)
52 m_inspectorDOMAgent = nullptr; 55 m_inspectorDOMAgent = nullptr;
53 #endif 56 #endif
54 } 57 }
55 58
56 void PageConsoleAgent::trace(Visitor* visitor) 59 void PageConsoleAgent::trace(Visitor* visitor)
57 { 60 {
58 visitor->trace(m_inspectorDOMAgent); 61 visitor->trace(m_inspectorDOMAgent);
62 visitor->trace(m_page);
59 InspectorConsoleAgent::trace(visitor); 63 InspectorConsoleAgent::trace(visitor);
60 } 64 }
61 65
62 void PageConsoleAgent::clearMessages(ErrorString* errorString) 66 void PageConsoleAgent::clearMessages(ErrorString* errorString)
63 { 67 {
64 m_inspectorDOMAgent->releaseDanglingNodes(); 68 m_inspectorDOMAgent->releaseDanglingNodes();
65 InspectorConsoleAgent::clearMessages(errorString); 69 InspectorConsoleAgent::clearMessages(errorString);
66 } 70 }
67 71
72 ConsoleMessageStorage* PageConsoleAgent::messageStorage()
73 {
74 return m_page->deprecatedLocalMainFrame()->console().messageStorage();
75 }
76
68 class InspectableNode FINAL : public InjectedScriptHost::InspectableObject { 77 class InspectableNode FINAL : public InjectedScriptHost::InspectableObject {
69 public: 78 public:
70 explicit InspectableNode(Node* node) : m_node(node) { } 79 explicit InspectableNode(Node* node) : m_node(node) { }
71 virtual ScriptValue get(ScriptState* state) OVERRIDE 80 virtual ScriptValue get(ScriptState* state) OVERRIDE
72 { 81 {
73 return InjectedScriptHost::nodeAsScriptValue(state, m_node); 82 return InjectedScriptHost::nodeAsScriptValue(state, m_node);
74 } 83 }
75 private: 84 private:
76 Node* m_node; 85 Node* m_node;
77 }; 86 };
78 87
79 void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId) 88 void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId)
80 { 89 {
81 Node* node = m_inspectorDOMAgent->nodeForId(nodeId); 90 Node* node = m_inspectorDOMAgent->nodeForId(nodeId);
82 if (!node) { 91 if (!node) {
83 *errorString = "nodeId is not valid"; 92 *errorString = "nodeId is not valid";
84 return; 93 return;
85 } 94 }
86 while (node->isInShadowTree()) { 95 while (node->isInShadowTree()) {
87 Node& ancestor = NodeTraversal::highestAncestorOrSelf(*node); 96 Node& ancestor = NodeTraversal::highestAncestorOrSelf(*node);
88 if (!ancestor.isShadowRoot() || toShadowRoot(ancestor).type() == ShadowR oot::AuthorShadowRoot) 97 if (!ancestor.isShadowRoot() || toShadowRoot(ancestor).type() == ShadowR oot::AuthorShadowRoot)
89 break; 98 break;
90 // User agent shadow root, keep climbing up. 99 // User agent shadow root, keep climbing up.
91 node = toShadowRoot(ancestor).host(); 100 node = toShadowRoot(ancestor).host();
92 } 101 }
93 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableNode(node))); 102 m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(n ew InspectableNode(node)));
94 } 103 }
95 104
96 } // namespace blink 105 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/PageConsoleAgent.h ('k') | Source/core/inspector/WorkerConsoleAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698