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 #if !defined(_WIN32) && !defined(_WIN64) | 5 #if !defined(_WIN32) && !defined(_WIN64) |
6 #include <unistd.h> // NOLINT | 6 #include <unistd.h> // NOLINT |
7 #endif // !defined(_WIN32) && !defined(_WIN64) | 7 #endif // !defined(_WIN32) && !defined(_WIN64) |
8 | 8 |
9 #include <locale.h> | 9 #include <locale.h> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 UtilsExtension() | 51 UtilsExtension() |
52 : v8::Extension("v8_inspector/utils", | 52 : v8::Extension("v8_inspector/utils", |
53 "native function print();" | 53 "native function print();" |
54 "native function quit();" | 54 "native function quit();" |
55 "native function setlocale();" | 55 "native function setlocale();" |
56 "native function load();" | 56 "native function load();" |
57 "native function compileAndRunWithOrigin();" | 57 "native function compileAndRunWithOrigin();" |
58 "native function setCurrentTimeMSForTest();" | 58 "native function setCurrentTimeMSForTest();" |
59 "native function schedulePauseOnNextStatement();" | 59 "native function schedulePauseOnNextStatement();" |
60 "native function cancelPauseOnNextStatement();") {} | 60 "native function cancelPauseOnNextStatement();" |
| 61 "native function reconnect();") {} |
61 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 62 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
62 v8::Isolate* isolate, v8::Local<v8::String> name) { | 63 v8::Isolate* isolate, v8::Local<v8::String> name) { |
63 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 64 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
64 if (name->Equals(context, v8::String::NewFromUtf8( | 65 if (name->Equals(context, v8::String::NewFromUtf8( |
65 isolate, "print", v8::NewStringType::kNormal) | 66 isolate, "print", v8::NewStringType::kNormal) |
66 .ToLocalChecked()) | 67 .ToLocalChecked()) |
67 .FromJust()) { | 68 .FromJust()) { |
68 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); | 69 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); |
69 } else if (name->Equals(context, | 70 } else if (name->Equals(context, |
70 v8::String::NewFromUtf8(isolate, "quit", | 71 v8::String::NewFromUtf8(isolate, "quit", |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 .FromJust()) { | 107 .FromJust()) { |
107 return v8::FunctionTemplate::New( | 108 return v8::FunctionTemplate::New( |
108 isolate, UtilsExtension::SchedulePauseOnNextStatement); | 109 isolate, UtilsExtension::SchedulePauseOnNextStatement); |
109 } else if (name->Equals(context, v8::String::NewFromUtf8( | 110 } else if (name->Equals(context, v8::String::NewFromUtf8( |
110 isolate, "cancelPauseOnNextStatement", | 111 isolate, "cancelPauseOnNextStatement", |
111 v8::NewStringType::kNormal) | 112 v8::NewStringType::kNormal) |
112 .ToLocalChecked()) | 113 .ToLocalChecked()) |
113 .FromJust()) { | 114 .FromJust()) { |
114 return v8::FunctionTemplate::New( | 115 return v8::FunctionTemplate::New( |
115 isolate, UtilsExtension::CancelPauseOnNextStatement); | 116 isolate, UtilsExtension::CancelPauseOnNextStatement); |
| 117 } else if (name->Equals(context, |
| 118 v8::String::NewFromUtf8(isolate, "reconnect", |
| 119 v8::NewStringType::kNormal) |
| 120 .ToLocalChecked()) |
| 121 .FromJust()) { |
| 122 return v8::FunctionTemplate::New(isolate, UtilsExtension::Reconnect); |
116 } | 123 } |
117 return v8::Local<v8::FunctionTemplate>(); | 124 return v8::Local<v8::FunctionTemplate>(); |
118 } | 125 } |
119 | 126 |
120 static void set_backend_task_runner(TaskRunner* runner) { | 127 static void set_backend_task_runner(TaskRunner* runner) { |
121 backend_runner_ = runner; | 128 backend_runner_ = runner; |
122 } | 129 } |
123 | 130 |
124 static void set_inspector_client(InspectorClientImpl* client) { | 131 static void set_inspector_client(InspectorClientImpl* client) { |
125 inspector_client_ = client; | 132 inspector_client_ = client; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 246 } |
240 | 247 |
241 static void CancelPauseOnNextStatement( | 248 static void CancelPauseOnNextStatement( |
242 const v8::FunctionCallbackInfo<v8::Value>& args) { | 249 const v8::FunctionCallbackInfo<v8::Value>& args) { |
243 if (args.Length() != 0) { | 250 if (args.Length() != 0) { |
244 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); | 251 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); |
245 Exit(); | 252 Exit(); |
246 } | 253 } |
247 inspector_client_->session()->cancelPauseOnNextStatement(); | 254 inspector_client_->session()->cancelPauseOnNextStatement(); |
248 } | 255 } |
| 256 |
| 257 static void Reconnect(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 258 if (args.Length() != 0) { |
| 259 fprintf(stderr, "Internal error: reconnect()."); |
| 260 Exit(); |
| 261 } |
| 262 v8::base::Semaphore ready_semaphore(0); |
| 263 inspector_client_->scheduleReconnect(&ready_semaphore); |
| 264 ready_semaphore.Wait(); |
| 265 } |
249 }; | 266 }; |
250 | 267 |
251 TaskRunner* UtilsExtension::backend_runner_ = nullptr; | 268 TaskRunner* UtilsExtension::backend_runner_ = nullptr; |
252 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; | 269 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; |
253 | 270 |
254 class SetTimeoutTask : public AsyncTask { | 271 class SetTimeoutTask : public AsyncTask { |
255 public: | 272 public: |
256 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, | 273 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, |
257 const char* task_name, v8_inspector::V8Inspector* inspector) | 274 const char* task_name, v8_inspector::V8Inspector* inspector) |
258 : AsyncTask(task_name, inspector), function_(isolate, function) {} | 275 : AsyncTask(task_name, inspector), function_(isolate, function) {} |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 argv[i]); | 601 argv[i]); |
585 Exit(); | 602 Exit(); |
586 } | 603 } |
587 frontend_runner.Append(new ExecuteStringTask(chars)); | 604 frontend_runner.Append(new ExecuteStringTask(chars)); |
588 } | 605 } |
589 | 606 |
590 frontend_runner.Join(); | 607 frontend_runner.Join(); |
591 backend_runner.Join(); | 608 backend_runner.Join(); |
592 return 0; | 609 return 0; |
593 } | 610 } |
OLD | NEW |