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

Side by Side Diff: dart/runtime/bin/vmservice_impl.cc

Issue 239303004: Extract common code, add host IP to --debug and --enable-vm-service options (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/bin/vmservice_impl.h ('k') | dart/tests/standalone/vmservice/test_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "bin/vmservice_impl.h" 5 #include "bin/vmservice_impl.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 static ResourcesEntry* ResourcesTable() { 81 static ResourcesEntry* ResourcesTable() {
82 return &__service_bin_resources_[0]; 82 return &__service_bin_resources_[0];
83 } 83 }
84 84
85 DISALLOW_ALLOCATION(); 85 DISALLOW_ALLOCATION();
86 DISALLOW_IMPLICIT_CONSTRUCTORS(Resources); 86 DISALLOW_IMPLICIT_CONSTRUCTORS(Resources);
87 }; 87 };
88 88
89 const char* VmService::error_msg_ = NULL; 89 const char* VmService::error_msg_ = NULL;
90 90
91 bool VmService::Start(intptr_t server_port) { 91 bool VmService::Start(const char *server_ip, intptr_t server_port) {
92 bool r = _Start(server_port); 92 bool r = _Start(server_ip, server_port);
93 if (!r) { 93 if (!r) {
94 return r; 94 return r;
95 } 95 }
96 // Start processing messages in a new thread. 96 // Start processing messages in a new thread.
97 dart::Thread::Start(ThreadMain, NULL); 97 dart::Thread::Start(ThreadMain, NULL);
98 return true; 98 return true;
99 } 99 }
100 100
101 101
102 bool VmService::_Start(intptr_t server_port) { 102 bool VmService::_Start(const char *server_ip, intptr_t server_port) {
103 ASSERT(Dart_CurrentIsolate() == NULL); 103 ASSERT(Dart_CurrentIsolate() == NULL);
104 Dart_Isolate isolate = Dart_GetServiceIsolate(NULL); 104 Dart_Isolate isolate = Dart_GetServiceIsolate(NULL);
105 if (isolate == NULL) { 105 if (isolate == NULL) {
106 error_msg_ = "Internal error."; 106 error_msg_ = "Internal error.";
107 return false; 107 return false;
108 } 108 }
109 Dart_EnterIsolate(isolate); 109 Dart_EnterIsolate(isolate);
110 Dart_EnterScope(); 110 Dart_EnterScope();
111 // Install our own library tag handler. 111 // Install our own library tag handler.
112 Dart_SetLibraryTagHandler(LibraryTagHandler); 112 Dart_SetLibraryTagHandler(LibraryTagHandler);
113 Dart_Handle result; 113 Dart_Handle result;
114 Dart_Handle library = LoadScript(kVMServiceIOLibraryScriptResourceName); 114 Dart_Handle library = LoadScript(kVMServiceIOLibraryScriptResourceName);
115 // Expect a library. 115 // Expect a library.
116 ASSERT(library != Dart_Null()); 116 ASSERT(library != Dart_Null());
117 SHUTDOWN_ON_ERROR(library); 117 SHUTDOWN_ON_ERROR(library);
118 Dart_ExitScope(); 118 Dart_ExitScope();
119 Dart_ExitIsolate(); 119 Dart_ExitIsolate();
120 bool retval = Dart_IsolateMakeRunnable(isolate); 120 bool retval = Dart_IsolateMakeRunnable(isolate);
121 if (!retval) { 121 if (!retval) {
122 Dart_EnterIsolate(isolate); 122 Dart_EnterIsolate(isolate);
123 Dart_ShutdownIsolate(); 123 Dart_ShutdownIsolate();
124 error_msg_ = "Invalid isolate state - Unable to make it runnable."; 124 error_msg_ = "Invalid isolate state - Unable to make it runnable.";
125 return false; 125 return false;
126 } 126 }
127 127
128 Dart_EnterIsolate(isolate); 128 Dart_EnterIsolate(isolate);
129 Dart_EnterScope(); 129 Dart_EnterScope();
130 library = Dart_RootLibrary(); 130 library = Dart_RootLibrary();
131 // Set requested TCP port. 131 // Set requested TCP port.
132 DartUtils::SetStringField(library, "_ip", server_ip);
132 DartUtils::SetIntegerField(library, "_port", server_port); 133 DartUtils::SetIntegerField(library, "_port", server_port);
133 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL); 134 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL);
134 SHUTDOWN_ON_ERROR(result); 135 SHUTDOWN_ON_ERROR(result);
135 // Load resources. 136 // Load resources.
136 result = LoadResources(library); 137 result = LoadResources(library);
137 SHUTDOWN_ON_ERROR(result); 138 SHUTDOWN_ON_ERROR(result);
138 139
139 Dart_ExitScope(); 140 Dart_ExitScope();
140 Dart_ExitIsolate(); 141 Dart_ExitIsolate();
141 142
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 printf("Service exited with an error:\n%s\n", Dart_GetError(result)); 277 printf("Service exited with an error:\n%s\n", Dart_GetError(result));
277 } 278 }
278 Dart_ExitScope(); 279 Dart_ExitScope();
279 Dart_ExitIsolate(); 280 Dart_ExitIsolate();
280 } 281 }
281 282
282 283
283 284
284 } // namespace bin 285 } // namespace bin
285 } // namespace dart 286 } // namespace dart
OLDNEW
« no previous file with comments | « dart/runtime/bin/vmservice_impl.h ('k') | dart/tests/standalone/vmservice/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698