| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 read();" | 56 "native function read();" |
| 57 "native function load();" | 57 "native function load();" |
| 58 "native function compileAndRunWithOrigin();" | 58 "native function compileAndRunWithOrigin();" |
| 59 "native function setCurrentTimeMSForTest();" | 59 "native function setCurrentTimeMSForTest();" |
| 60 "native function schedulePauseOnNextStatement();" | 60 "native function schedulePauseOnNextStatement();" |
| 61 "native function cancelPauseOnNextStatement();") {} | 61 "native function cancelPauseOnNextStatement();" |
| 62 "native function reconnect();") {} |
| 62 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 63 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 63 v8::Isolate* isolate, v8::Local<v8::String> name) { | 64 v8::Isolate* isolate, v8::Local<v8::String> name) { |
| 64 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 65 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 65 if (name->Equals(context, v8::String::NewFromUtf8( | 66 if (name->Equals(context, v8::String::NewFromUtf8( |
| 66 isolate, "print", v8::NewStringType::kNormal) | 67 isolate, "print", v8::NewStringType::kNormal) |
| 67 .ToLocalChecked()) | 68 .ToLocalChecked()) |
| 68 .FromJust()) { | 69 .FromJust()) { |
| 69 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); | 70 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); |
| 70 } else if (name->Equals(context, | 71 } else if (name->Equals(context, |
| 71 v8::String::NewFromUtf8(isolate, "quit", | 72 v8::String::NewFromUtf8(isolate, "quit", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 .FromJust()) { | 114 .FromJust()) { |
| 114 return v8::FunctionTemplate::New( | 115 return v8::FunctionTemplate::New( |
| 115 isolate, UtilsExtension::SchedulePauseOnNextStatement); | 116 isolate, UtilsExtension::SchedulePauseOnNextStatement); |
| 116 } else if (name->Equals(context, v8::String::NewFromUtf8( | 117 } else if (name->Equals(context, v8::String::NewFromUtf8( |
| 117 isolate, "cancelPauseOnNextStatement", | 118 isolate, "cancelPauseOnNextStatement", |
| 118 v8::NewStringType::kNormal) | 119 v8::NewStringType::kNormal) |
| 119 .ToLocalChecked()) | 120 .ToLocalChecked()) |
| 120 .FromJust()) { | 121 .FromJust()) { |
| 121 return v8::FunctionTemplate::New( | 122 return v8::FunctionTemplate::New( |
| 122 isolate, UtilsExtension::CancelPauseOnNextStatement); | 123 isolate, UtilsExtension::CancelPauseOnNextStatement); |
| 124 } else if (name->Equals(context, |
| 125 v8::String::NewFromUtf8(isolate, "reconnect", |
| 126 v8::NewStringType::kNormal) |
| 127 .ToLocalChecked()) |
| 128 .FromJust()) { |
| 129 return v8::FunctionTemplate::New(isolate, UtilsExtension::Reconnect); |
| 123 } | 130 } |
| 124 return v8::Local<v8::FunctionTemplate>(); | 131 return v8::Local<v8::FunctionTemplate>(); |
| 125 } | 132 } |
| 126 | 133 |
| 127 static void set_backend_task_runner(TaskRunner* runner) { | 134 static void set_backend_task_runner(TaskRunner* runner) { |
| 128 backend_runner_ = runner; | 135 backend_runner_ = runner; |
| 129 } | 136 } |
| 130 | 137 |
| 131 static void set_inspector_client(InspectorClientImpl* client) { | 138 static void set_inspector_client(InspectorClientImpl* client) { |
| 132 inspector_client_ = client; | 139 inspector_client_ = client; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 275 } |
| 269 | 276 |
| 270 static void CancelPauseOnNextStatement( | 277 static void CancelPauseOnNextStatement( |
| 271 const v8::FunctionCallbackInfo<v8::Value>& args) { | 278 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 272 if (args.Length() != 0) { | 279 if (args.Length() != 0) { |
| 273 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); | 280 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); |
| 274 Exit(); | 281 Exit(); |
| 275 } | 282 } |
| 276 inspector_client_->session()->cancelPauseOnNextStatement(); | 283 inspector_client_->session()->cancelPauseOnNextStatement(); |
| 277 } | 284 } |
| 285 |
| 286 static void Reconnect(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 287 if (args.Length() != 0) { |
| 288 fprintf(stderr, "Internal error: reconnect()."); |
| 289 Exit(); |
| 290 } |
| 291 v8::base::Semaphore ready_semaphore(0); |
| 292 inspector_client_->scheduleReconnect(&ready_semaphore); |
| 293 ready_semaphore.Wait(); |
| 294 } |
| 278 }; | 295 }; |
| 279 | 296 |
| 280 TaskRunner* UtilsExtension::backend_runner_ = nullptr; | 297 TaskRunner* UtilsExtension::backend_runner_ = nullptr; |
| 281 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; | 298 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; |
| 282 | 299 |
| 283 class SetTimeoutTask : public AsyncTask { | 300 class SetTimeoutTask : public AsyncTask { |
| 284 public: | 301 public: |
| 285 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, | 302 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, |
| 286 const char* task_name, v8_inspector::V8Inspector* inspector) | 303 const char* task_name, v8_inspector::V8Inspector* inspector) |
| 287 : AsyncTask(task_name, inspector), function_(isolate, function) {} | 304 : AsyncTask(task_name, inspector), function_(isolate, function) {} |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 argv[i]); | 630 argv[i]); |
| 614 Exit(); | 631 Exit(); |
| 615 } | 632 } |
| 616 frontend_runner.Append(new ExecuteStringTask(chars)); | 633 frontend_runner.Append(new ExecuteStringTask(chars)); |
| 617 } | 634 } |
| 618 | 635 |
| 619 frontend_runner.Join(); | 636 frontend_runner.Join(); |
| 620 backend_runner.Join(); | 637 backend_runner.Join(); |
| 621 return 0; | 638 return 0; |
| 622 } | 639 } |
| OLD | NEW |