OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
11 #include "vm/flags.h" | 11 #include "vm/flags.h" |
| 12 #include "vm/message.h" |
12 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
13 #include "vm/object.h" | 14 #include "vm/object.h" |
14 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
15 #include "vm/service.h" | 16 #include "vm/service.h" |
16 #include "vm/service_isolate.h" | 17 #include "vm/service_isolate.h" |
17 | 18 |
18 namespace dart { | 19 namespace dart { |
19 | 20 |
20 // Native implementations for the dart:developer library. | 21 // Native implementations for the dart:developer library. |
21 DEFINE_NATIVE_ENTRY(Developer_debugger, 2) { | 22 DEFINE_NATIVE_ENTRY(Developer_debugger, 2) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // service isolate. This can happen, for example, because the | 114 // service isolate. This can happen, for example, because the |
114 // service isolate uses dart:io. If we decide that we want to start | 115 // service isolate uses dart:io. If we decide that we want to start |
115 // supporting this in the future, it will take some work. | 116 // supporting this in the future, it will take some work. |
116 if (!ServiceIsolate::IsServiceIsolateDescendant(isolate)) { | 117 if (!ServiceIsolate::IsServiceIsolateDescendant(isolate)) { |
117 isolate->RegisterServiceExtensionHandler(name, handler); | 118 isolate->RegisterServiceExtensionHandler(name, handler); |
118 } | 119 } |
119 return Object::null(); | 120 return Object::null(); |
120 #endif // PRODUCT | 121 #endif // PRODUCT |
121 } | 122 } |
122 | 123 |
| 124 DEFINE_NATIVE_ENTRY(Developer_getServiceMajorVersion, 0) { |
| 125 return Smi::New(SERVICE_PROTOCOL_MAJOR_VERSION); |
| 126 } |
| 127 |
| 128 |
| 129 DEFINE_NATIVE_ENTRY(Developer_getServiceMinorVersion, 0) { |
| 130 return Smi::New(SERVICE_PROTOCOL_MINOR_VERSION); |
| 131 } |
| 132 |
| 133 |
| 134 static void SendNull(const SendPort& port) { |
| 135 const Dart_Port destination_port_id = port.Id(); |
| 136 PortMap::PostMessage(new Message( |
| 137 destination_port_id, Object::null(), Message::kNormalPriority)); |
| 138 } |
| 139 |
| 140 |
| 141 DEFINE_NATIVE_ENTRY(Developer_getServerInfo, 1) { |
| 142 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 143 #if defined(PRODUCT) |
| 144 SendNull(port); |
| 145 return Object::null(); |
| 146 #else |
| 147 if (!ServiceIsolate::IsRunning()) { |
| 148 SendNull(port); |
| 149 } else { |
| 150 ServiceIsolate::RequestServerInfo(port); |
| 151 } |
| 152 return Object::null(); |
| 153 #endif |
| 154 } |
| 155 |
| 156 |
| 157 DEFINE_NATIVE_ENTRY(Developer_webServerControl, 2) { |
| 158 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 159 GET_NON_NULL_NATIVE_ARGUMENT(Bool, enabled, arguments->NativeArgAt(1)); |
| 160 #if defined(PRODUCT) |
| 161 SendNull(port); |
| 162 return Object::null(); |
| 163 #else |
| 164 if (!ServiceIsolate::IsRunning()) { |
| 165 SendNull(port); |
| 166 } else { |
| 167 ServiceIsolate::ControlWebServer(port, enabled.value()); |
| 168 } |
| 169 return Object::null(); |
| 170 #endif |
| 171 } |
| 172 |
123 } // namespace dart | 173 } // namespace dart |
OLD | NEW |