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

Unified Diff: runtime/bin/vmservice_impl.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/bin/vmservice_impl.h ('k') | runtime/lib/developer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice_impl.cc
diff --git a/runtime/bin/vmservice_impl.cc b/runtime/bin/vmservice_impl.cc
index 871a91c7ca0298d014e94eeb032ccb4728eb8b8a..004cf66dd75e95c549a809660e27e5b813634634 100644
--- a/runtime/bin/vmservice_impl.cc
+++ b/runtime/bin/vmservice_impl.cc
@@ -91,27 +91,20 @@ class Resources {
void NotifyServerState(Dart_NativeArguments args) {
Dart_EnterScope();
- const char* ip_chars;
- Dart_Handle ip_arg = Dart_GetNativeArgument(args, 0);
- if (Dart_IsError(ip_arg)) {
- VmService::SetServerIPAndPort("", 0);
+ const char* uri_chars;
+ Dart_Handle uri_arg = Dart_GetNativeArgument(args, 0);
+ if (Dart_IsError(uri_arg)) {
+ VmService::SetServerAddress("");
Dart_ExitScope();
return;
}
- Dart_Handle result = Dart_StringToCString(ip_arg, &ip_chars);
+ Dart_Handle result = Dart_StringToCString(uri_arg, &uri_chars);
if (Dart_IsError(result)) {
- VmService::SetServerIPAndPort("", 0);
+ VmService::SetServerAddress("");
Dart_ExitScope();
return;
}
- Dart_Handle port_arg = Dart_GetNativeArgument(args, 1);
- if (Dart_IsError(port_arg)) {
- VmService::SetServerIPAndPort("", 0);
- Dart_ExitScope();
- return;
- }
- int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
- VmService::SetServerIPAndPort(ip_chars, port);
+ VmService::SetServerAddress(uri_chars);
Dart_ExitScope();
}
@@ -129,7 +122,7 @@ struct VmServiceIONativeEntry {
static VmServiceIONativeEntry _VmServiceIONativeEntries[] = {
- {"VMServiceIO_NotifyServerState", 2, NotifyServerState},
+ {"VMServiceIO_NotifyServerState", 1, NotifyServerState},
{"VMServiceIO_Shutdown", 0, Shutdown },
};
@@ -156,8 +149,7 @@ static Dart_NativeFunction VmServiceIONativeResolver(Dart_Handle name,
const char* VmService::error_msg_ = NULL;
-char VmService::server_ip_[kServerIpStringBufferSize];
-intptr_t VmService::server_port_ = 0;
+char VmService::server_uri_[kServerUriStringBufferSize];
bool VmService::LoadForGenPrecompiled() {
@@ -180,7 +172,7 @@ bool VmService::Setup(const char* server_ip,
bool dev_mode_server) {
Dart_Isolate isolate = Dart_CurrentIsolate();
ASSERT(isolate != NULL);
- SetServerIPAndPort("", 0);
+ SetServerAddress("");
Dart_Handle result;
@@ -290,13 +282,16 @@ const char* VmService::GetErrorMessage() {
}
-void VmService::SetServerIPAndPort(const char* ip, intptr_t port) {
- if (ip == NULL) {
- ip = "";
+void VmService::SetServerAddress(const char* server_uri) {
+ if (server_uri == NULL) {
+ server_uri = "";
+ }
+ const intptr_t server_uri_len = strlen(server_uri);
+ if (server_uri_len >= (kServerUriStringBufferSize - 1)) {
+ FATAL1("vm-service: Server URI exceeded length: %s\n", server_uri);
}
- strncpy(server_ip_, ip, kServerIpStringBufferSize);
- server_ip_[kServerIpStringBufferSize - 1] = '\0';
- server_port_ = port;
+ strncpy(server_uri_, server_uri, kServerUriStringBufferSize);
+ server_uri_[kServerUriStringBufferSize - 1] = '\0';
}
« no previous file with comments | « runtime/bin/vmservice_impl.h ('k') | runtime/lib/developer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698