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

Side by Side Diff: runtime/vm/service.cc

Issue 19622003: VM Service isolate listing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/vm/service.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "vm/isolate.h"
6 #include "vm/message.h"
7 #include "vm/object.h"
8 #include "vm/port.h"
9 #include "vm/service.h"
10
11 namespace dart {
12
13 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
14 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
15 return reinterpret_cast<uint8_t*>(new_ptr);
16 }
17
18
19 static void PostReply(const String& reply, Dart_Port reply_port) {
20 uint8_t* data = NULL;
21 MessageWriter writer(&data, &allocator);
22 writer.WriteMessage(reply);
23 PortMap::PostMessage(new Message(reply_port, Message::kIllegalPort, data,
24 writer.BytesWritten(),
25 Message::kNormalPriority));
26 }
27
28
29 static RawString* HandleIdMessage(Isolate* isolate, Dart_Port reply_port) {
30 TextBuffer buffer(256);
31 buffer.Printf("{ \"id\": \"%s\" }", isolate->name());
32 return String::New(buffer.buf());
33 }
34
35
36 void Service::HandleServiceMessage(Isolate* isolate, Dart_Port reply_port,
37 const Instance& message) {
38 ASSERT(isolate != NULL);
39 ASSERT(reply_port != ILLEGAL_PORT);
40 ASSERT(!message.IsNull());
41 ASSERT(message.IsString());
42
43 String& reply = String::Handle();
44
45 // For now, assume service message is always an id check.
46 reply = HandleIdMessage(isolate, reply_port);
47
48 ASSERT(!reply.IsNull());
49
50 PostReply(reply, reply_port);
51 }
52
53 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698