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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h

Issue 2295913003: [DevTools] Switch from platform/v8_inspector to v8/v8-inspector.h. (Closed)
Patch Set: rebase 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
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 InjectedScript_h
32 #define InjectedScript_h
33
34 #include "platform/v8_inspector/Allocator.h"
35 #include "platform/v8_inspector/InjectedScriptNative.h"
36 #include "platform/v8_inspector/InspectedContext.h"
37 #include "platform/v8_inspector/V8Console.h"
38 #include "platform/v8_inspector/V8Debugger.h"
39 #include "platform/v8_inspector/protocol/Forward.h"
40 #include "platform/v8_inspector/protocol/Runtime.h"
41
42 #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 V8_INSPECTOR_DISALLOW_COPY(InjectedScript);
56 public:
57 static std::unique_ptr<InjectedScript> create(InspectedContext*);
58 ~InjectedScript();
59
60 InspectedContext* context() const { return m_context; }
61
62 void getProperties(ErrorString*, v8::Local<v8::Object>, const String16& grou pName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, st d::unique_ptr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result, M aybe<protocol::Runtime::ExceptionDetails>*);
63 void releaseObject(const String16& objectId);
64
65 std::unique_ptr<protocol::Runtime::RemoteObject> wrapObject(ErrorString*, v8 ::Local<v8::Value>, const String16& groupName, bool forceValueType = false, bool generatePreview = false) const;
66 bool wrapObjectProperty(ErrorString*, v8::Local<v8::Object>, v8::Local<v8::N ame> key, const String16& groupName, bool forceValueType = false, bool generateP review = false) const;
67 bool wrapPropertyInArray(ErrorString*, v8::Local<v8::Array>, v8::Local<v8::S tring> property, const String16& groupName, bool forceValueType = false, bool ge neratePreview = false) const;
68 bool wrapObjectsInArray(ErrorString*, v8::Local<v8::Array>, const String16& groupName, bool forceValueType = false, bool generatePreview = false) const;
69 std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable(v8::Local<v8::Val ue> table, v8::Local<v8::Value> columns) const;
70
71 bool findObject(ErrorString*, const RemoteObjectId&, v8::Local<v8::Value>*) const;
72 String16 objectGroupName(const RemoteObjectId&) const;
73 void releaseObjectGroup(const String16&);
74 void setCustomObjectFormatterEnabled(bool);
75 v8::MaybeLocal<v8::Value> resolveCallArgument(ErrorString*, protocol::Runtim e::CallArgument*);
76
77 std::unique_ptr<protocol::Runtime::ExceptionDetails> createExceptionDetails( ErrorString*, const v8::TryCatch&, const String16& groupName, bool generatePrevi ew);
78 void wrapEvaluateResult(ErrorString*,
79 v8::MaybeLocal<v8::Value> maybeResultValue,
80 const v8::TryCatch&,
81 const String16& objectGroup,
82 bool returnByValue,
83 bool generatePreview,
84 std::unique_ptr<protocol::Runtime::RemoteObject>* result,
85 Maybe<protocol::Runtime::ExceptionDetails>*);
86 v8::Local<v8::Value> lastEvaluationResult() const;
87
88 class Scope {
89 public:
90 bool initialize();
91 bool installCommandLineAPI();
92 void ignoreExceptionsAndMuteConsole();
93 void pretendUserGesture();
94 v8::Local<v8::Context> context() const { return m_context; }
95 InjectedScript* injectedScript() const { return m_injectedScript; }
96 const v8::TryCatch& tryCatch() const { return m_tryCatch; }
97
98 protected:
99 Scope(ErrorString*, V8InspectorImpl*, int contextGroupId);
100 ~Scope();
101 virtual void findInjectedScript(V8InspectorSessionImpl*) = 0;
102
103 ErrorString* m_errorString;
104 V8InspectorImpl* m_inspector;
105 int m_contextGroupId;
106 InjectedScript* m_injectedScript;
107
108 private:
109 void cleanup();
110 V8Debugger::PauseOnExceptionsState setPauseOnExceptionsState(V8Debugger: :PauseOnExceptionsState);
111
112 v8::HandleScope m_handleScope;
113 v8::TryCatch m_tryCatch;
114 v8::Local<v8::Context> m_context;
115 std::unique_ptr<V8Console::CommandLineAPIScope> m_commandLineAPIScope;
116 bool m_ignoreExceptionsAndMuteConsole;
117 V8Debugger::PauseOnExceptionsState m_previousPauseOnExceptionsState;
118 bool m_userGesture;
119 };
120
121 class ContextScope: public Scope {
122 V8_INSPECTOR_DISALLOW_COPY(ContextScope);
123 public:
124 ContextScope(ErrorString*, V8InspectorImpl*, int contextGroupId, int exe cutionContextId);
125 ~ContextScope();
126 private:
127 void findInjectedScript(V8InspectorSessionImpl*) override;
128 int m_executionContextId;
129 };
130
131 class ObjectScope: public Scope {
132 V8_INSPECTOR_DISALLOW_COPY(ObjectScope);
133 public:
134 ObjectScope(ErrorString*, V8InspectorImpl*, int contextGroupId, const St ring16& remoteObjectId);
135 ~ObjectScope();
136 const String16& objectGroupName() const { return m_objectGroupName; }
137 v8::Local<v8::Value> object() const { return m_object; }
138 private:
139 void findInjectedScript(V8InspectorSessionImpl*) override;
140 String16 m_remoteObjectId;
141 String16 m_objectGroupName;
142 v8::Local<v8::Value> m_object;
143 };
144
145 class CallFrameScope: public Scope {
146 V8_INSPECTOR_DISALLOW_COPY(CallFrameScope);
147 public:
148 CallFrameScope(ErrorString*, V8InspectorImpl*, int contextGroupId, const String16& remoteCallFrameId);
149 ~CallFrameScope();
150 size_t frameOrdinal() const { return m_frameOrdinal; }
151 private:
152 void findInjectedScript(V8InspectorSessionImpl*) override;
153 String16 m_remoteCallFrameId;
154 size_t m_frameOrdinal;
155 };
156
157 private:
158 InjectedScript(InspectedContext*, v8::Local<v8::Object>, std::unique_ptr<Inj ectedScriptNative>);
159 v8::Local<v8::Value> v8Value() const;
160 v8::MaybeLocal<v8::Value> wrapValue(ErrorString*, v8::Local<v8::Value>, cons t String16& groupName, bool forceValueType, bool generatePreview) const;
161 v8::Local<v8::Object> commandLineAPI();
162
163 InspectedContext* m_context;
164 v8::Global<v8::Value> m_value;
165 v8::Global<v8::Value> m_lastEvaluationResult;
166 std::unique_ptr<InjectedScriptNative> m_native;
167 v8::Global<v8::Object> m_commandLineAPI;
168 };
169
170 } // namespace v8_inspector
171
172 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698