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

Side by Side Diff: runtime/observatory/lib/src/app/page.dart

Issue 823403004: Begin migrating the vm service from a rest-style interface to a json-rpc style interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove old-style standalone tests. Created 5 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of app; 5 part of app;
6 6
7 /// A [Page] controls the user interface of Observatory. At any given time 7 /// A [Page] controls the user interface of Observatory. At any given time
8 /// one page will be the current page. Pages are registered at startup. 8 /// one page will be the current page. Pages are registered at startup.
9 /// When the user navigates within the application, each page is asked if it 9 /// When the user navigates within the application, each page is asked if it
10 /// can handle the current location, the first page to say yes, wins. 10 /// can handle the current location, the first page to say yes, wins.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if (element == null) { 81 if (element == null) {
82 element = new Element.tag('class-tree'); 82 element = new Element.tag('class-tree');
83 } 83 }
84 } 84 }
85 85
86 void _visit(String url) { 86 void _visit(String url) {
87 assert(element != null); 87 assert(element != null);
88 assert(canVisit(url)); 88 assert(canVisit(url));
89 // ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving 89 // ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving
90 // isolate url. 90 // isolate url.
91 //
92 // TODO(turnidge): Many pages share the isolate parsing/fetching
93 // code. Consider refactoring.
91 url = url.substring(_urlPrefix.length); 94 url = url.substring(_urlPrefix.length);
92 /// Request the isolate url. 95 /// Request the isolate url.
93 app.vm.get(url).then((isolate) { 96 app.vm.get(url).then((isolate) {
94 if (element != null) { 97 if (element != null) {
95 /// Update the page. 98 /// Update the page.
96 ClassTreeElement page = element; 99 ClassTreeElement page = element;
97 page.isolate = isolate; 100 page.isolate = isolate;
98 } 101 }
99 }).catchError((e) { 102 }).catchError((e) {
100 Logger.root.severe('ClassTreePage visit error: $e'); 103 Logger.root.severe('ClassTreePage visit error: $e');
(...skipping 30 matching lines...) Expand all
131 } 134 }
132 }).catchError((e) { 135 }).catchError((e) {
133 Logger.root.severe('Unexpected debugger error: $e'); 136 Logger.root.severe('Unexpected debugger error: $e');
134 }); 137 });
135 } 138 }
136 139
137 /// Catch all. 140 /// Catch all.
138 bool canVisit(String url) => url.startsWith(_urlPrefix); 141 bool canVisit(String url) => url.startsWith(_urlPrefix);
139 } 142 }
140 143
144 class CpuProfilerPage extends Page {
145 static const _urlPrefix = 'profiler/';
146
147 CpuProfilerPage(app) : super(app);
148
149 void onInstall() {
150 if (element == null) {
151 element = new Element.tag('cpu-profile');
152 }
153 }
154
155 void _visit(String url) {
156 assert(element != null);
157 assert(canVisit(url));
158 // CpuProfiler urls are 'profiler/isolate-id', chop off prefix, leaving
159 // isolate url.
160 url = url.substring(_urlPrefix.length);
161 /// Request the isolate url.
162 app.vm.get(url).then((isolate) {
163 if (element != null) {
164 /// Update the page.
165 CpuProfileElement page = element;
166 page.isolate = isolate;
167 }
168 }).catchError((e) {
169 Logger.root.severe('Unexpected profiler error: $e');
170 });
171 }
172
173 /// Catch all.
174 bool canVisit(String url) => url.startsWith(_urlPrefix);
175 }
176
177 class AllocationProfilerPage extends Page {
178 static const _urlPrefix = 'allocation-profiler/';
179
180 AllocationProfilerPage(app) : super(app);
181
182 void onInstall() {
183 if (element == null) {
184 element = new Element.tag('heap-profile');
185 }
186 }
187
188 void _visit(String url) {
189 assert(element != null);
190 assert(canVisit(url));
191 // Allocation profiler urls are 'allocation-profiler/isolate-id',
192 // chop off prefix, leaving isolate url.
193 url = url.substring(_urlPrefix.length);
194 /// Request the isolate url.
195 app.vm.get(url).then((isolate) {
196 if (element != null) {
197 /// Update the page.
198 HeapProfileElement page = element;
199 page.isolate = isolate;
200 }
201 }).catchError((e) {
202 Logger.root.severe('Unexpected allocation profiler error: $e');
203 });
204 }
205
206 /// Catch all.
207 bool canVisit(String url) => url.startsWith(_urlPrefix);
208 }
209
210 class HeapMapPage extends Page {
211 static const _urlPrefix = 'heap-map/';
212
213 HeapMapPage(app) : super(app);
214
215 void onInstall() {
216 if (element == null) {
217 element = new Element.tag('heap-map');
218 }
219 }
220
221 void _visit(String url) {
222 assert(element != null);
223 assert(canVisit(url));
224 // Allocation profiler urls are 'heap-map/isolate-id',
225 // chop off prefix, leaving isolate url.
226 url = url.substring(_urlPrefix.length);
227 /// Request the isolate url.
228 app.vm.get(url).then((isolate) {
229 if (element != null) {
230 /// Update the page.
231 HeapMapElement page = element;
232 page.isolate = isolate;
233 }
234 }).catchError((e) {
235 Logger.root.severe('Unexpected heap map error: $e');
236 });
237 }
238
239 /// Catch all.
240 bool canVisit(String url) => url.startsWith(_urlPrefix);
241 }
242
141 class ErrorViewPage extends Page { 243 class ErrorViewPage extends Page {
142 ErrorViewPage(app) : super(app); 244 ErrorViewPage(app) : super(app);
143 245
144 void onInstall() { 246 void onInstall() {
145 if (element == null) { 247 if (element == null) {
146 /// Lazily create page. 248 /// Lazily create page.
147 element = new Element.tag('service-view'); 249 element = new Element.tag('service-view');
148 } 250 }
149 } 251 }
150 252
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void _visit(String url) { 338 void _visit(String url) {
237 assert(element != null); 339 assert(element != null);
238 assert(canVisit(url)); 340 assert(canVisit(url));
239 app.vm.get(_isolateId(url)).then((i) { 341 app.vm.get(_isolateId(url)).then((i) {
240 (element as MetricsPageElement).isolate = i; 342 (element as MetricsPageElement).isolate = i;
241 }); 343 });
242 } 344 }
243 345
244 bool canVisit(String url) => _matcher.hasMatch(url); 346 bool canVisit(String url) => _matcher.hasMatch(url);
245 } 347 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/app/application.dart ('k') | runtime/observatory/lib/src/elements/class_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698