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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 #ifndef VM_SERVICE_H_ 5 #ifndef VM_SERVICE_H_
6 #define VM_SERVICE_H_ 6 #define VM_SERVICE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/object_id_ring.h"
11 #include "vm/os_thread.h" 12 #include "vm/os_thread.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 class Array; 16 class Array;
16 class EmbedderServiceHandler; 17 class EmbedderServiceHandler;
17 class GCEvent; 18 class GCEvent;
19 class GrowableObjectArray;
18 class Instance; 20 class Instance;
19 class Isolate; 21 class Isolate;
20 class JSONStream; 22 class JSONStream;
21 class Object; 23 class Object;
22 class RawInstance; 24 class RawInstance;
23 class ServiceEvent; 25 class ServiceEvent;
24 class String; 26 class String;
25 27
28 class ServiceIdZone {
29 public:
30 ServiceIdZone();
31 virtual ~ServiceIdZone();
32
33 // Returned string will be zone allocated.
34 virtual char* GetServiceId(const Object& obj) = 0;
35
36 private:
37 };
38
39
40 class RingServiceIdZone : public ServiceIdZone {
41 public:
42 // Use the isolate's object id ring.
43 explicit RingServiceIdZone(ObjectIdRing::IdPolicy policy);
44 virtual ~RingServiceIdZone();
45
46 // Returned string will be zone allocated.
47 virtual char* GetServiceId(const Object& obj);
48
49 private:
50 ObjectIdRing::IdPolicy policy_;
51 };
52
53
54 // Growable array of objects. Ids are derived from the format string passed in
55 // and the index into the storage array. Ids are always reused to avoid growing
56 // the array.
57 class GrowableServiceIdZone : public ServiceIdZone {
58 public:
59 // |format_str| must contain one and only one format specifier (%" Pd "). It
60 // will be replaced with the index into the array. |storage| can not be null.
61 GrowableServiceIdZone(const char* format_str,
62 const GrowableObjectArray& storage);
63 virtual ~GrowableServiceIdZone();
64
65 // Returned string will be zone allocated.
66 virtual char* GetServiceId(const Object& obj);
67
68 private:
69 intptr_t FindIndex(const Object& obj);
70 intptr_t Append(const Object& obj);
71
72 const char* format_str_;
73 const GrowableObjectArray& array_;
74 };
75
76
26 class Service : public AllStatic { 77 class Service : public AllStatic {
27 public: 78 public:
28 // Handles a message which is not directed to an isolate. 79 // Handles a message which is not directed to an isolate.
29 static void HandleRootMessage(const Array& message); 80 static void HandleRootMessage(const Array& message);
30 81
31 // Handles a message which is directed to a particular isolate. 82 // Handles a message which is directed to a particular isolate.
32 static void HandleIsolateMessage(Isolate* isolate, const Array& message); 83 static void HandleIsolateMessage(Isolate* isolate, const Array& message);
33 84
34 static bool NeedsEvents(); 85 static bool NeedsEvents();
35 86
(...skipping 29 matching lines...) Expand all
65 const uint8_t* data, 116 const uint8_t* data,
66 intptr_t size); 117 intptr_t size);
67 118
68 static EmbedderServiceHandler* isolate_service_handler_head_; 119 static EmbedderServiceHandler* isolate_service_handler_head_;
69 static EmbedderServiceHandler* root_service_handler_head_; 120 static EmbedderServiceHandler* root_service_handler_head_;
70 }; 121 };
71 122
72 } // namespace dart 123 } // namespace dart
73 124
74 #endif // VM_SERVICE_H_ 125 #endif // VM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698