]> git.saurik.com Git - apple/javascriptcore.git/blob - inspector/JSGlobalObjectInspectorController.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / inspector / JSGlobalObjectInspectorController.h
1 /*
2 * Copyright (C) 2014 Apple 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. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef JSGlobalObjectInspectorController_h
27 #define JSGlobalObjectInspectorController_h
28
29 #include "InspectorAgentRegistry.h"
30 #include "InspectorEnvironment.h"
31 #include <wtf/Forward.h>
32 #include <wtf/Noncopyable.h>
33 #include <wtf/text/WTFString.h>
34
35 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
36 #include "AugmentableInspectorController.h"
37 #endif
38
39 namespace WTF {
40 class Stopwatch;
41 }
42
43
44 namespace JSC {
45 class ConsoleClient;
46 class Exception;
47 class ExecState;
48 class JSGlobalObject;
49 class JSValue;
50 }
51
52 namespace Inspector {
53
54 class BackendDispatcher;
55 class FrontendChannel;
56 class InjectedScriptManager;
57 class InspectorAgent;
58 class InspectorConsoleAgent;
59 class InspectorDebuggerAgent;
60 class JSGlobalObjectConsoleClient;
61 class ScriptCallStack;
62
63 class JSGlobalObjectInspectorController final
64 : public InspectorEnvironment
65 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
66 , public AugmentableInspectorController
67 #endif
68 {
69 WTF_MAKE_NONCOPYABLE(JSGlobalObjectInspectorController);
70 WTF_MAKE_FAST_ALLOCATED;
71 public:
72 JSGlobalObjectInspectorController(JSC::JSGlobalObject&);
73 ~JSGlobalObjectInspectorController();
74
75 void connectFrontend(FrontendChannel*, bool isAutomaticInspection);
76 void disconnectFrontend(DisconnectReason);
77 void dispatchMessageFromFrontend(const String&);
78
79 void globalObjectDestroyed();
80
81 bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions; }
82 void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack) { m_includeNativeCallStackWithExceptions = includesNativeCallStack; }
83
84 void pause();
85 void reportAPIException(JSC::ExecState*, JSC::Exception*);
86
87 JSC::ConsoleClient* consoleClient() const;
88
89 virtual bool developerExtrasEnabled() const override;
90 virtual bool canAccessInspectedScriptState(JSC::ExecState*) const override { return true; }
91 virtual InspectorFunctionCallHandler functionCallHandler() const override;
92 virtual InspectorEvaluateHandler evaluateHandler() const override;
93 virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String&, int) override { }
94 virtual void didCallInjectedScriptFunction(JSC::ExecState*) override { }
95 virtual void frontendInitialized() override;
96 virtual Ref<WTF::Stopwatch> executionStopwatch() override;
97
98 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
99 virtual AugmentableInspectorControllerClient* augmentableInspectorControllerClient() const override { return m_augmentingClient; }
100 virtual void setAugmentableInspectorControllerClient(AugmentableInspectorControllerClient* client) override { m_augmentingClient = client; }
101
102 virtual FrontendChannel* frontendChannel() const override { return m_frontendChannel; }
103 virtual void appendExtraAgent(std::unique_ptr<InspectorAgentBase>) override;
104 #endif
105
106 private:
107 void appendAPIBacktrace(ScriptCallStack* callStack);
108
109 JSC::JSGlobalObject& m_globalObject;
110 std::unique_ptr<InjectedScriptManager> m_injectedScriptManager;
111 std::unique_ptr<JSGlobalObjectConsoleClient> m_consoleClient;
112 InspectorAgent* m_inspectorAgent;
113 InspectorConsoleAgent* m_consoleAgent;
114 InspectorDebuggerAgent* m_debuggerAgent;
115 AgentRegistry m_agents;
116 FrontendChannel* m_frontendChannel;
117 RefPtr<BackendDispatcher> m_backendDispatcher;
118 Ref<WTF::Stopwatch> m_executionStopwatch;
119 bool m_includeNativeCallStackWithExceptions;
120 bool m_isAutomaticInspection;
121
122 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
123 AugmentableInspectorControllerClient* m_augmentingClient;
124 #endif
125 };
126
127 } // namespace Inspector
128
129 #endif // !defined(JSGlobalObjectInspectorController_h)