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

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: updated CHANGELOG.md 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..e764ff9acc4f4d7207651fa5f421bf76823686f1 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,53 @@ DEFINE_NATIVE_ENTRY(Developer_registerExtension, 2) {
#endif // PRODUCT
}
+DEFINE_NATIVE_ENTRY(Developer_getServiceMajorVersion, 0) {
+ return Smi::New(SERVICE_PROTOCOL_MAJOR_VERSION);
rmacnak 2016/10/20 17:12:31 Consider returning 0 in product mode or no service
Cutch 2016/10/20 23:31:51 Done.
+}
+
+
+DEFINE_NATIVE_ENTRY(Developer_getServiceMinorVersion, 0) {
+ return Smi::New(SERVICE_PROTOCOL_MINOR_VERSION);
+}
+
+
+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));
+ GET_NON_NULL_NATIVE_ARGUMENT(Bool, enabled, arguments->NativeArgAt(1));
+#if defined(PRODUCT)
+ SendNull(port);
+ return Object::null();
+#else
+ 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