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 #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | 5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |
6 #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | 6 #define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |
7 | 7 |
8 #include "include/v8-inspector.h" | 8 #include "include/v8-inspector.h" |
9 #include "include/v8-platform.h" | 9 #include "include/v8-platform.h" |
10 #include "include/v8.h" | 10 #include "include/v8.h" |
11 #include "src/base/macros.h" | 11 #include "src/base/macros.h" |
12 #include "src/base/platform/platform.h" | 12 #include "src/base/platform/platform.h" |
13 #include "src/inspector/string-16.h" | 13 #include "src/inspector/string-16.h" |
14 #include "src/locked-queue-inl.h" | 14 #include "src/locked-queue-inl.h" |
15 | 15 |
16 class TaskRunner : public v8::base::Thread { | 16 class TaskRunner : public v8::base::Thread { |
17 public: | 17 public: |
18 class Task { | 18 class Task { |
19 public: | 19 public: |
20 virtual ~Task() {} | 20 virtual ~Task() {} |
21 virtual bool is_inspector_task() = 0; | 21 virtual bool is_inspector_task() = 0; |
22 virtual void Run(v8::Isolate* isolate, | 22 virtual void Run(v8::Isolate* isolate, |
23 const v8::Global<v8::Context>& context) = 0; | 23 const v8::Global<v8::Context>& context) = 0; |
24 }; | 24 }; |
25 | 25 |
26 explicit TaskRunner(v8::ExtensionConfiguration* extensions, | 26 TaskRunner(v8::ExtensionConfiguration* extensions, bool catch_exceptions, |
27 v8::base::Semaphore* ready_semaphore); | 27 v8::base::Semaphore* ready_semaphore); |
28 virtual ~TaskRunner(); | 28 virtual ~TaskRunner(); |
29 | 29 |
30 // Thread implementation. | 30 // Thread implementation. |
31 void Run() override; | 31 void Run() override; |
32 | 32 |
33 // Should be called from the same thread and only from task. | 33 // Should be called from the same thread and only from task. |
34 void RunMessageLoop(bool only_protocol); | 34 void RunMessageLoop(bool only_protocol); |
35 void QuitMessageLoop(); | 35 void QuitMessageLoop(); |
36 | 36 |
37 // TaskRunner takes ownership. | 37 // TaskRunner takes ownership. |
38 void Append(Task* task); | 38 void Append(Task* task); |
39 | 39 |
40 static TaskRunner* FromContext(v8::Local<v8::Context>); | 40 static TaskRunner* FromContext(v8::Local<v8::Context>); |
41 | 41 |
42 private: | 42 private: |
43 void InitializeContext(); | 43 void InitializeContext(); |
44 Task* GetNext(bool only_protocol); | 44 Task* GetNext(bool only_protocol); |
45 | 45 |
46 v8::ExtensionConfiguration* extensions_; | 46 v8::ExtensionConfiguration* extensions_; |
| 47 bool catch_exceptions_; |
47 v8::base::Semaphore* ready_semaphore_; | 48 v8::base::Semaphore* ready_semaphore_; |
48 | 49 |
49 v8::Isolate* isolate_; | 50 v8::Isolate* isolate_; |
50 v8::Global<v8::Context> context_; | 51 v8::Global<v8::Context> context_; |
51 | 52 |
52 // deferred_queue_ combined with queue_ (in this order) have all tasks in the | 53 // deferred_queue_ combined with queue_ (in this order) have all tasks in the |
53 // correct order. | 54 // correct order. |
54 // Sometimes we skip non-protocol tasks by moving them from queue_ to | 55 // Sometimes we skip non-protocol tasks by moving them from queue_ to |
55 // deferred_queue_. | 56 // deferred_queue_. |
56 v8::internal::LockedQueue<Task*> queue_; | 57 v8::internal::LockedQueue<Task*> queue_; |
(...skipping 13 matching lines...) Expand all Loading... |
70 void Run(v8::Isolate* isolate, | 71 void Run(v8::Isolate* isolate, |
71 const v8::Global<v8::Context>& context) override; | 72 const v8::Global<v8::Context>& context) override; |
72 | 73 |
73 private: | 74 private: |
74 v8_inspector::String16 expression_; | 75 v8_inspector::String16 expression_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); | 77 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); |
77 }; | 78 }; |
78 | 79 |
79 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ | 80 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ |
OLD | NEW |