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

Unified Diff: runtime/vm/service_isolate.cc

Issue 2438613002: Provide an API to dart:developer to control the web server hosting the Service Protocol (Closed)
Patch Set: CHANGELOG.md merge and fatal error Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/service_isolate.h ('k') | sdk/lib/_internal/js_runtime/lib/developer_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service_isolate.cc
diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc
index c5e2e753039753048003e07879311161ffbde059..5a3b1d4b5bfdc360933de5dcd06bdcc41a48c893 100644
--- a/runtime/vm/service_isolate.cc
+++ b/runtime/vm/service_isolate.cc
@@ -43,6 +43,9 @@ static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
#define VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID 1
#define VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID 2
+#define VM_SERVICE_WEB_SERVER_CONTROL_MESSAGE_ID 3
+#define VM_SERVICE_SERVER_INFO_MESSAGE_ID 4
+
static RawArray* MakeServiceControlMessage(Dart_Port port_id, intptr_t code,
const String& name) {
const Array& list = Array::Handle(Array::New(4));
@@ -58,6 +61,18 @@ static RawArray* MakeServiceControlMessage(Dart_Port port_id, intptr_t code,
}
+static RawArray* MakeServerControlMessage(const SendPort& sp,
+ intptr_t code,
+ bool enable = false) {
+ const Array& list = Array::Handle(Array::New(3));
+ ASSERT(!list.IsNull());
+ list.SetAt(0, Integer::Handle(Integer::New(code)));
+ list.SetAt(1, sp);
+ list.SetAt(2, Bool::Get(enable));
+ return list.raw();
+}
+
+
static RawArray* MakeServiceExitMessage() {
const Array& list = Array::Handle(Array::New(1));
ASSERT(!list.IsNull());
@@ -81,6 +96,36 @@ bool ServiceIsolate::initializing_ = true;
bool ServiceIsolate::shutting_down_ = false;
char* ServiceIsolate::server_address_ = NULL;
+void ServiceIsolate::RequestServerInfo(const SendPort& sp) {
+ const Array& message =
+ Array::Handle(
+ MakeServerControlMessage(sp,
+ VM_SERVICE_SERVER_INFO_MESSAGE_ID,
+ false /* ignored */));
+ ASSERT(!message.IsNull());
+ uint8_t* data = NULL;
+ MessageWriter writer(&data, &allocator, false);
+ writer.WriteMessage(message);
+ intptr_t len = writer.BytesWritten();
+ PortMap::PostMessage(new Message(port_, data, len, Message::kNormalPriority));
+}
+
+
+void ServiceIsolate::ControlWebServer(const SendPort& sp, bool enable) {
+ const Array& message =
+ Array::Handle(
+ MakeServerControlMessage(sp,
+ VM_SERVICE_WEB_SERVER_CONTROL_MESSAGE_ID,
+ enable));
+ ASSERT(!message.IsNull());
+ uint8_t* data = NULL;
+ MessageWriter writer(&data, &allocator, false);
+ writer.WriteMessage(message);
+ intptr_t len = writer.BytesWritten();
+ PortMap::PostMessage(new Message(port_, data, len, Message::kNormalPriority));
+}
+
+
void ServiceIsolate::SetServerAddress(const char* address) {
if (server_address_ != NULL) {
free(server_address_);
« no previous file with comments | « runtime/vm/service_isolate.h ('k') | sdk/lib/_internal/js_runtime/lib/developer_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698