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

Side by Side Diff: test/inspector/task-runner.h

Issue 2385663002: Version 5.5.335.1 (cherry-pick) (Closed)
Patch Set: Created 4 years, 2 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 | « test/inspector/inspector-impl.cc ('k') | test/inspector/task-runner.cc » ('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 // 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
3 // found in the LICENSE file.
4
5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
6 #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
7
8 #include "include/v8-inspector.h"
9 #include "include/v8-platform.h"
10 #include "include/v8.h"
11 #include "src/base/macros.h"
12 #include "src/base/platform/platform.h"
13 #include "src/inspector/string-16.h"
14 #include "src/locked-queue-inl.h"
15
16 class TaskRunner : public v8::base::Thread {
17 public:
18 class Task {
19 public:
20 virtual ~Task() {}
21 virtual bool is_inspector_task() = 0;
22 virtual void Run(v8::Isolate* isolate,
23 const v8::Global<v8::Context>& context) = 0;
24 };
25
26 explicit TaskRunner(v8::ExtensionConfiguration* extensions,
27 v8::base::Semaphore* ready_semaphore);
28 virtual ~TaskRunner();
29
30 // Thread implementation.
31 void Run() override;
32
33 // Should be called from the same thread and only from task.
34 void RunMessageLoop(bool only_protocol);
35 void QuitMessageLoop();
36
37 // TaskRunner takes ownership.
38 void Append(Task* task);
39
40 static TaskRunner* FromContext(v8::Local<v8::Context>);
41
42 private:
43 void InitializeContext();
44 Task* GetNext(bool only_protocol);
45
46 v8::ExtensionConfiguration* extensions_;
47 v8::base::Semaphore* ready_semaphore_;
48
49 v8::Isolate* isolate_;
50 v8::Global<v8::Context> context_;
51
52 // deferred_queue_ combined with queue_ (in this order) have all tasks in the
53 // correct order.
54 // Sometimes we skip non-protocol tasks by moving them from queue_ to
55 // deferred_queue_.
56 v8::internal::LockedQueue<Task*> queue_;
57 v8::internal::LockedQueue<Task*> deffered_queue_;
58 v8::base::Semaphore process_queue_semaphore_;
59
60 int nested_loop_count_;
61
62 DISALLOW_COPY_AND_ASSIGN(TaskRunner);
63 };
64
65 class ExecuteStringTask : public TaskRunner::Task {
66 public:
67 explicit ExecuteStringTask(const v8_inspector::String16& expression);
68 bool is_inspector_task() override { return false; }
69
70 void Run(v8::Isolate* isolate,
71 const v8::Global<v8::Context>& context) override;
72
73 private:
74 v8_inspector::String16 expression_;
75
76 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask);
77 };
78
79 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « test/inspector/inspector-impl.cc ('k') | test/inspector/task-runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698