Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/inspector/InjectedScript.h

Issue 2338413003: [inspector] change implementation file extension from cpp to cc (Closed)
Patch Set: string16 -> string-16 Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/DebuggerScript.js ('k') | src/inspector/InjectedScript.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 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_INJECTEDSCRIPT_H_
32 #define V8_INSPECTOR_INJECTEDSCRIPT_H_
33
34 #include "src/base/macros.h"
35 #include "src/inspector/InjectedScriptNative.h"
36 #include "src/inspector/InspectedContext.h"
37 #include "src/inspector/V8Console.h"
38 #include "src/inspector/V8Debugger.h"
39 #include "src/inspector/protocol/Forward.h"
40 #include "src/inspector/protocol/Runtime.h"
41
42 #include "include/v8.h"
43
44 namespace v8_inspector {
45
46 class RemoteObjectId;
47 class V8FunctionCall;
48 class V8InspectorImpl;
49 class V8InspectorSessionImpl;
50
51 using protocol::ErrorString;
52 using protocol::Maybe;
53
54 class InjectedScript final {
55 DISALLOW_COPY_AND_ASSIGN(InjectedScript);
56
57 public:
58 static std::unique_ptr<InjectedScript> create(InspectedContext*);
59 ~InjectedScript();
60
61 InspectedContext* context() const { return m_context; }
62
63 void getProperties(
64 ErrorString*, v8::Local<v8::Object>, const String16& groupName,
65 bool ownProperties, bool accessorPropertiesOnly, bool generatePreview,
66 std::unique_ptr<protocol::Array<protocol::Runtime::PropertyDescriptor>>*
67 result,
68 Maybe<protocol::Runtime::ExceptionDetails>*);
69 void releaseObject(const String16& objectId);
70
71 std::unique_ptr<protocol::Runtime::RemoteObject> wrapObject(
72 ErrorString*, v8::Local<v8::Value>, const String16& groupName,
73 bool forceValueType = false, bool generatePreview = false) const;
74 bool wrapObjectProperty(ErrorString*, v8::Local<v8::Object>,
75 v8::Local<v8::Name> key, const String16& groupName,
76 bool forceValueType = false,
77 bool generatePreview = false) const;
78 bool wrapPropertyInArray(ErrorString*, v8::Local<v8::Array>,
79 v8::Local<v8::String> property,
80 const String16& groupName,
81 bool forceValueType = false,
82 bool generatePreview = false) const;
83 bool wrapObjectsInArray(ErrorString*, v8::Local<v8::Array>,
84 const String16& groupName,
85 bool forceValueType = false,
86 bool generatePreview = false) const;
87 std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable(
88 v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const;
89
90 bool findObject(ErrorString*, const RemoteObjectId&,
91 v8::Local<v8::Value>*) const;
92 String16 objectGroupName(const RemoteObjectId&) const;
93 void releaseObjectGroup(const String16&);
94 void setCustomObjectFormatterEnabled(bool);
95 v8::MaybeLocal<v8::Value> resolveCallArgument(
96 ErrorString*, protocol::Runtime::CallArgument*);
97
98 std::unique_ptr<protocol::Runtime::ExceptionDetails> createExceptionDetails(
99 ErrorString*, const v8::TryCatch&, const String16& groupName,
100 bool generatePreview);
101 void wrapEvaluateResult(
102 ErrorString*, v8::MaybeLocal<v8::Value> maybeResultValue,
103 const v8::TryCatch&, const String16& objectGroup, bool returnByValue,
104 bool generatePreview,
105 std::unique_ptr<protocol::Runtime::RemoteObject>* result,
106 Maybe<protocol::Runtime::ExceptionDetails>*);
107 v8::Local<v8::Value> lastEvaluationResult() const;
108
109 class Scope {
110 public:
111 bool initialize();
112 bool installCommandLineAPI();
113 void ignoreExceptionsAndMuteConsole();
114 void pretendUserGesture();
115 v8::Local<v8::Context> context() const { return m_context; }
116 InjectedScript* injectedScript() const { return m_injectedScript; }
117 const v8::TryCatch& tryCatch() const { return m_tryCatch; }
118
119 protected:
120 Scope(ErrorString*, V8InspectorImpl*, int contextGroupId);
121 virtual ~Scope();
122 virtual void findInjectedScript(V8InspectorSessionImpl*) = 0;
123
124 ErrorString* m_errorString;
125 V8InspectorImpl* m_inspector;
126 int m_contextGroupId;
127 InjectedScript* m_injectedScript;
128
129 private:
130 void cleanup();
131 V8Debugger::PauseOnExceptionsState setPauseOnExceptionsState(
132 V8Debugger::PauseOnExceptionsState);
133
134 v8::HandleScope m_handleScope;
135 v8::TryCatch m_tryCatch;
136 v8::Local<v8::Context> m_context;
137 std::unique_ptr<V8Console::CommandLineAPIScope> m_commandLineAPIScope;
138 bool m_ignoreExceptionsAndMuteConsole;
139 V8Debugger::PauseOnExceptionsState m_previousPauseOnExceptionsState;
140 bool m_userGesture;
141 };
142
143 class ContextScope : public Scope {
144 DISALLOW_COPY_AND_ASSIGN(ContextScope);
145
146 public:
147 ContextScope(ErrorString*, V8InspectorImpl*, int contextGroupId,
148 int executionContextId);
149 ~ContextScope();
150
151 private:
152 void findInjectedScript(V8InspectorSessionImpl*) override;
153 int m_executionContextId;
154 };
155
156 class ObjectScope : public Scope {
157 DISALLOW_COPY_AND_ASSIGN(ObjectScope);
158
159 public:
160 ObjectScope(ErrorString*, V8InspectorImpl*, int contextGroupId,
161 const String16& remoteObjectId);
162 ~ObjectScope();
163 const String16& objectGroupName() const { return m_objectGroupName; }
164 v8::Local<v8::Value> object() const { return m_object; }
165
166 private:
167 void findInjectedScript(V8InspectorSessionImpl*) override;
168 String16 m_remoteObjectId;
169 String16 m_objectGroupName;
170 v8::Local<v8::Value> m_object;
171 };
172
173 class CallFrameScope : public Scope {
174 DISALLOW_COPY_AND_ASSIGN(CallFrameScope);
175
176 public:
177 CallFrameScope(ErrorString*, V8InspectorImpl*, int contextGroupId,
178 const String16& remoteCallFrameId);
179 ~CallFrameScope();
180 size_t frameOrdinal() const { return m_frameOrdinal; }
181
182 private:
183 void findInjectedScript(V8InspectorSessionImpl*) override;
184 String16 m_remoteCallFrameId;
185 size_t m_frameOrdinal;
186 };
187
188 private:
189 InjectedScript(InspectedContext*, v8::Local<v8::Object>,
190 std::unique_ptr<InjectedScriptNative>);
191 v8::Local<v8::Value> v8Value() const;
192 v8::MaybeLocal<v8::Value> wrapValue(ErrorString*, v8::Local<v8::Value>,
193 const String16& groupName,
194 bool forceValueType,
195 bool generatePreview) const;
196 v8::Local<v8::Object> commandLineAPI();
197
198 InspectedContext* m_context;
199 v8::Global<v8::Value> m_value;
200 v8::Global<v8::Value> m_lastEvaluationResult;
201 std::unique_ptr<InjectedScriptNative> m_native;
202 v8::Global<v8::Object> m_commandLineAPI;
203 };
204
205 } // namespace v8_inspector
206
207 #endif // V8_INSPECTOR_INJECTEDSCRIPT_H_
OLDNEW
« no previous file with comments | « src/inspector/DebuggerScript.js ('k') | src/inspector/InjectedScript.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698