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

Side by Side Diff: runtime/bin/vmstats_impl.h

Issue 12221022: Initial prototype of vmstats support, based on Dart VM Stats draft design doc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Code review feedback response Created 7 years, 10 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
(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 #ifndef BIN_VMSTATS_IMPL_H_
6 #define BIN_VMSTATS_IMPL_H_
7
8 #include "bin/vmstats.h"
9
10 #include <map>
11 #include <sstream>
12 #include <string>
13
14 #include "bin/isolate_data.h"
15 #include "platform/thread.h"
16
17 namespace dart {
18
19 // VmStats is a HTTP singleton service that reports status information
20 // of the running VM.
21
22 class VmStats {
23 public:
24 static void Start(int port, const char* root_dir);
25 static void Stop();
26
27 // Add and remove functions for the isolate_table, called by main.cc.
28 static void AddIsolate(IsolateData* isolate_data, Dart_Isolate isolate);
29 static void RemoveIsolate(IsolateData* isolate_data);
30
31 private:
32 VmStats() : running_(false) {}
33
34 static void WebServer(uword bind_address);
35 static void Shutdown();
36
37 // Status text generators.
38 char* IsolatesStatus();
39
40 typedef std::map<IsolateData*, Dart_Isolate> IsolateTable;
41
42 std::string root_directory_;
43 IsolateTable isolate_table_;
44 bool running_;
45
46 static VmStats* instance_;
47 static Monitor instance_monitor_;
48
49 // Disallow copy constructor.
50 DISALLOW_COPY_AND_ASSIGN(VmStats);
51 };
52
53
54 // Status plug-in and linked-list node.
55 class VmStatusPlugin {
56 public:
57 explicit VmStatusPlugin(Dart_VmStatusCallback callback)
58 : callback_(callback), next_(NULL) {}
59
60 void Append(VmStatusPlugin* plugin) {
61 VmStatusPlugin* list = this;
62 while (list->next_ != NULL) {
63 list = list->next_;
64 }
65 list->next_ = plugin;
66 }
67
68 Dart_VmStatusCallback callback() { return callback_; }
69 VmStatusPlugin* next() { return next_; }
70
71 private:
72 Dart_VmStatusCallback callback_;
73 VmStatusPlugin* next_;
74 };
75
76
77 // Singleton service managing VM status gathering and status plug-in
78 // registration.
79 class VmStatusService {
80 public:
81 static int RegisterPlugin(Dart_VmStatusCallback callback);
82
83 // Returns VM status for a specified request. The caller is responsible
84 // for releasing the heap memory after use.
85 static char* GetVmStatus(const char* request);
86
87 static void InitOnce();
88
89 private:
90 VmStatusService() : registered_plugin_list_(NULL) {}
91
92 static VmStatusService* instance_;
93 static Mutex mutex_;
94
95 VmStatusPlugin* registered_plugin_list_;
96
97 DISALLOW_COPY_AND_ASSIGN(VmStatusService);
98 };
99
100 } // namespace dart
101
102 #endif // BIN_VMSTATS_IMPL_H_
OLDNEW
« no previous file with comments | « runtime/bin/vmstats.h ('k') | runtime/bin/vmstats_impl.cc » ('j') | runtime/bin/vmstats_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698