OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "include/libplatform/libplatform.h" |
| 6 #include "include/v8.h" |
| 7 |
| 8 #include "src/base/platform/platform.h" |
| 9 #include "src/flags.h" |
| 10 #include "src/inspector/string-util.h" |
| 11 |
| 12 #include "test/inspector-protocol/channel-impl.h" |
| 13 #include "test/inspector-protocol/inspector-client-impl.h" |
| 14 #include "test/inspector-protocol/inspector-extension.h" |
| 15 #include "test/inspector-protocol/load-extension.h" |
| 16 #include "test/inspector-protocol/set-timeout-extension.h" |
| 17 #include "test/inspector-protocol/task-queue.h" |
| 18 #include "test/inspector-protocol/task-runner.h" |
| 19 #include "test/inspector-protocol/task.h" |
| 20 #include "test/inspector-protocol/utils-extension.h" |
| 21 |
| 22 int main(int argc, char* argv[]) { |
| 23 using namespace v8_inspector; |
| 24 |
| 25 v8::V8::InitializeICUDefaultLocation(argv[0]); |
| 26 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); |
| 27 v8::V8::InitializePlatform(platform); |
| 28 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
| 29 v8::V8::InitializeExternalStartupData(argv[0]); |
| 30 v8::V8::Initialize(); |
| 31 |
| 32 SetTimeoutExtension set_timeout_extension; |
| 33 v8::RegisterExtension(&set_timeout_extension); |
| 34 LoadExtension load_extension; |
| 35 v8::RegisterExtension(&load_extension); |
| 36 UtilsExtension utils_extension; |
| 37 v8::RegisterExtension(&utils_extension); |
| 38 BackendExtension backend_extension; |
| 39 v8::RegisterExtension(&backend_extension); |
| 40 FrontendExtension frontend_extension; |
| 41 v8::RegisterExtension(&frontend_extension); |
| 42 |
| 43 TaskQueue backend_queue; |
| 44 FrontendExtension::set_backend_task_queue(&backend_queue); |
| 45 |
| 46 TaskQueue frontend_queue; |
| 47 BackendExtension::set_frontend_task_queue(&frontend_queue); |
| 48 |
| 49 v8::base::Semaphore in_semaphore_(0); |
| 50 TaskRunner backend_task_runner(&backend_queue); |
| 51 |
| 52 const char* backend_extensions[] = {"v8_inspector/setTimeout", |
| 53 "v8_inspector/backend"}; |
| 54 v8::ExtensionConfiguration backend_configuration( |
| 55 arraysize(backend_extensions), backend_extensions); |
| 56 backend_queue.Append( |
| 57 new InitTask(&backend_configuration, &backend_task_runner, nullptr)); |
| 58 V8InspectorClientImpl inspector_client; |
| 59 ChannelImpl channel(&frontend_queue); |
| 60 backend_queue.Append( |
| 61 new ConnectTask(&inspector_client, &channel, &in_semaphore_)); |
| 62 in_semaphore_.Wait(); |
| 63 |
| 64 TaskRunner frontend_task_runner(&frontend_queue); |
| 65 const char* frontend_extensions[] = { |
| 66 "v8_inspector/utils", "v8_inspector/load", "v8_inspector/frontend"}; |
| 67 v8::ExtensionConfiguration frontend_configuration( |
| 68 arraysize(frontend_extensions), frontend_extensions); |
| 69 frontend_queue.Append(new InitTask(&frontend_configuration, |
| 70 &frontend_task_runner, &in_semaphore_)); |
| 71 in_semaphore_.Wait(); |
| 72 |
| 73 for (int i = 1; i < argc; ++i) { |
| 74 if (argv[i][0] == '-') break; |
| 75 const size_t kBufferSize = 1024; |
| 76 char buffer[kBufferSize]; |
| 77 int written = |
| 78 v8::base::OS::SNPrintF(buffer, kBufferSize, "load(\"%s\")", argv[i]); |
| 79 CHECK(written != -1); |
| 80 String16 source(buffer); |
| 81 frontend_queue.Append(new ExecuteStringTask(toStringView(source))); |
| 82 } |
| 83 return 0; |
| 84 } |
OLD | NEW |