Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / inspector / InspectorConsoleAgent.h
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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.
23  */
24
25 #ifndef InspectorConsoleAgent_h
26 #define InspectorConsoleAgent_h
27
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"
40
41 namespace blink {
42
43 class ConsoleMessage;
44 class ConsoleMessageStorage;
45 class DocumentLoader;
46 class LocalFrame;
47 class InspectorFrontend;
48 class InjectedScriptManager;
49 class InspectorTimelineAgent;
50 class ScriptProfile;
51 class ThreadableLoaderClient;
52 class XMLHttpRequest;
53
54 typedef String ErrorString;
55
56 class InspectorConsoleAgent : public InspectorBaseAgent<InspectorConsoleAgent>, public InspectorBackendDispatcher::ConsoleCommandHandler {
57     WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
58 public:
59     InspectorConsoleAgent(InspectorTimelineAgent*, InjectedScriptManager*);
60     virtual ~InspectorConsoleAgent();
61     virtual void trace(Visitor*) override;
62
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; }
67
68     virtual void setFrontend(InspectorFrontend*) override final;
69     virtual void clearFrontend() override final;
70     virtual void restore() override final;
71
72     void addMessageToConsole(ConsoleMessage*);
73     void consoleMessagesCleared();
74
75     void setTracingBasedTimeline(ErrorString*, bool enabled);
76     void consoleTimeline(ExecutionContext*, const String& title, ScriptState*);
77     void consoleTimelineEnd(ExecutionContext*, const String& title, ScriptState*);
78
79     void didCommitLoad(LocalFrame*, DocumentLoader*);
80
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;
87
88     virtual bool isWorkerAgent() = 0;
89
90     virtual void setLastEvaluationResult(ErrorString*, const String& objectId) override;
91
92 protected:
93     void sendConsoleMessageToFrontend(ConsoleMessage*, bool generatePreview);
94     virtual ConsoleMessageStorage* messageStorage() = 0;
95
96     RawPtrWillBeMember<InspectorTimelineAgent> m_timelineAgent;
97     RawPtrWillBeMember<InjectedScriptManager> m_injectedScriptManager;
98     InspectorFrontend::Console* m_frontend;
99     bool m_enabled;
100 private:
101     static int s_enabledAgentCount;
102 };
103
104 } // namespace blink
105
106
107 #endif // !defined(InspectorConsoleAgent_h)