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

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: fjkdls 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 }).catchError((e) { 132 }).catchError((e) {
133 Logger.root.severe('Unexpected debugger error: $e'); 133 Logger.root.severe('Unexpected debugger error: $e');
134 }); 134 });
135 } 135 }
136 136
137 /// Catch all. 137 /// Catch all.
138 bool canVisit(String url) => url.startsWith(_urlPrefix); 138 bool canVisit(String url) => url.startsWith(_urlPrefix);
139 } 139 }
140 140
141 class CpuProfilerPage extends Page {
142 static const _urlPrefix = 'profiler/';
143
144 CpuProfilerPage(app) : super(app);
145
146 void onInstall() {
147 if (element == null) {
148 element = new Element.tag('cpu-profile');
149 }
150 }
151
152 void _visit(String url) {
153 assert(element != null);
154 assert(canVisit(url));
155 // CpuProfiler urls are 'profiler/isolate-id', chop off prefix, leaving
156 // isolate url.
Cutch 2015/02/02 22:20:04 Maybe this stripping of isolate out of the URL sho
turnidge 2015/02/02 22:44:05 Added TODO. I'll be touching this code again soon
157 url = url.substring(_urlPrefix.length);
158 /// Request the isolate url.
159 app.vm.get(url).then((isolate) {
160 if (element != null) {
161 /// Update the page.
162 CpuProfileElement page = element;
163 page.isolate = isolate;
164 }
165 }).catchError((e) {
166 Logger.root.severe('Unexpected profiler error: $e');
167 });
168 }
169
170 /// Catch all.
171 bool canVisit(String url) => url.startsWith(_urlPrefix);
172 }
173
174 class AllocationProfilerPage extends Page {
175 static const _urlPrefix = 'allocation-profiler/';
176
177 AllocationProfilerPage(app) : super(app);
178
179 void onInstall() {
180 if (element == null) {
181 element = new Element.tag('heap-profile');
182 }
183 }
184
185 void _visit(String url) {
186 assert(element != null);
187 assert(canVisit(url));
188 // Allocation profiler urls are 'allocation-profiler/isolate-id',
189 // chop off prefix, leaving isolate url.
190 url = url.substring(_urlPrefix.length);
191 /// Request the isolate url.
192 app.vm.get(url).then((isolate) {
193 if (element != null) {
194 /// Update the page.
195 HeapProfileElement page = element;
196 page.isolate = isolate;
197 }
198 }).catchError((e) {
199 Logger.root.severe('Unexpected allocation profiler error: $e');
200 });
201 }
202
203 /// Catch all.
204 bool canVisit(String url) => url.startsWith(_urlPrefix);
205 }
206
207 class HeapMapPage extends Page {
208 static const _urlPrefix = 'heap-map/';
209
210 HeapMapPage(app) : super(app);
211
212 void onInstall() {
213 if (element == null) {
214 element = new Element.tag('heap-map');
215 }
216 }
217
218 void _visit(String url) {
219 assert(element != null);
220 assert(canVisit(url));
221 // Allocation profiler urls are 'heap-map/isolate-id',
222 // chop off prefix, leaving isolate url.
223 url = url.substring(_urlPrefix.length);
224 /// Request the isolate url.
225 app.vm.get(url).then((isolate) {
226 if (element != null) {
227 /// Update the page.
228 HeapMapElement page = element;
229 page.isolate = isolate;
230 }
231 }).catchError((e) {
232 Logger.root.severe('Unexpected heap map error: $e');
233 });
234 }
235
236 /// Catch all.
237 bool canVisit(String url) => url.startsWith(_urlPrefix);
238 }
239
141 class ErrorViewPage extends Page { 240 class ErrorViewPage extends Page {
142 ErrorViewPage(app) : super(app); 241 ErrorViewPage(app) : super(app);
143 242
144 void onInstall() { 243 void onInstall() {
145 if (element == null) { 244 if (element == null) {
146 /// Lazily create page. 245 /// Lazily create page.
147 element = new Element.tag('service-view'); 246 element = new Element.tag('service-view');
148 } 247 }
149 } 248 }
150 249
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void _visit(String url) { 335 void _visit(String url) {
237 assert(element != null); 336 assert(element != null);
238 assert(canVisit(url)); 337 assert(canVisit(url));
239 app.vm.get(_isolateId(url)).then((i) { 338 app.vm.get(_isolateId(url)).then((i) {
240 (element as MetricsPageElement).isolate = i; 339 (element as MetricsPageElement).isolate = i;
241 }); 340 });
242 } 341 }
243 342
244 bool canVisit(String url) => _matcher.hasMatch(url); 343 bool canVisit(String url) => _matcher.hasMatch(url);
245 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698