]> git.saurik.com Git - apple/javascriptcore.git/blob - inspector/agents/InspectorRuntimeAgent.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / inspector / agents / InspectorRuntimeAgent.h
1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef InspectorRuntimeAgent_h
33 #define InspectorRuntimeAgent_h
34
35 #include "InspectorBackendDispatchers.h"
36 #include "InspectorFrontendDispatchers.h"
37 #include "inspector/InspectorAgentBase.h"
38 #include <wtf/Forward.h>
39 #include <wtf/Noncopyable.h>
40
41 namespace JSC {
42 class VM;
43 }
44
45 namespace Inspector {
46
47 class InjectedScript;
48 class InjectedScriptManager;
49 class InspectorArray;
50 class ScriptDebugServer;
51 typedef String ErrorString;
52
53 class JS_EXPORT_PRIVATE InspectorRuntimeAgent : public InspectorAgentBase, public RuntimeBackendDispatcherHandler {
54 WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
55 public:
56 virtual ~InspectorRuntimeAgent();
57
58 virtual void willDestroyFrontendAndBackend(DisconnectReason) override;
59
60 virtual void enable(ErrorString&) override { m_enabled = true; }
61 virtual void disable(ErrorString&) override { m_enabled = false; }
62 virtual void parse(ErrorString&, const String& expression, Inspector::Protocol::Runtime::SyntaxErrorType* result, Inspector::Protocol::OptOutput<String>* message, RefPtr<Inspector::Protocol::Runtime::ErrorRange>&) override final;
63 virtual void evaluate(ErrorString&, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex) override final;
64 virtual void callFunctionOn(ErrorString&, const String& objectId, const String& expression, const Inspector::InspectorArray* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override final;
65 virtual void releaseObject(ErrorString&, const ErrorString& objectId) override final;
66 virtual void getProperties(ErrorString&, const String& objectId, const bool* ownProperties, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
67 virtual void getDisplayableProperties(ErrorString&, const String& objectId, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
68 virtual void getCollectionEntries(ErrorString&, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::CollectionEntry>>& entries) override final;
69 virtual void saveResult(ErrorString&, const Inspector::InspectorObject& callArgument, const int* executionContextId, Inspector::Protocol::OptOutput<int>* savedResultIndex) override final;
70 virtual void releaseObjectGroup(ErrorString&, const String& objectGroup) override final;
71 virtual void run(ErrorString&) override;
72 virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const Inspector::InspectorArray& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>&) override;
73 virtual void enableTypeProfiler(ErrorString&) override;
74 virtual void disableTypeProfiler(ErrorString&) override;
75 virtual void getBasicBlocks(ErrorString&, const String& in_sourceID, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::BasicBlock>>& out_basicBlocks) override;
76
77 void setScriptDebugServer(ScriptDebugServer* scriptDebugServer) { m_scriptDebugServer = scriptDebugServer; }
78
79 bool enabled() const { return m_enabled; }
80
81 protected:
82 InspectorRuntimeAgent(InjectedScriptManager*);
83
84 InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
85
86 virtual JSC::VM& globalVM() = 0;
87 virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0;
88
89 virtual void muteConsole() = 0;
90 virtual void unmuteConsole() = 0;
91
92 private:
93 void setTypeProfilerEnabledState(bool);
94
95 InjectedScriptManager* m_injectedScriptManager;
96 ScriptDebugServer* m_scriptDebugServer;
97 bool m_enabled;
98 bool m_isTypeProfilingEnabled;
99 };
100
101 } // namespace Inspector
102
103 #endif // InspectorRuntimeAgent_h