2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #ifndef InspectorConsoleAgent_h
26 #define InspectorConsoleAgent_h
28 #include "bindings/core/v8/ScriptState.h"
29 #include "bindings/core/v8/ScriptString.h"
30 #include "core/InspectorFrontend.h"
31 #include "core/inspector/ConsoleAPITypes.h"
32 #include "core/inspector/InspectorBaseAgent.h"
33 #include "core/frame/ConsoleTypes.h"
34 #include "wtf/Forward.h"
35 #include "wtf/HashCountedSet.h"
36 #include "wtf/HashMap.h"
37 #include "wtf/Noncopyable.h"
38 #include "wtf/Vector.h"
39 #include "wtf/text/StringHash.h"
44 class ConsoleMessageStorage;
47 class InspectorFrontend;
48 class InjectedScriptManager;
49 class InspectorTimelineAgent;
51 class ThreadableLoaderClient;
54 typedef String ErrorString;
56 class InspectorConsoleAgent : public InspectorBaseAgent<InspectorConsoleAgent>, public InspectorBackendDispatcher::ConsoleCommandHandler {
57 WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
59 InspectorConsoleAgent(InspectorTimelineAgent*, InjectedScriptManager*);
60 virtual ~InspectorConsoleAgent();
61 virtual void trace(Visitor*) override;
63 virtual void enable(ErrorString*) override final;
64 virtual void disable(ErrorString*) override final;
65 virtual void clearMessages(ErrorString*) override;
66 bool enabled() { return m_enabled; }
68 virtual void setFrontend(InspectorFrontend*) override final;
69 virtual void clearFrontend() override final;
70 virtual void restore() override final;
72 void addMessageToConsole(ConsoleMessage*);
73 void consoleMessagesCleared();
75 void setTracingBasedTimeline(ErrorString*, bool enabled);
76 void consoleTimeline(ExecutionContext*, const String& title, ScriptState*);
77 void consoleTimelineEnd(ExecutionContext*, const String& title, ScriptState*);
79 void didCommitLoad(LocalFrame*, DocumentLoader*);
81 void didFinishXHRLoading(XMLHttpRequest*, ThreadableLoaderClient*, unsigned long requestIdentifier, ScriptString, const AtomicString& method, const String& url);
82 void addProfileFinishedMessageToConsole(PassRefPtrWillBeRawPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
83 void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
84 virtual void setMonitoringXHREnabled(ErrorString*, bool enabled) override;
85 virtual void addInspectedNode(ErrorString*, int nodeId) = 0;
86 virtual void addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId) override;
88 virtual bool isWorkerAgent() = 0;
90 virtual void setLastEvaluationResult(ErrorString*, const String& objectId) override;
93 void sendConsoleMessageToFrontend(ConsoleMessage*, bool generatePreview);
94 virtual ConsoleMessageStorage* messageStorage() = 0;
96 RawPtrWillBeMember<InspectorTimelineAgent> m_timelineAgent;
97 RawPtrWillBeMember<InjectedScriptManager> m_injectedScriptManager;
98 InspectorFrontend::Console* m_frontend;
101 static int s_enabledAgentCount;
107 #endif // !defined(InspectorConsoleAgent_h)