OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/inspector/task-runner.h" | 5 #include "test/inspector/task-runner.h" |
6 | 6 |
| 7 #include "test/inspector/inspector-impl.h" |
| 8 |
7 #if !defined(_WIN32) && !defined(_WIN64) | 9 #if !defined(_WIN32) && !defined(_WIN64) |
8 #include <unistd.h> // NOLINT | 10 #include <unistd.h> // NOLINT |
9 #endif // !defined(_WIN32) && !defined(_WIN64) | 11 #endif // !defined(_WIN32) && !defined(_WIN64) |
10 | 12 |
11 namespace { | 13 namespace { |
12 | 14 |
13 const int kTaskRunnerIndex = 2; | 15 const int kTaskRunnerIndex = 2; |
14 | 16 |
15 void ReportUncaughtException(v8::Isolate* isolate, | 17 void ReportUncaughtException(v8::Isolate* isolate, |
16 const v8::TryCatch& try_catch) { | 18 const v8::TryCatch& try_catch) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 v8::internal::Vector<uint16_t>::New(str->Length()); | 132 v8::internal::Vector<uint16_t>::New(str->Length()); |
131 str->Write(buffer.start(), 0, str->Length()); | 133 str->Write(buffer.start(), 0, str->Length()); |
132 return buffer; | 134 return buffer; |
133 } | 135 } |
134 | 136 |
135 } // namespace | 137 } // namespace |
136 | 138 |
137 ExecuteStringTask::ExecuteStringTask( | 139 ExecuteStringTask::ExecuteStringTask( |
138 const v8::internal::Vector<uint16_t>& expression, | 140 const v8::internal::Vector<uint16_t>& expression, |
139 v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, | 141 v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, |
140 v8::Local<v8::Integer> column_offset) | 142 v8::Local<v8::Integer> column_offset, bool report_async) |
141 : expression_(expression), | 143 : expression_(expression), |
142 name_(ToVector(name)), | 144 name_(ToVector(name)), |
143 line_offset_(line_offset.As<v8::Int32>()->Value()), | 145 line_offset_(line_offset.As<v8::Int32>()->Value()), |
144 column_offset_(column_offset.As<v8::Int32>()->Value()) {} | 146 column_offset_(column_offset.As<v8::Int32>()->Value()), |
| 147 report_async_(report_async) {} |
145 | 148 |
146 ExecuteStringTask::ExecuteStringTask( | 149 ExecuteStringTask::ExecuteStringTask( |
147 const v8::internal::Vector<const char>& expression) | 150 const v8::internal::Vector<const char>& expression) |
148 : expression_utf8_(expression), line_offset_(0), column_offset_(0) {} | 151 : expression_utf8_(expression), |
| 152 line_offset_(0), |
| 153 column_offset_(0), |
| 154 report_async_(false) {} |
149 | 155 |
150 void ExecuteStringTask::Run(v8::Isolate* isolate, | 156 void ExecuteStringTask::Run(v8::Isolate* isolate, |
151 const v8::Global<v8::Context>& context) { | 157 const v8::Global<v8::Context>& context) { |
152 v8::MicrotasksScope microtasks_scope(isolate, | 158 v8::MicrotasksScope microtasks_scope(isolate, |
153 v8::MicrotasksScope::kRunMicrotasks); | 159 v8::MicrotasksScope::kRunMicrotasks); |
154 v8::HandleScope handle_scope(isolate); | 160 v8::HandleScope handle_scope(isolate); |
155 v8::Local<v8::Context> local_context = context.Get(isolate); | 161 v8::Local<v8::Context> local_context = context.Get(isolate); |
156 v8::Context::Scope context_scope(local_context); | 162 v8::Context::Scope context_scope(local_context); |
157 | 163 |
158 v8::Local<v8::String> name = | 164 v8::Local<v8::String> name = |
(...skipping 17 matching lines...) Expand all Loading... |
176 expression_utf8_.length()) | 182 expression_utf8_.length()) |
177 .ToLocalChecked(); | 183 .ToLocalChecked(); |
178 } | 184 } |
179 | 185 |
180 v8::ScriptCompiler::Source scriptSource(source, origin); | 186 v8::ScriptCompiler::Source scriptSource(source, origin); |
181 v8::Local<v8::Script> script; | 187 v8::Local<v8::Script> script; |
182 if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) | 188 if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) |
183 .ToLocal(&script)) | 189 .ToLocal(&script)) |
184 return; | 190 return; |
185 v8::MaybeLocal<v8::Value> result; | 191 v8::MaybeLocal<v8::Value> result; |
| 192 v8_inspector::V8Inspector* inspector = |
| 193 report_async_ ? InspectorClientImpl::InspectorFromContext(local_context) |
| 194 : nullptr; |
| 195 if (inspector) inspector->asyncTaskStarted(this); |
186 result = script->Run(local_context); | 196 result = script->Run(local_context); |
| 197 if (inspector) inspector->asyncTaskFinished(this); |
187 } | 198 } |
OLD | NEW |