Chromium Code Reviews| Index: test/inspector-protocol/task-runner.h |
| diff --git a/test/inspector-protocol/task-runner.h b/test/inspector-protocol/task-runner.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0fcdadf15d277e7afdaf2f306f7a4b3d5ba449b4 |
| --- /dev/null |
| +++ b/test/inspector-protocol/task-runner.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |
| +#define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |
| + |
| +#include <string> |
| + |
| +#include "include/v8-inspector.h" |
| +#include "include/v8-platform.h" |
| +#include "include/v8.h" |
| +#include "src/base/macros.h" |
| +#include "src/base/platform/platform.h" |
| +#include "src/locked-queue-inl.h" |
| + |
| +class TaskRunner : public v8::base::Thread { |
| + public: |
| + class Task { |
| + public: |
| + virtual ~Task() {} |
| + virtual bool is_protocol_task() = 0; |
| + virtual void Run(v8::Local<v8::Context>) = 0; |
| + }; |
| + |
| + explicit TaskRunner(v8::ExtensionConfiguration* extensions, |
| + v8::base::Semaphore* ready); |
| + virtual ~TaskRunner(); |
| + |
| + // Thread implementation. |
| + void Run() override; |
| + |
| + // Should be called from the same thread and only from task. |
| + void RunMessageLoop(bool only_protocol); |
| + void QuitMessageLoop(); |
| + |
| + // TaskRunner takes ownership. |
| + void Append(Task* task); |
| + |
| + static TaskRunner* FromContext(v8::Local<v8::Context>); |
| + |
| + private: |
| + void InitializeContext(); |
| + Task* GetNext(bool only_protocol); |
| + |
| + v8::ExtensionConfiguration* extensions_; |
| + v8::base::Semaphore* ready_; |
|
dgozman
2016/09/24 00:56:10
ready_semaphore_
kozy
2016/09/26 01:44:08
Done.
|
| + |
| + v8::Isolate* isolate_; |
| + v8::Global<v8::Context> context_; |
| + |
| + v8::internal::LockedQueue<Task*> queue_; |
|
dgozman
2016/09/24 00:56:10
// deferred_queue_ combined with queue_ (in this o
kozy
2016/09/26 01:44:08
Done.
|
| + v8::internal::LockedQueue<Task*> deffered_queue_; |
| + v8::base::Semaphore process_queue_semaphore_; |
| + |
| + int nested_loops_; |
|
dgozman
2016/09/24 00:56:10
nested_loop_count_;
kozy
2016/09/26 01:44:08
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(TaskRunner); |
| +}; |
| + |
| +class ExecuteStringTask : public TaskRunner::Task { |
| + public: |
| + explicit ExecuteStringTask(const std::string& expression); |
| + bool is_protocol_task() override { return false; } |
| + |
| + void Run(v8::Local<v8::Context>) override; |
| + |
| + private: |
| + std::string expression_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); |
| +}; |
| + |
| +#endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |