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

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

Issue 1004113004: [DevTools] Do not instrument with InspectorInspectorAgent. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ASSERT(isMainThread) Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
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 21 matching lines...) Expand all
32 #include "core/inspector/InspectorInspectorAgent.h" 32 #include "core/inspector/InspectorInspectorAgent.h"
33 33
34 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
35 #include "bindings/core/v8/ScriptController.h" 35 #include "bindings/core/v8/ScriptController.h"
36 #include "core/InspectorFrontend.h" 36 #include "core/InspectorFrontend.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/inspector/InjectedScriptHost.h" 39 #include "core/inspector/InjectedScriptHost.h"
40 #include "core/inspector/InjectedScriptManager.h" 40 #include "core/inspector/InjectedScriptManager.h"
41 #include "core/inspector/InspectorState.h" 41 #include "core/inspector/InspectorState.h"
42 #include "core/inspector/InstrumentingAgents.h"
43 #include "core/loader/DocumentLoader.h" 42 #include "core/loader/DocumentLoader.h"
44 #include "core/page/Page.h" 43 #include "core/page/Page.h"
45 #include "platform/weborigin/SecurityOrigin.h" 44 #include "platform/weborigin/SecurityOrigin.h"
46 #include "wtf/text/StringBuilder.h" 45 #include "wtf/text/StringBuilder.h"
47 46
48 namespace blink { 47 namespace blink {
49 48
50 namespace InspectorAgentState { 49 namespace InspectorAgentState {
51 static const char inspectorAgentEnabled[] = "inspectorAgentEnabled"; 50 static const char inspectorAgentEnabled[] = "inspectorAgentEnabled";
52 } 51 }
53 52
54 InspectorInspectorAgent::InspectorInspectorAgent(InjectedScriptManager* injected ScriptManager) 53 InspectorInspectorAgent::InspectorInspectorAgent(InjectedScriptManager* injected ScriptManager)
55 : InspectorBaseAgent<InspectorInspectorAgent, InspectorFrontend::Inspector>( "Inspector") 54 : InspectorBaseAgent<InspectorInspectorAgent, InspectorFrontend::Inspector>( "Inspector")
56 , m_injectedScriptManager(injectedScriptManager) 55 , m_injectedScriptManager(injectedScriptManager)
57 { 56 {
58 } 57 }
59 58
60 InspectorInspectorAgent::~InspectorInspectorAgent() 59 InspectorInspectorAgent::~InspectorInspectorAgent()
61 { 60 {
62 #if !ENABLE(OILPAN)
63 m_instrumentingAgents->setInspectorInspectorAgent(nullptr);
64 #endif
65 } 61 }
66 62
67 DEFINE_TRACE(InspectorInspectorAgent) 63 DEFINE_TRACE(InspectorInspectorAgent)
68 { 64 {
69 visitor->trace(m_injectedScriptManager); 65 visitor->trace(m_injectedScriptManager);
70 InspectorBaseAgent::trace(visitor); 66 InspectorBaseAgent::trace(visitor);
71 } 67 }
72 68
73 void InspectorInspectorAgent::init()
74 {
75 m_instrumentingAgents->setInspectorInspectorAgent(this);
76 }
77
78 void InspectorInspectorAgent::enable(ErrorString*) 69 void InspectorInspectorAgent::enable(ErrorString*)
79 { 70 {
80 m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, true); 71 m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, true);
81
82 for (Vector<pair<long, String>>::iterator it = m_pendingEvaluateTestCommands .begin(); frontend() && it != m_pendingEvaluateTestCommands.end(); ++it) 72 for (Vector<pair<long, String>>::iterator it = m_pendingEvaluateTestCommands .begin(); frontend() && it != m_pendingEvaluateTestCommands.end(); ++it)
83 frontend()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*i t).second); 73 frontend()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*i t).second);
84 m_pendingEvaluateTestCommands.clear(); 74 m_pendingEvaluateTestCommands.clear();
85 } 75 }
86 76
87 void InspectorInspectorAgent::disable(ErrorString*) 77 void InspectorInspectorAgent::disable(ErrorString*)
88 { 78 {
89 m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, false); 79 m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, false);
90 m_pendingEvaluateTestCommands.clear(); 80 m_pendingEvaluateTestCommands.clear();
91 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects(); 81 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
92 m_injectedScriptManager->discardInjectedScripts(); 82 m_injectedScriptManager->discardInjectedScripts();
93 } 83 }
94 84
95 void InspectorInspectorAgent::domContentLoadedEventFired(LocalFrame* frame) 85 void InspectorInspectorAgent::didCommitLoadForLocalFrame(LocalFrame* frame)
96 { 86 {
97 if (frame != frame->localFrameRoot()) 87 if (frame != frame->localFrameRoot())
98 return; 88 return;
99 89
100 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects(); 90 m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
101 } 91 }
102 92
93 void InspectorInspectorAgent::restore()
94 {
95 if (m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) {
96 ErrorString error;
97 enable(&error);
98 }
99 }
100
103 void InspectorInspectorAgent::evaluateForTestInFrontend(long callId, const Strin g& script) 101 void InspectorInspectorAgent::evaluateForTestInFrontend(long callId, const Strin g& script)
104 { 102 {
105 if (m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) { 103 if (m_state->getBoolean(InspectorAgentState::inspectorAgentEnabled)) {
106 frontend()->evaluateForTestInFrontend(static_cast<int>(callId), script); 104 frontend()->evaluateForTestInFrontend(static_cast<int>(callId), script);
107 frontend()->flush(); 105 frontend()->flush();
108 } else { 106 } else {
109 m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script)) ; 107 m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script)) ;
110 } 108 }
111 } 109 }
112 110
113 void InspectorInspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObj ect> objectToInspect, PassRefPtr<JSONObject> hints) 111 void InspectorInspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObj ect> objectToInspect, PassRefPtr<JSONObject> hints)
114 { 112 {
115 if (frontend() && m_state->getBoolean(InspectorAgentState::inspectorAgentEna bled)) 113 if (frontend() && m_state->getBoolean(InspectorAgentState::inspectorAgentEna bled))
116 frontend()->inspect(objectToInspect, hints); 114 frontend()->inspect(objectToInspect, hints);
117 } 115 }
118 116
119 } // namespace blink 117 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorInspectorAgent.h ('k') | Source/core/inspector/InspectorInstrumentation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698