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

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

Issue 2204563003: Converted Observatory cpu-profile element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed tmp files Created 4 years, 4 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
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 IsolateSampleProfileRepository _isolateSampleProfileRepository
8 = new IsolateSampleProfileRepository();
9
7 class IsolateNotFound implements Exception { 10 class IsolateNotFound implements Exception {
8 String isolateId; 11 String isolateId;
9 IsolateNotFound(this.isolateId); 12 IsolateNotFound(this.isolateId);
10 String toString() => "IsolateNotFound: $isolateId"; 13 String toString() => "IsolateNotFound: $isolateId";
11 } 14 }
12 15
13 /// A [Page] controls the user interface of Observatory. At any given time 16 /// A [Page] controls the user interface of Observatory. At any given time
14 /// one page will be the current page. Pages are registered at startup. 17 /// one page will be the current page. Pages are registered at startup.
15 /// When the user navigates within the application, each page is asked if it 18 /// When the user navigates within the application, each page is asked if it
16 /// can handle the current location, the first page to say yes, wins. 19 /// can handle the current location, the first page to say yes, wins.
(...skipping 23 matching lines...) Expand all
40 _visit(uri); 43 _visit(uri);
41 } 44 }
42 45
43 // Overridden by subclasses. 46 // Overridden by subclasses.
44 void _visit(Uri uri); 47 void _visit(Uri uri);
45 48
46 /// Called to test whether this page can visit [uri]. 49 /// Called to test whether this page can visit [uri].
47 bool canVisit(Uri uri); 50 bool canVisit(Uri uri);
48 } 51 }
49 52
50 /// A [SimplePage] matches a single uri path and displays a single element. 53 /// A [SimplePage] matches a single uri path and displays a single element.
Cutch 2016/08/02 15:52:19 fix documentation comment
cbernaschina 2016/08/02 17:40:24 Done.
51 class SimplePage extends Page { 54 abstract class MatchingPage extends Page {
52 final String path; 55 final String path;
53 final String elementTagName; 56 MatchingPage(this.path, app) : super(app);
54 SimplePage(this.path, this.elementTagName, app) : super(app);
55
56 void onInstall() {
57 if (element == null) {
58 element = new Element.tag(elementTagName);
59 }
60 }
61 57
62 void _visit(Uri uri) { 58 void _visit(Uri uri) {
63 assert(uri != null); 59 assert(uri != null);
64 assert(canVisit(uri)); 60 assert(canVisit(uri));
65 } 61 }
66 62
67 Future<Isolate> getIsolate(Uri uri) { 63 Future<Isolate> getIsolate(Uri uri) {
68 var isolateId = uri.queryParameters['isolateId']; 64 var isolateId = uri.queryParameters['isolateId'];
69 return app.vm.getIsolate(isolateId).then((isolate) { 65 return app.vm.getIsolate(isolateId).then((isolate) {
70 if (isolate == null) { 66 if (isolate == null) {
71 throw new IsolateNotFound(isolateId); 67 throw new IsolateNotFound(isolateId);
72 } 68 }
73 return isolate; 69 return isolate;
74 }); 70 });
75 } 71 }
76 72
77 bool canVisit(Uri uri) => uri.path == path; 73 bool canVisit(Uri uri) => uri.path == path;
78 } 74 }
79 75
76 /// A [SimplePage] matches a single uri path and displays a single element.
77 class SimplePage extends MatchingPage {
78 final String elementTagName;
79 SimplePage(String path, this.elementTagName, app) : super(path, app);
80
81 void onInstall() {
82 if (element == null) {
83 element = new Element.tag(elementTagName);
84 }
85 }
86 }
87
80 /// Error page for unrecognized paths. 88 /// Error page for unrecognized paths.
81 class ErrorPage extends Page { 89 class ErrorPage extends Page {
82 ErrorPage(app) : super(app); 90 ErrorPage(app) : super(app);
83 91
84 void onInstall() { 92 void onInstall() {
85 if (element == null) { 93 if (element == null) {
86 // Lazily create page. 94 // Lazily create page.
87 element = new Element.tag('general-error'); 95 element = new Element.tag('general-error');
88 } 96 }
89 } 97 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (element != null) { 218 if (element != null) {
211 /// Update the page. 219 /// Update the page.
212 ObjectStoreViewElement page = element; 220 ObjectStoreViewElement page = element;
213 page.objectStore = objectStore; 221 page.objectStore = objectStore;
214 } 222 }
215 }); 223 });
216 }); 224 });
217 } 225 }
218 } 226 }
219 227
220 class CpuProfilerPage extends SimplePage { 228 class CpuProfilerPage extends MatchingPage {
221 CpuProfilerPage(app) : super('profiler', 'cpu-profile', app); 229 CpuProfilerPage(app) : super('profiler', app);
230
231 DivElement container = new DivElement();
222 232
223 void _visit(Uri uri) { 233 void _visit(Uri uri) {
224 super._visit(uri); 234 super._visit(uri);
225 getIsolate(uri).then((isolate) { 235 getIsolate(uri).then((isolate) {
226 if (element != null) { 236 container.children = [
227 /// Update the page. 237 new CpuProfileElement(
228 CpuProfileElement page = element; 238 isolate.vm, isolate.vm.changes.map((_) {
229 page.isolate = isolate; 239 return new VMUpdateEventMock(vm: isolate.vm);
Cutch 2016/08/02 15:52:19 why are mocks present here?
cbernaschina 2016/08/02 17:40:24 I'm building up another CL where all the Events co
230 } 240 }), isolate, isolate.vm.changes.map((_) {
241 return new IsolateUpdateEventMock(isolate: isolate);
242 }),
243 _isolateSampleProfileRepository,
244 app.notifications)
245 ];
231 }); 246 });
232 } 247 }
248
249 void onInstall() {
250 if (element == null) {
251 element = container;
252 }
253 assert(element != null);
254 }
233 } 255 }
234 256
235 class TableCpuProfilerPage extends SimplePage { 257 class TableCpuProfilerPage extends SimplePage {
236 TableCpuProfilerPage(app) 258 TableCpuProfilerPage(app)
237 : super('profiler-table', 'cpu-profile-table', app); 259 : super('profiler-table', 'cpu-profile-table', app);
238 260
239 void _visit(Uri uri) { 261 void _visit(Uri uri) {
240 super._visit(uri); 262 super._visit(uri);
241 getIsolate(uri).then((isolate) { 263 getIsolate(uri).then((isolate) {
242 if (element != null) { 264 if (element != null) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 assert(element != null); 498 assert(element != null);
477 } 499 }
478 500
479 void _visit(Uri uri) { 501 void _visit(Uri uri) {
480 assert(element != null); 502 assert(element != null);
481 assert(canVisit(uri)); 503 assert(canVisit(uri));
482 } 504 }
483 505
484 bool canVisit(Uri uri) => uri.path == 'timeline'; 506 bool canVisit(Uri uri) => uri.path == 'timeline';
485 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698