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 #if defined(PRODUCT) |
| 126 return Smi::New(0); |
| 127 #else |
| 128 return Smi::New(SERVICE_PROTOCOL_MAJOR_VERSION); |
| 129 #endif |
| 130 } |
| 131 |
| 132 |
| 133 DEFINE_NATIVE_ENTRY(Developer_getServiceMinorVersion, 0) { |
| 134 #if defined(PRODUCT) |
| 135 return Smi::New(0); |
| 136 #else |
| 137 return Smi::New(SERVICE_PROTOCOL_MINOR_VERSION); |
| 138 #endif |
| 139 } |
| 140 |
| 141 |
| 142 static void SendNull(const SendPort& port) { |
| 143 const Dart_Port destination_port_id = port.Id(); |
| 144 PortMap::PostMessage(new Message( |
| 145 destination_port_id, Object::null(), Message::kNormalPriority)); |
| 146 } |
| 147 |
| 148 |
| 149 DEFINE_NATIVE_ENTRY(Developer_getServerInfo, 1) { |
| 150 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 151 #if defined(PRODUCT) |
| 152 SendNull(port); |
| 153 return Object::null(); |
| 154 #else |
| 155 if (!ServiceIsolate::IsRunning()) { |
| 156 SendNull(port); |
| 157 } else { |
| 158 ServiceIsolate::RequestServerInfo(port); |
| 159 } |
| 160 return Object::null(); |
| 161 #endif |
| 162 } |
| 163 |
| 164 |
| 165 DEFINE_NATIVE_ENTRY(Developer_webServerControl, 2) { |
| 166 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
| 167 #if defined(PRODUCT) |
| 168 SendNull(port); |
| 169 return Object::null(); |
| 170 #else |
| 171 GET_NON_NULL_NATIVE_ARGUMENT(Bool, enabled, arguments->NativeArgAt(1)); |
| 172 if (!ServiceIsolate::IsRunning()) { |
| 173 SendNull(port); |
| 174 } else { |
| 175 ServiceIsolate::ControlWebServer(port, enabled.value()); |
| 176 } |
| 177 return Object::null(); |
| 178 #endif |
| 179 } |
| 180 |
123 } // namespace dart | 181 } // namespace dart |
OLD | NEW |