| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 "native function reconnect();" |
| 63 "native function createContextGroup();") {} |
| 63 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 64 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 64 v8::Isolate* isolate, v8::Local<v8::String> name) { | 65 v8::Isolate* isolate, v8::Local<v8::String> name) { |
| 65 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 66 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 66 if (name->Equals(context, v8::String::NewFromUtf8( | 67 if (name->Equals(context, v8::String::NewFromUtf8( |
| 67 isolate, "print", v8::NewStringType::kNormal) | 68 isolate, "print", v8::NewStringType::kNormal) |
| 68 .ToLocalChecked()) | 69 .ToLocalChecked()) |
| 69 .FromJust()) { | 70 .FromJust()) { |
| 70 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); | 71 return v8::FunctionTemplate::New(isolate, UtilsExtension::Print); |
| 71 } else if (name->Equals(context, | 72 } else if (name->Equals(context, |
| 72 v8::String::NewFromUtf8(isolate, "quit", | 73 v8::String::NewFromUtf8(isolate, "quit", |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 .ToLocalChecked()) | 121 .ToLocalChecked()) |
| 121 .FromJust()) { | 122 .FromJust()) { |
| 122 return v8::FunctionTemplate::New( | 123 return v8::FunctionTemplate::New( |
| 123 isolate, UtilsExtension::CancelPauseOnNextStatement); | 124 isolate, UtilsExtension::CancelPauseOnNextStatement); |
| 124 } else if (name->Equals(context, | 125 } else if (name->Equals(context, |
| 125 v8::String::NewFromUtf8(isolate, "reconnect", | 126 v8::String::NewFromUtf8(isolate, "reconnect", |
| 126 v8::NewStringType::kNormal) | 127 v8::NewStringType::kNormal) |
| 127 .ToLocalChecked()) | 128 .ToLocalChecked()) |
| 128 .FromJust()) { | 129 .FromJust()) { |
| 129 return v8::FunctionTemplate::New(isolate, UtilsExtension::Reconnect); | 130 return v8::FunctionTemplate::New(isolate, UtilsExtension::Reconnect); |
| 131 } else if (name->Equals(context, v8::String::NewFromUtf8( |
| 132 isolate, "createContextGroup", |
| 133 v8::NewStringType::kNormal) |
| 134 .ToLocalChecked()) |
| 135 .FromJust()) { |
| 136 return v8::FunctionTemplate::New(isolate, |
| 137 UtilsExtension::CreateContextGroup); |
| 130 } | 138 } |
| 131 return v8::Local<v8::FunctionTemplate>(); | 139 return v8::Local<v8::FunctionTemplate>(); |
| 132 } | 140 } |
| 133 | 141 |
| 134 static void set_backend_task_runner(TaskRunner* runner) { | 142 static void set_backend_task_runner(TaskRunner* runner) { |
| 135 backend_runner_ = runner; | 143 backend_runner_ = runner; |
| 136 } | 144 } |
| 137 | 145 |
| 138 static void set_inspector_client(InspectorClientImpl* client) { | 146 static void set_inspector_client(InspectorClientImpl* client) { |
| 139 inspector_client_ = client; | 147 inspector_client_ = client; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 inspector_client_->session()->schedulePauseOnNextStatement(reason_view, | 281 inspector_client_->session()->schedulePauseOnNextStatement(reason_view, |
| 274 details_view); | 282 details_view); |
| 275 } | 283 } |
| 276 | 284 |
| 277 static void CancelPauseOnNextStatement( | 285 static void CancelPauseOnNextStatement( |
| 278 const v8::FunctionCallbackInfo<v8::Value>& args) { | 286 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 279 if (args.Length() != 0) { | 287 if (args.Length() != 0) { |
| 280 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); | 288 fprintf(stderr, "Internal error: cancelPauseOnNextStatement()."); |
| 281 Exit(); | 289 Exit(); |
| 282 } | 290 } |
| 291 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 283 inspector_client_->session()->cancelPauseOnNextStatement(); | 292 inspector_client_->session()->cancelPauseOnNextStatement(); |
| 284 } | 293 } |
| 285 | 294 |
| 286 static void Reconnect(const v8::FunctionCallbackInfo<v8::Value>& args) { | 295 static void Reconnect(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 287 if (args.Length() != 0) { | 296 if (args.Length() != 0) { |
| 288 fprintf(stderr, "Internal error: reconnect()."); | 297 fprintf(stderr, "Internal error: reconnect()."); |
| 289 Exit(); | 298 Exit(); |
| 290 } | 299 } |
| 291 v8::base::Semaphore ready_semaphore(0); | 300 v8::base::Semaphore ready_semaphore(0); |
| 292 inspector_client_->scheduleReconnect(&ready_semaphore); | 301 inspector_client_->scheduleReconnect(&ready_semaphore); |
| 293 ready_semaphore.Wait(); | 302 ready_semaphore.Wait(); |
| 294 } | 303 } |
| 304 |
| 305 static void CreateContextGroup( |
| 306 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 307 if (args.Length() != 0) { |
| 308 fprintf(stderr, "Internal error: createContextGroup()."); |
| 309 Exit(); |
| 310 } |
| 311 const char* backend_extensions[] = {"v8_inspector/setTimeout", |
| 312 "v8_inspector/inspector"}; |
| 313 v8::ExtensionConfiguration backend_configuration( |
| 314 arraysize(backend_extensions), backend_extensions); |
| 315 v8::base::Semaphore ready_semaphore(0); |
| 316 int context_group_id = 0; |
| 317 inspector_client_->scheduleCreateContextGroup( |
| 318 &backend_configuration, &ready_semaphore, &context_group_id); |
| 319 ready_semaphore.Wait(); |
| 320 args.GetReturnValue().Set( |
| 321 v8::Int32::New(args.GetIsolate(), context_group_id)); |
| 322 } |
| 295 }; | 323 }; |
| 296 | 324 |
| 297 TaskRunner* UtilsExtension::backend_runner_ = nullptr; | 325 TaskRunner* UtilsExtension::backend_runner_ = nullptr; |
| 298 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; | 326 InspectorClientImpl* UtilsExtension::inspector_client_ = nullptr; |
| 299 | 327 |
| 300 class SetTimeoutTask : public AsyncTask { | 328 class SetTimeoutTask : public AsyncTask { |
| 301 public: | 329 public: |
| 302 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, | 330 SetTimeoutTask(v8::Isolate* isolate, v8::Local<v8::Function> function, |
| 303 const char* task_name, v8_inspector::V8Inspector* inspector) | 331 const char* task_name, v8_inspector::V8Inspector* inspector) |
| 304 : AsyncTask(task_name, inspector), function_(isolate, function) {} | 332 : AsyncTask(task_name, inspector), function_(isolate, function) {} |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 argv[i]); | 684 argv[i]); |
| 657 Exit(); | 685 Exit(); |
| 658 } | 686 } |
| 659 frontend_runner.Append(new ExecuteStringTask(chars)); | 687 frontend_runner.Append(new ExecuteStringTask(chars)); |
| 660 } | 688 } |
| 661 | 689 |
| 662 frontend_runner.Join(); | 690 frontend_runner.Join(); |
| 663 backend_runner.Join(); | 691 backend_runner.Join(); |
| 664 return 0; | 692 return 0; |
| 665 } | 693 } |
| OLD | NEW |