OLD | NEW |
| (Empty) |
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 are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #ifndef V8_INSPECTOR_V8RUNTIMEAGENTIMPL_H_ | |
32 #define V8_INSPECTOR_V8RUNTIMEAGENTIMPL_H_ | |
33 | |
34 #include "src/inspector/Allocator.h" | |
35 #include "src/inspector/protocol/Forward.h" | |
36 #include "src/inspector/protocol/Runtime.h" | |
37 | |
38 #include <v8.h> | |
39 | |
40 namespace v8_inspector { | |
41 | |
42 class InjectedScript; | |
43 class InspectedContext; | |
44 class RemoteObjectIdBase; | |
45 class V8ConsoleMessage; | |
46 class V8InspectorImpl; | |
47 class V8InspectorSessionImpl; | |
48 | |
49 using protocol::ErrorString; | |
50 using protocol::Maybe; | |
51 | |
52 class V8RuntimeAgentImpl : public protocol::Runtime::Backend { | |
53 V8_INSPECTOR_DISALLOW_COPY(V8RuntimeAgentImpl); | |
54 public: | |
55 V8RuntimeAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, prot
ocol::DictionaryValue* state); | |
56 ~V8RuntimeAgentImpl() override; | |
57 void restore(); | |
58 | |
59 // Part of the protocol. | |
60 void enable(ErrorString*) override; | |
61 void disable(ErrorString*) override; | |
62 void evaluate( | |
63 const String16& expression, | |
64 const Maybe<String16>& objectGroup, | |
65 const Maybe<bool>& includeCommandLineAPI, | |
66 const Maybe<bool>& silent, | |
67 const Maybe<int>& executionContextId, | |
68 const Maybe<bool>& returnByValue, | |
69 const Maybe<bool>& generatePreview, | |
70 const Maybe<bool>& userGesture, | |
71 const Maybe<bool>& awaitPromise, | |
72 std::unique_ptr<EvaluateCallback>) override; | |
73 void awaitPromise( | |
74 const String16& promiseObjectId, | |
75 const Maybe<bool>& returnByValue, | |
76 const Maybe<bool>& generatePreview, | |
77 std::unique_ptr<AwaitPromiseCallback>) override; | |
78 void callFunctionOn( | |
79 const String16& objectId, | |
80 const String16& expression, | |
81 const Maybe<protocol::Array<protocol::Runtime::CallArgument>>& optionalA
rguments, | |
82 const Maybe<bool>& silent, | |
83 const Maybe<bool>& returnByValue, | |
84 const Maybe<bool>& generatePreview, | |
85 const Maybe<bool>& userGesture, | |
86 const Maybe<bool>& awaitPromise, | |
87 std::unique_ptr<CallFunctionOnCallback>) override; | |
88 void releaseObject(ErrorString*, const String16& objectId) override; | |
89 void getProperties(ErrorString*, | |
90 const String16& objectId, | |
91 const Maybe<bool>& ownProperties, | |
92 const Maybe<bool>& accessorPropertiesOnly, | |
93 const Maybe<bool>& generatePreview, | |
94 std::unique_ptr<protocol::Array<protocol::Runtime::PropertyDescriptor>>*
result, | |
95 Maybe<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>* i
nternalProperties, | |
96 Maybe<protocol::Runtime::ExceptionDetails>*) override; | |
97 void releaseObjectGroup(ErrorString*, const String16& objectGroup) override; | |
98 void runIfWaitingForDebugger(ErrorString*) override; | |
99 void setCustomObjectFormatterEnabled(ErrorString*, bool) override; | |
100 void discardConsoleEntries(ErrorString*) override; | |
101 void compileScript(ErrorString*, | |
102 const String16& expression, | |
103 const String16& sourceURL, | |
104 bool persistScript, | |
105 const Maybe<int>& executionContextId, | |
106 Maybe<String16>*, | |
107 Maybe<protocol::Runtime::ExceptionDetails>*) override; | |
108 void runScript( | |
109 const String16&, | |
110 const Maybe<int>& executionContextId, | |
111 const Maybe<String16>& objectGroup, | |
112 const Maybe<bool>& silent, | |
113 const Maybe<bool>& includeCommandLineAPI, | |
114 const Maybe<bool>& returnByValue, | |
115 const Maybe<bool>& generatePreview, | |
116 const Maybe<bool>& awaitPromise, | |
117 std::unique_ptr<RunScriptCallback>) override; | |
118 | |
119 void reset(); | |
120 void reportExecutionContextCreated(InspectedContext*); | |
121 void reportExecutionContextDestroyed(InspectedContext*); | |
122 void inspect(std::unique_ptr<protocol::Runtime::RemoteObject> objectToInspec
t, std::unique_ptr<protocol::DictionaryValue> hints); | |
123 void messageAdded(V8ConsoleMessage*); | |
124 bool enabled() const { return m_enabled; } | |
125 | |
126 private: | |
127 void reportMessage(V8ConsoleMessage*, bool generatePreview); | |
128 | |
129 V8InspectorSessionImpl* m_session; | |
130 protocol::DictionaryValue* m_state; | |
131 protocol::Runtime::Frontend m_frontend; | |
132 V8InspectorImpl* m_inspector; | |
133 bool m_enabled; | |
134 protocol::HashMap<String16, std::unique_ptr<v8::Global<v8::Script>>> m_compi
ledScripts; | |
135 }; | |
136 | |
137 } // namespace v8_inspector | |
138 | |
139 #endif // V8_INSPECTOR_V8RUNTIMEAGENTIMPL_H_ | |
OLD | NEW |