OLD | NEW |
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 "vm/service.h" | 5 #include "vm/service.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 DECLARE_FLAG(bool, trace_service_pause_events); | 41 DECLARE_FLAG(bool, trace_service_pause_events); |
42 | 42 |
43 ServiceIdZone::ServiceIdZone() { | 43 ServiceIdZone::ServiceIdZone() { |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 ServiceIdZone::~ServiceIdZone() { | 47 ServiceIdZone::~ServiceIdZone() { |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 RingServiceIdZone::RingServiceIdZone( | 51 RingServiceIdZone::RingServiceIdZone() |
52 ObjectIdRing* ring, ObjectIdRing::IdPolicy policy) | 52 : ring_(NULL), |
53 : ring_(ring), | 53 policy_(ObjectIdRing::kAllocateId) { |
54 policy_(policy) { | |
55 ASSERT(ring_ != NULL); | |
56 } | 54 } |
57 | 55 |
58 | 56 |
59 RingServiceIdZone::~RingServiceIdZone() { | 57 RingServiceIdZone::~RingServiceIdZone() { |
60 } | 58 } |
61 | 59 |
62 | 60 |
| 61 void RingServiceIdZone::Init( |
| 62 ObjectIdRing* ring, ObjectIdRing::IdPolicy policy) { |
| 63 ring_ = ring; |
| 64 policy_ = policy; |
| 65 } |
| 66 |
| 67 |
63 char* RingServiceIdZone::GetServiceId(const Object& obj) { | 68 char* RingServiceIdZone::GetServiceId(const Object& obj) { |
| 69 ASSERT(ring_ != NULL); |
64 Thread* thread = Thread::Current(); | 70 Thread* thread = Thread::Current(); |
65 Zone* zone = thread->zone(); | 71 Zone* zone = thread->zone(); |
66 ASSERT(zone != NULL); | 72 ASSERT(zone != NULL); |
67 const intptr_t id = ring_->GetIdForObject(obj.raw(), policy_); | 73 const intptr_t id = ring_->GetIdForObject(obj.raw(), policy_); |
68 return zone->PrintToString("objects/%" Pd "", id); | 74 return zone->PrintToString("objects/%" Pd "", id); |
69 } | 75 } |
70 | 76 |
71 | 77 |
72 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. | 78 // TODO(johnmccutchan): Unify embedder service handler lists and their APIs. |
73 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; | 79 EmbedderServiceHandler* Service::isolate_service_handler_head_ = NULL; |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 } | 1002 } |
997 | 1003 |
998 | 1004 |
999 static bool DumpIdZone(Isolate* isolate, JSONStream* js) { | 1005 static bool DumpIdZone(Isolate* isolate, JSONStream* js) { |
1000 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, | 1006 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, |
1001 // always send the ObjectIdRing. | 1007 // always send the ObjectIdRing. |
1002 // | 1008 // |
1003 ObjectIdRing* ring = isolate->object_id_ring(); | 1009 ObjectIdRing* ring = isolate->object_id_ring(); |
1004 ASSERT(ring != NULL); | 1010 ASSERT(ring != NULL); |
1005 // When printing the ObjectIdRing, force object id reuse policy. | 1011 // When printing the ObjectIdRing, force object id reuse policy. |
1006 RingServiceIdZone reuse_zone(ring, ObjectIdRing::kReuseId); | 1012 RingServiceIdZone reuse_zone; |
| 1013 reuse_zone.Init(ring, ObjectIdRing::kReuseId); |
1007 js->set_id_zone(&reuse_zone); | 1014 js->set_id_zone(&reuse_zone); |
1008 ring->PrintJSON(js); | 1015 ring->PrintJSON(js); |
1009 return true; | 1016 return true; |
1010 } | 1017 } |
1011 | 1018 |
1012 | 1019 |
1013 static bool Echo(Isolate* isolate, JSONStream* js) { | 1020 static bool Echo(Isolate* isolate, JSONStream* js) { |
1014 JSONObject jsobj(js); | 1021 JSONObject jsobj(js); |
1015 return HandleCommonEcho(&jsobj, js); | 1022 return HandleCommonEcho(&jsobj, js); |
1016 } | 1023 } |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3125 ServiceMethodDescriptor& method = service_methods_[i]; | 3132 ServiceMethodDescriptor& method = service_methods_[i]; |
3126 if (strcmp(method_name, method.name) == 0) { | 3133 if (strcmp(method_name, method.name) == 0) { |
3127 return &method; | 3134 return &method; |
3128 } | 3135 } |
3129 } | 3136 } |
3130 return NULL; | 3137 return NULL; |
3131 } | 3138 } |
3132 | 3139 |
3133 | 3140 |
3134 } // namespace dart | 3141 } // namespace dart |
OLD | NEW |