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

Unified Diff: runtime/vm/service.h

Issue 1132323002: Add Service ID zones to service protocol (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/service.h
diff --git a/runtime/vm/service.h b/runtime/vm/service.h
index a635dc30d08c7e37cdc9bb0bba341da412552605..a0b3a2e2cca8b125f4489e2ee47346b2bc50e0df 100644
--- a/runtime/vm/service.h
+++ b/runtime/vm/service.h
@@ -8,6 +8,7 @@
#include "include/dart_api.h"
#include "vm/allocation.h"
+#include "vm/object_id_ring.h"
#include "vm/os_thread.h"
namespace dart {
@@ -15,6 +16,7 @@ namespace dart {
class Array;
class EmbedderServiceHandler;
class GCEvent;
+class GrowableObjectArray;
class Instance;
class Isolate;
class JSONStream;
@@ -23,6 +25,55 @@ class RawInstance;
class ServiceEvent;
class String;
+class ServiceIdZone {
+ public:
+ ServiceIdZone();
+ virtual ~ServiceIdZone();
+
+ // Returned string will be zone allocated.
+ virtual char* GetServiceId(const Object& obj) = 0;
+
+ private:
+};
+
+
+class RingServiceIdZone : public ServiceIdZone {
+ public:
+ // Use the isolate's object id ring.
+ explicit RingServiceIdZone(ObjectIdRing::IdPolicy policy);
+ virtual ~RingServiceIdZone();
+
+ // Returned string will be zone allocated.
+ virtual char* GetServiceId(const Object& obj);
+
+ private:
+ ObjectIdRing::IdPolicy policy_;
+};
+
+
+// Growable array of objects. Ids are derived from the format string passed in
+// and the index into the storage array. Ids are always reused to avoid growing
+// the array.
+class GrowableServiceIdZone : public ServiceIdZone {
+ public:
+ // |format_str| must contain one and only one format specifier (%" Pd "). It
+ // will be replaced with the index into the array. |storage| can not be null.
+ GrowableServiceIdZone(const char* format_str,
+ const GrowableObjectArray& storage);
+ virtual ~GrowableServiceIdZone();
+
+ // Returned string will be zone allocated.
+ virtual char* GetServiceId(const Object& obj);
+
+ private:
+ intptr_t FindIndex(const Object& obj);
+ intptr_t Append(const Object& obj);
+
+ const char* format_str_;
+ const GrowableObjectArray& array_;
+};
+
+
class Service : public AllStatic {
public:
// Handles a message which is not directed to an isolate.

Powered by Google App Engine
This is Rietveld 408576698