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

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

Issue 2832723004: [test/inspector] remove any usage of v8::Extension (Closed)
Patch Set: ac Created 3 years, 8 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
OLDNEW
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 <map> 8 #include <map>
9 9
10 #include "include/v8-inspector.h" 10 #include "include/v8-inspector.h"
(...skipping 18 matching lines...) Expand all
29 class TaskRunner : public v8::base::Thread { 29 class TaskRunner : public v8::base::Thread {
30 public: 30 public:
31 class Task { 31 class Task {
32 public: 32 public:
33 virtual ~Task() {} 33 virtual ~Task() {}
34 virtual bool is_inspector_task() = 0; 34 virtual bool is_inspector_task() = 0;
35 virtual void Run(v8::Isolate* isolate, 35 virtual void Run(v8::Isolate* isolate,
36 const v8::Global<v8::Context>& context) = 0; 36 const v8::Global<v8::Context>& context) = 0;
37 }; 37 };
38 38
39 TaskRunner(v8::ExtensionConfiguration* extensions, bool catch_exceptions, 39 class SetupGlobalTask {
40 public:
41 virtual ~SetupGlobalTask() = default;
42 virtual void Run(v8::Isolate* isolate,
43 v8::Local<v8::ObjectTemplate> global) = 0;
44 };
45 using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>;
46
47 TaskRunner(SetupGlobalTasks setup_global_tasks, bool catch_exceptions,
40 v8::base::Semaphore* ready_semaphore); 48 v8::base::Semaphore* ready_semaphore);
41 virtual ~TaskRunner(); 49 virtual ~TaskRunner();
42 50
43 // Thread implementation. 51 // Thread implementation.
44 void Run() override; 52 void Run() override;
45 53
46 // Should be called from the same thread and only from task. 54 // Should be called from the same thread and only from task.
47 void RunMessageLoop(bool only_protocol); 55 void RunMessageLoop(bool only_protocol);
48 void QuitMessageLoop(); 56 void QuitMessageLoop();
49 57
50 // TaskRunner takes ownership. 58 // TaskRunner takes ownership.
51 void Append(Task* task); 59 void Append(Task* task);
52 60
53 static TaskRunner* FromContext(v8::Local<v8::Context>); 61 static TaskRunner* FromContext(v8::Local<v8::Context>);
54 62
55 v8::Local<v8::Context> NewContextGroup(); 63 v8::Local<v8::Context> NewContextGroup(
64 const SetupGlobalTasks& setup_global_tasks);
56 v8::Local<v8::Context> GetContext(int context_group_id); 65 v8::Local<v8::Context> GetContext(int context_group_id);
57 static int GetContextGroupId(v8::Local<v8::Context> context); 66 static int GetContextGroupId(v8::Local<v8::Context> context);
58 67
59 void Terminate(); 68 void Terminate();
60 69
61 void RegisterModule(v8::internal::Vector<uint16_t> name, 70 void RegisterModule(v8::internal::Vector<uint16_t> name,
62 v8::Local<v8::Module> module); 71 v8::Local<v8::Module> module);
63 static v8::MaybeLocal<v8::Module> ModuleResolveCallback( 72 static v8::MaybeLocal<v8::Module> ModuleResolveCallback(
64 v8::Local<v8::Context> context, v8::Local<v8::String> specifier, 73 v8::Local<v8::Context> context, v8::Local<v8::String> specifier,
65 v8::Local<v8::Module> referrer); 74 v8::Local<v8::Module> referrer);
66 75
67 private: 76 private:
68 void InitializeIsolate(); 77 void InitializeIsolate();
69 Task* GetNext(bool only_protocol); 78 Task* GetNext(bool only_protocol);
70 79
71 v8::ExtensionConfiguration* extensions_; 80 SetupGlobalTasks setup_global_tasks_;
72 bool catch_exceptions_; 81 bool catch_exceptions_;
73 v8::base::Semaphore* ready_semaphore_; 82 v8::base::Semaphore* ready_semaphore_;
74 83
75 v8::Isolate* isolate_; 84 v8::Isolate* isolate_;
76 intptr_t last_context_group_id_ = 0; 85 intptr_t last_context_group_id_ = 0;
77 std::map<intptr_t, v8::Global<v8::Context>> contexts_; 86 std::map<intptr_t, v8::Global<v8::Context>> contexts_;
78 87
79 // deferred_queue_ combined with queue_ (in this order) have all tasks in the 88 // deferred_queue_ combined with queue_ (in this order) have all tasks in the
80 // correct order. Sometimes we skip non-protocol tasks by moving them from 89 // correct order. Sometimes we skip non-protocol tasks by moving them from
81 // queue_ to deferred_queue_. 90 // queue_ to deferred_queue_.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 v8::internal::Vector<const char> expression_utf8_; 137 v8::internal::Vector<const char> expression_utf8_;
129 v8::internal::Vector<uint16_t> name_; 138 v8::internal::Vector<uint16_t> name_;
130 int32_t line_offset_ = 0; 139 int32_t line_offset_ = 0;
131 int32_t column_offset_ = 0; 140 int32_t column_offset_ = 0;
132 bool is_module_ = false; 141 bool is_module_ = false;
133 142
134 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask); 143 DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask);
135 }; 144 };
136 145
137 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_ 146 #endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698