| 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 "include/libplatform/libplatform.h" | 9 #include "include/libplatform/libplatform.h" |
| 10 #include "include/v8.h" | 10 #include "include/v8.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 : v8::Extension("v8_inspector/setTimeout", | 120 : v8::Extension("v8_inspector/setTimeout", |
| 121 "native function setTimeout();") {} | 121 "native function setTimeout();") {} |
| 122 | 122 |
| 123 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 123 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 124 v8::Isolate* isolate, v8::Local<v8::String> name) { | 124 v8::Isolate* isolate, v8::Local<v8::String> name) { |
| 125 return v8::FunctionTemplate::New(isolate, SetTimeoutExtension::SetTimeout); | 125 return v8::FunctionTemplate::New(isolate, SetTimeoutExtension::SetTimeout); |
| 126 } | 126 } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 static void SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) { | 129 static void SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 130 v8::Isolate* isolate = args.GetIsolate(); | |
| 131 if (args.Length() != 2 || !args[1]->IsNumber() || | 130 if (args.Length() != 2 || !args[1]->IsNumber() || |
| 132 (!args[0]->IsFunction() && !args[0]->IsString()) || | 131 (!args[0]->IsFunction() && !args[0]->IsString()) || |
| 133 args[1].As<v8::Number>()->Value() != 0.0) { | 132 args[1].As<v8::Number>()->Value() != 0.0) { |
| 134 fprintf(stderr, | 133 fprintf(stderr, |
| 135 "Internal error: only setTimeout(function, 0) is supported."); | 134 "Internal error: only setTimeout(function, 0) is supported."); |
| 136 Exit(); | 135 Exit(); |
| 137 } | 136 } |
| 138 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 137 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
| 139 if (args[0]->IsFunction()) { | 138 if (args[0]->IsFunction()) { |
| 140 TaskRunner::FromContext(context)->Append(new SetTimeoutTask( | 139 TaskRunner::FromContext(context)->Append(new SetTimeoutTask( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 Exit(); | 226 Exit(); |
| 228 } | 227 } |
| 229 v8_inspector::String16 source = | 228 v8_inspector::String16 source = |
| 230 v8_inspector::String16::fromUTF8(chars.start(), chars.length()); | 229 v8_inspector::String16::fromUTF8(chars.start(), chars.length()); |
| 231 frontend_runner.Append(new ExecuteStringTask(source)); | 230 frontend_runner.Append(new ExecuteStringTask(source)); |
| 232 } | 231 } |
| 233 | 232 |
| 234 frontend_runner.Join(); | 233 frontend_runner.Join(); |
| 235 return 0; | 234 return 0; |
| 236 } | 235 } |
| OLD | NEW |