Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Unified Diff: runtime/lib/developer.cc

Issue 2438613002: Provide an API to dart:developer to control the web server hosting the Service Protocol (Closed)
Patch Set: disable the auth token until we announce the breaking change Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/lib/developer.cc
diff --git a/runtime/lib/developer.cc b/runtime/lib/developer.cc
index 57a1a4c295abbd3ed4f96fc7ae94f1fb249c9869..a0e315fab4e45bae764c0f241cd42443946e474d 100644
--- a/runtime/lib/developer.cc
+++ b/runtime/lib/developer.cc
@@ -9,6 +9,7 @@
#include "vm/debugger.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
+#include "vm/message.h"
#include "vm/native_entry.h"
#include "vm/object.h"
#include "vm/object_store.h"
@@ -120,4 +121,61 @@ DEFINE_NATIVE_ENTRY(Developer_registerExtension, 2) {
#endif // PRODUCT
}
+DEFINE_NATIVE_ENTRY(Developer_getServiceMajorVersion, 0) {
+#if defined(PRODUCT)
+ return Smi::New(0);
siva 2016/10/21 16:15:06 Shouldn't the product version of these pretty much
+#else
+ return Smi::New(SERVICE_PROTOCOL_MAJOR_VERSION);
+#endif
+}
+
+
+DEFINE_NATIVE_ENTRY(Developer_getServiceMinorVersion, 0) {
+#if defined(PRODUCT)
+ return Smi::New(0);
+#else
+ return Smi::New(SERVICE_PROTOCOL_MINOR_VERSION);
+#endif
+}
+
+
+static void SendNull(const SendPort& port) {
+ const Dart_Port destination_port_id = port.Id();
+ PortMap::PostMessage(new Message(
+ destination_port_id, Object::null(), Message::kNormalPriority));
+}
+
+
+DEFINE_NATIVE_ENTRY(Developer_getServerInfo, 1) {
+ GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
+#if defined(PRODUCT)
+ SendNull(port);
+ return Object::null();
+#else
+ if (!ServiceIsolate::IsRunning()) {
+ SendNull(port);
+ } else {
+ ServiceIsolate::RequestServerInfo(port);
+ }
+ return Object::null();
+#endif
+}
+
+
+DEFINE_NATIVE_ENTRY(Developer_webServerControl, 2) {
+ GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
+#if defined(PRODUCT)
+ SendNull(port);
+ return Object::null();
+#else
+ GET_NON_NULL_NATIVE_ARGUMENT(Bool, enabled, arguments->NativeArgAt(1));
+ if (!ServiceIsolate::IsRunning()) {
+ SendNull(port);
+ } else {
+ ServiceIsolate::ControlWebServer(port, enabled.value());
+ }
+ return Object::null();
+#endif
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698