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

Unified Diff: test/inspector/inspector-test.cc

Issue 2574803002: [inspector] add async instrumentation for setTimeout in tests (Closed)
Patch Set: addressed comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/inspector/debugger/async-set-timeout-expected.txt ('k') | test/inspector/protocol-test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/inspector-test.cc
diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc
index 401aca077650afa8413274ba82d6920addc57d29..3895fac8a0d7138efde120e78b10d09cf75b4c78 100644
--- a/test/inspector/inspector-test.cc
+++ b/test/inspector/inspector-test.cc
@@ -177,22 +177,23 @@ class UtilsExtension : public v8::Extension {
backend_runner_->Append(new ExecuteStringTask(
ToVector(args[0].As<v8::String>()), args[1].As<v8::String>(),
- args[2].As<v8::Int32>(), args[3].As<v8::Int32>()));
+ args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), nullptr, nullptr));
}
};
TaskRunner* UtilsExtension::backend_runner_ = nullptr;
-class SetTimeoutTask : public TaskRunner::Task {
+class SetTimeoutTask : public AsyncTask {
public:
- SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function)
- : function_(isolate, function) {}
+ SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function,
+ const char* task_name, v8_inspector::V8Inspector* inspector)
+ : AsyncTask(task_name, inspector), function_(isolate, function) {}
virtual ~SetTimeoutTask() {}
bool is_inspector_task() final { return false; }
- void Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& global_context) override {
+ void AsyncRun(v8::Isolate* isolate,
+ const v8::Global<v8::Context>& global_context) override {
v8::MicrotasksScope microtasks_scope(isolate,
v8::MicrotasksScope::kRunMicrotasks);
v8::HandleScope handle_scope(isolate);
@@ -234,14 +235,20 @@ class SetTimeoutExtension : public v8::Extension {
}
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ std::unique_ptr<TaskRunner::Task> task;
+ v8_inspector::V8Inspector* inspector =
+ InspectorClientImpl::InspectorFromContext(context);
if (args[0]->IsFunction()) {
- TaskRunner::FromContext(context)->Append(
- new SetTimeoutTask(isolate, v8::Local<v8::Function>::Cast(args[0])));
+ task.reset(new SetTimeoutTask(isolate,
+ v8::Local<v8::Function>::Cast(args[0]),
+ "setTimeout", inspector));
} else {
- TaskRunner::FromContext(context)->Append(new ExecuteStringTask(
+ task.reset(new ExecuteStringTask(
ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate),
- v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0)));
+ v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0),
+ "setTimeout", inspector));
}
+ TaskRunner::FromContext(context)->Append(task.release());
}
};
@@ -334,9 +341,10 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel {
v8::Local<v8::String> result = v8::String::Concat(prefix, message_string);
result = v8::String::Concat(result, suffix);
- frontend_task_runner_->Append(new ExecuteStringTask(
- ToVector(result), v8::String::Empty(isolate),
- v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0)));
+ frontend_task_runner_->Append(
+ new ExecuteStringTask(ToVector(result), v8::String::Empty(isolate),
+ v8::Integer::New(isolate, 0),
+ v8::Integer::New(isolate, 0), nullptr, nullptr));
}
private:
« no previous file with comments | « test/inspector/debugger/async-set-timeout-expected.txt ('k') | test/inspector/protocol-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698