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

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

Issue 810623005: Build Observatory with runtime (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | « runtime/bin/vmservice_impl.h ('k') | runtime/dart-runtime.gyp » ('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 13 matching lines...) Expand all
24 #define SHUTDOWN_ON_ERROR(handle) \ 24 #define SHUTDOWN_ON_ERROR(handle) \
25 if (Dart_IsError(handle)) { \ 25 if (Dart_IsError(handle)) { \
26 error_msg_ = strdup(Dart_GetError(handle)); \ 26 error_msg_ = strdup(Dart_GetError(handle)); \
27 Dart_ExitScope(); \ 27 Dart_ExitScope(); \
28 Dart_ShutdownIsolate(); \ 28 Dart_ShutdownIsolate(); \
29 return false; \ 29 return false; \
30 } 30 }
31 31
32 #define kLibrarySourceNamePrefix "/vmservice" 32 #define kLibrarySourceNamePrefix "/vmservice"
33 static const char* kVMServiceIOLibraryScriptResourceName = "vmservice_io.dart"; 33 static const char* kVMServiceIOLibraryScriptResourceName = "vmservice_io.dart";
34 #define kClientResourceNamePrefix "/vmservice/observatory/deployed/web"
35 34
36 struct ResourcesEntry { 35 struct ResourcesEntry {
37 const char* path_; 36 const char* path_;
38 const char* resource_; 37 const char* resource_;
39 int length_; 38 int length_;
40 }; 39 };
41 40
42 extern ResourcesEntry __service_bin_resources_[]; 41 extern ResourcesEntry __service_bin_resources_[];
43 42
44 class Resources { 43 class Resources {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 238
240 239
241 Dart_Handle VmService::LoadSource(Dart_Handle library, const char* name) { 240 Dart_Handle VmService::LoadSource(Dart_Handle library, const char* name) {
242 Dart_Handle url = Dart_NewStringFromCString(name); 241 Dart_Handle url = Dart_NewStringFromCString(name);
243 Dart_Handle source = GetSource(name); 242 Dart_Handle source = GetSource(name);
244 return Dart_LoadSource(library, url, source, 0, 0); 243 return Dart_LoadSource(library, url, source, 0, 0);
245 } 244 }
246 245
247 246
248 Dart_Handle VmService::LoadResource(Dart_Handle library, 247 Dart_Handle VmService::LoadResource(Dart_Handle library,
249 const char* resource_name, 248 const char* resource_name) {
250 const char* prefix) {
251 intptr_t prefix_len = strlen(prefix);
252 // Prepare for invoke call. 249 // Prepare for invoke call.
253 Dart_Handle name = Dart_NewStringFromCString(resource_name+prefix_len); 250 Dart_Handle name = Dart_NewStringFromCString(resource_name);
254 RETURN_ERROR_HANDLE(name); 251 RETURN_ERROR_HANDLE(name);
255 const char* data_buffer = NULL; 252 const char* data_buffer = NULL;
256 int data_buffer_length = Resources::ResourceLookup(resource_name, 253 int data_buffer_length = Resources::ResourceLookup(resource_name,
257 &data_buffer); 254 &data_buffer);
258 if (data_buffer_length == Resources::kNoSuchInstance) { 255 if (data_buffer_length == Resources::kNoSuchInstance) {
259 printf("Could not find %s %s\n", resource_name, resource_name+prefix_len); 256 printf("Could not find %s %s\n", resource_name, resource_name);
260 } 257 }
261 ASSERT(data_buffer_length != Resources::kNoSuchInstance); 258 ASSERT(data_buffer_length != Resources::kNoSuchInstance);
262 Dart_Handle data_list = Dart_NewTypedData(Dart_TypedData_kUint8, 259 Dart_Handle data_list = Dart_NewTypedData(Dart_TypedData_kUint8,
263 data_buffer_length); 260 data_buffer_length);
264 RETURN_ERROR_HANDLE(data_list); 261 RETURN_ERROR_HANDLE(data_list);
265 Dart_TypedData_Type type = Dart_TypedData_kInvalid; 262 Dart_TypedData_Type type = Dart_TypedData_kInvalid;
266 void* data_list_buffer = NULL; 263 void* data_list_buffer = NULL;
267 intptr_t data_list_buffer_length = 0; 264 intptr_t data_list_buffer_length = 0;
268 Dart_Handle result = Dart_TypedDataAcquireData(data_list, &type, 265 Dart_Handle result = Dart_TypedDataAcquireData(data_list, &type,
269 &data_list_buffer, 266 &data_list_buffer,
(...skipping 10 matching lines...) Expand all
280 const intptr_t kNumArgs = 2; 277 const intptr_t kNumArgs = 2;
281 Dart_Handle args[kNumArgs] = { name, data_list }; 278 Dart_Handle args[kNumArgs] = { name, data_list };
282 result = Dart_Invoke(library, Dart_NewStringFromCString("_addResource"), 279 result = Dart_Invoke(library, Dart_NewStringFromCString("_addResource"),
283 kNumArgs, args); 280 kNumArgs, args);
284 return result; 281 return result;
285 } 282 }
286 283
287 284
288 Dart_Handle VmService::LoadResources(Dart_Handle library) { 285 Dart_Handle VmService::LoadResources(Dart_Handle library) {
289 Dart_Handle result = Dart_Null(); 286 Dart_Handle result = Dart_Null();
290 intptr_t prefixLen = strlen(kClientResourceNamePrefix); 287 intptr_t prefixLen = strlen(kLibrarySourceNamePrefix);
291 for (intptr_t i = 0; Resources::Path(i) != NULL; i++) { 288 for (intptr_t i = 0; Resources::Path(i) != NULL; i++) {
292 const char* path = Resources::Path(i); 289 const char* path = Resources::Path(i);
293 if (!strncmp(path, kClientResourceNamePrefix, prefixLen)) { 290 // If it doesn't begin with kLibrarySourceNamePrefix it is a frontend
294 result = LoadResource(library, path, kClientResourceNamePrefix); 291 // resource.
292 if (strncmp(path, kLibrarySourceNamePrefix, prefixLen) != 0) {
293 result = LoadResource(library, path);
295 if (Dart_IsError(result)) { 294 if (Dart_IsError(result)) {
296 break; 295 break;
297 } 296 }
298 } 297 }
299 } 298 }
300 return result; 299 return result;
301 } 300 }
302 301
303 302
304 Dart_Handle VmService::LibraryTagHandler(Dart_LibraryTag tag, 303 Dart_Handle VmService::LibraryTagHandler(Dart_LibraryTag tag,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 printf("Service exited with an error:\n%s\n", Dart_GetError(result)); 347 printf("Service exited with an error:\n%s\n", Dart_GetError(result));
349 } 348 }
350 Dart_ExitScope(); 349 Dart_ExitScope();
351 Dart_ExitIsolate(); 350 Dart_ExitIsolate();
352 } 351 }
353 352
354 353
355 354
356 } // namespace bin 355 } // namespace bin
357 } // namespace dart 356 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/vmservice_impl.h ('k') | runtime/dart-runtime.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698