mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 01:23:47 +00:00
Small refactor of pages
BUG= R=turnidge@google.com Review URL: https://codereview.chromium.org//897593003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43408 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
900633cf8c
commit
7794b4a71e
|
@ -195,13 +195,6 @@ class ObservatoryApplication extends Observable {
|
|||
currentPage = page;
|
||||
}
|
||||
|
||||
ObservatoryApplication.devtools(this.rootElement) :
|
||||
locationManager = new HashLocationManager(),
|
||||
targets = null {
|
||||
vm = new PostMessageVM();
|
||||
_initOnce(true);
|
||||
}
|
||||
|
||||
ObservatoryApplication(this.rootElement) :
|
||||
locationManager = new HashLocationManager(),
|
||||
targets = new TargetManager() {
|
||||
|
|
|
@ -71,173 +71,111 @@ class ServiceObjectPage extends Page {
|
|||
bool canVisit(String url) => true;
|
||||
}
|
||||
|
||||
/// Class tree page.
|
||||
class ClassTreePage extends Page {
|
||||
static const _urlPrefix = 'class-tree/';
|
||||
|
||||
ClassTreePage(app) : super(app);
|
||||
class IsolateSuffixPage extends Page {
|
||||
final String pagePrefix;
|
||||
final String elementTagName;
|
||||
String _isolateId;
|
||||
String get isolateId => _isolateId;
|
||||
IsolateSuffixPage(this.pagePrefix, this.elementTagName, app) : super(app);
|
||||
|
||||
void onInstall() {
|
||||
if (element == null) {
|
||||
element = new Element.tag('class-tree');
|
||||
element = new Element.tag(elementTagName);
|
||||
}
|
||||
}
|
||||
|
||||
void _visit(String url) {
|
||||
assert(element != null);
|
||||
assert(url != null);
|
||||
assert(canVisit(url));
|
||||
// ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving
|
||||
// isolate url.
|
||||
//
|
||||
// TODO(turnidge): Many pages share the isolate parsing/fetching
|
||||
// code. Consider refactoring.
|
||||
url = url.substring(_urlPrefix.length);
|
||||
/// Request the isolate url.
|
||||
app.vm.get(url).then((isolate) {
|
||||
_isolateId = url.substring(pagePrefix.length);
|
||||
}
|
||||
|
||||
Future<Isolate> getIsolate() {
|
||||
return app.vm.get(isolateId).catchError((e) {
|
||||
Logger.root.severe('$pagePrefix visit error: $e');
|
||||
return e;
|
||||
});
|
||||
}
|
||||
|
||||
bool canVisit(String url) => url.startsWith(pagePrefix);
|
||||
}
|
||||
|
||||
|
||||
/// Class tree page.
|
||||
class ClassTreePage extends IsolateSuffixPage {
|
||||
ClassTreePage(app) : super('class-tree/', 'class-tree', app);
|
||||
|
||||
void _visit(String url) {
|
||||
super._visit(url);
|
||||
getIsolate().then((isolate) {
|
||||
if (element != null) {
|
||||
/// Update the page.
|
||||
ClassTreeElement page = element;
|
||||
page.isolate = isolate;
|
||||
}
|
||||
}).catchError((e) {
|
||||
Logger.root.severe('ClassTreePage visit error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
/// Catch all.
|
||||
bool canVisit(String url) => url.startsWith(_urlPrefix);
|
||||
}
|
||||
|
||||
class DebuggerPage extends Page {
|
||||
static const _urlPrefix = 'debugger/';
|
||||
|
||||
DebuggerPage(app) : super(app);
|
||||
|
||||
void onInstall() {
|
||||
if (element == null) {
|
||||
element = new Element.tag('debugger-page');
|
||||
}
|
||||
}
|
||||
class DebuggerPage extends IsolateSuffixPage {
|
||||
DebuggerPage(app) : super('debugger/', 'debugger-page', app);
|
||||
|
||||
void _visit(String url) {
|
||||
assert(element != null);
|
||||
assert(canVisit(url));
|
||||
// Debugger urls are 'debugger/isolate-id', chop off prefix, leaving
|
||||
// isolate url.
|
||||
url = url.substring(_urlPrefix.length);
|
||||
/// Request the isolate url.
|
||||
app.vm.get(url).then((isolate) {
|
||||
super._visit(url);
|
||||
getIsolate().then((isolate) {
|
||||
if (element != null) {
|
||||
/// Update the page.
|
||||
DebuggerPageElement page = element;
|
||||
page.isolate = isolate;
|
||||
}
|
||||
}).catchError((e) {
|
||||
Logger.root.severe('Unexpected debugger error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
/// Catch all.
|
||||
bool canVisit(String url) => url.startsWith(_urlPrefix);
|
||||
}
|
||||
|
||||
class CpuProfilerPage extends Page {
|
||||
static const _urlPrefix = 'profiler/';
|
||||
|
||||
CpuProfilerPage(app) : super(app);
|
||||
|
||||
void onInstall() {
|
||||
if (element == null) {
|
||||
element = new Element.tag('cpu-profile');
|
||||
}
|
||||
}
|
||||
class CpuProfilerPage extends IsolateSuffixPage {
|
||||
CpuProfilerPage(app) : super('profiler/', 'cpu-profile', app);
|
||||
|
||||
void _visit(String url) {
|
||||
assert(element != null);
|
||||
assert(canVisit(url));
|
||||
// CpuProfiler urls are 'profiler/isolate-id', chop off prefix, leaving
|
||||
// isolate url.
|
||||
url = url.substring(_urlPrefix.length);
|
||||
/// Request the isolate url.
|
||||
app.vm.get(url).then((isolate) {
|
||||
super._visit(url);
|
||||
getIsolate().then((isolate) {
|
||||
if (element != null) {
|
||||
/// Update the page.
|
||||
CpuProfileElement page = element;
|
||||
page.isolate = isolate;
|
||||
}
|
||||
}).catchError((e) {
|
||||
Logger.root.severe('Unexpected profiler error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
/// Catch all.
|
||||
bool canVisit(String url) => url.startsWith(_urlPrefix);
|
||||
}
|
||||
|
||||
class AllocationProfilerPage extends Page {
|
||||
static const _urlPrefix = 'allocation-profiler/';
|
||||
|
||||
AllocationProfilerPage(app) : super(app);
|
||||
|
||||
void onInstall() {
|
||||
if (element == null) {
|
||||
element = new Element.tag('heap-profile');
|
||||
}
|
||||
}
|
||||
class AllocationProfilerPage extends IsolateSuffixPage {
|
||||
AllocationProfilerPage(app)
|
||||
: super('allocation-profiler/', 'heap-profile', app);
|
||||
|
||||
void _visit(String url) {
|
||||
assert(element != null);
|
||||
assert(canVisit(url));
|
||||
// Allocation profiler urls are 'allocation-profiler/isolate-id',
|
||||
// chop off prefix, leaving isolate url.
|
||||
url = url.substring(_urlPrefix.length);
|
||||
/// Request the isolate url.
|
||||
app.vm.get(url).then((isolate) {
|
||||
super._visit(url);
|
||||
getIsolate().then((isolate) {
|
||||
if (element != null) {
|
||||
/// Update the page.
|
||||
HeapProfileElement page = element;
|
||||
page.isolate = isolate;
|
||||
}
|
||||
}).catchError((e) {
|
||||
Logger.root.severe('Unexpected allocation profiler error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
/// Catch all.
|
||||
bool canVisit(String url) => url.startsWith(_urlPrefix);
|
||||
}
|
||||
|
||||
class HeapMapPage extends Page {
|
||||
static const _urlPrefix = 'heap-map/';
|
||||
|
||||
HeapMapPage(app) : super(app);
|
||||
|
||||
void onInstall() {
|
||||
if (element == null) {
|
||||
element = new Element.tag('heap-map');
|
||||
}
|
||||
}
|
||||
class HeapMapPage extends IsolateSuffixPage {
|
||||
HeapMapPage(app) : super('heap-map/', 'heap-map', app);
|
||||
|
||||
void _visit(String url) {
|
||||
assert(element != null);
|
||||
assert(canVisit(url));
|
||||
// Allocation profiler urls are 'heap-map/isolate-id',
|
||||
// chop off prefix, leaving isolate url.
|
||||
url = url.substring(_urlPrefix.length);
|
||||
/// Request the isolate url.
|
||||
app.vm.get(url).then((isolate) {
|
||||
super._visit(url);
|
||||
getIsolate().then((isolate) {
|
||||
if (element != null) {
|
||||
/// Update the page.
|
||||
HeapMapElement page = element;
|
||||
page.isolate = isolate;
|
||||
}
|
||||
}).catchError((e) {
|
||||
Logger.root.severe('Unexpected heap map error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
/// Catch all.
|
||||
bool canVisit(String url) => url.startsWith(_urlPrefix);
|
||||
}
|
||||
|
||||
class ErrorViewPage extends Page {
|
||||
|
|
|
@ -13,7 +13,6 @@ import 'package:polymer/polymer.dart';
|
|||
/// elements.
|
||||
@CustomTag('observatory-application')
|
||||
class ObservatoryApplicationElement extends ObservatoryElement {
|
||||
@published bool devtools = false;
|
||||
@reflectable ObservatoryApplication app;
|
||||
|
||||
ObservatoryApplicationElement.created() : super.created();
|
||||
|
@ -21,10 +20,6 @@ class ObservatoryApplicationElement extends ObservatoryElement {
|
|||
@override
|
||||
void attached() {
|
||||
super.attached();
|
||||
if (devtools) {
|
||||
app = new ObservatoryApplication.devtools(this);
|
||||
} else {
|
||||
app = new ObservatoryApplication(this);
|
||||
}
|
||||
app = new ObservatoryApplication(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,6 @@
|
|||
'lib/src/service/object.dart',
|
||||
'lib/tracer.dart',
|
||||
'web/index.html',
|
||||
'web/index_devtools.html',
|
||||
'web/main.dart',
|
||||
],
|
||||
'actions': [
|
||||
|
@ -187,8 +186,6 @@
|
|||
'outputs': [
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index.html_bootstrap.dart.js',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index_devtools.html',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index_devtools.html_bootstrap.dart.js',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
|
@ -207,14 +204,10 @@
|
|||
'../../tools/observatory_tool.py',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index.html_bootstrap.dart.js',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index_devtools.html',
|
||||
'<(PRODUCT_DIR)/observatory/build/web/index_devtools.html_bootstrap.dart.js',
|
||||
],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/observatory/deployed/web/index.html',
|
||||
'<(PRODUCT_DIR)/observatory/deployed/web/index.html_bootstrap.dart.js',
|
||||
'<(PRODUCT_DIR)/observatory/deployed/web/index_devtools.html',
|
||||
'<(PRODUCT_DIR)/observatory/deployed/web/index_devtools.html_bootstrap.dart.js',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
|
|
|
@ -66,13 +66,13 @@ var tests = [
|
|||
|
||||
List tests = [];
|
||||
// Load code from frame 0.
|
||||
tests.add(isolate.get(codeId0)..then((ServiceObject code) {
|
||||
tests.add(isolate.get(codeId0)..then((Code code) {
|
||||
expect(code.type, equals('Code'));
|
||||
expect(code.function.name, equals('funcB'));
|
||||
expect(code.hasDisassembly, equals(true));
|
||||
}));
|
||||
// Load code from frame 0.
|
||||
tests.add(isolate.get(codeId1)..then((ServiceObject code) {
|
||||
tests.add(isolate.get(codeId1)..then((Code code) {
|
||||
expect(code.type, equals('Code'));
|
||||
expect(code.function.name, equals('funcA'));
|
||||
expect(code.hasDisassembly, equals(true));
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html style="height: 100%">
|
||||
<head>
|
||||
<title>Dart VM Observatory</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="import" href="packages/polymer/polymer.html">
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
<link rel="stylesheet" href="packages/observatory/src/elements/css/shared.css">
|
||||
<link rel="import" href="packages/observatory/elements.html">
|
||||
<script type="application/dart" src="main.dart"></script>
|
||||
<script src="packages/browser/dart.js"></script>
|
||||
</head>
|
||||
<body style="height:100%">
|
||||
<observatory-application devtools="true"></observatory-application>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue