mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 05:23:31 +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;
|
currentPage = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObservatoryApplication.devtools(this.rootElement) :
|
|
||||||
locationManager = new HashLocationManager(),
|
|
||||||
targets = null {
|
|
||||||
vm = new PostMessageVM();
|
|
||||||
_initOnce(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObservatoryApplication(this.rootElement) :
|
ObservatoryApplication(this.rootElement) :
|
||||||
locationManager = new HashLocationManager(),
|
locationManager = new HashLocationManager(),
|
||||||
targets = new TargetManager() {
|
targets = new TargetManager() {
|
||||||
|
|
|
@ -71,173 +71,111 @@ class ServiceObjectPage extends Page {
|
||||||
bool canVisit(String url) => true;
|
bool canVisit(String url) => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Class tree page.
|
class IsolateSuffixPage extends Page {
|
||||||
class ClassTreePage extends Page {
|
final String pagePrefix;
|
||||||
static const _urlPrefix = 'class-tree/';
|
final String elementTagName;
|
||||||
|
String _isolateId;
|
||||||
ClassTreePage(app) : super(app);
|
String get isolateId => _isolateId;
|
||||||
|
IsolateSuffixPage(this.pagePrefix, this.elementTagName, app) : super(app);
|
||||||
|
|
||||||
void onInstall() {
|
void onInstall() {
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
element = new Element.tag('class-tree');
|
element = new Element.tag(elementTagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _visit(String url) {
|
void _visit(String url) {
|
||||||
assert(element != null);
|
assert(url != null);
|
||||||
assert(canVisit(url));
|
assert(canVisit(url));
|
||||||
// ClassTree urls are 'class-tree/isolate-id', chop off prefix, leaving
|
_isolateId = url.substring(pagePrefix.length);
|
||||||
// isolate url.
|
}
|
||||||
//
|
|
||||||
// TODO(turnidge): Many pages share the isolate parsing/fetching
|
Future<Isolate> getIsolate() {
|
||||||
// code. Consider refactoring.
|
return app.vm.get(isolateId).catchError((e) {
|
||||||
url = url.substring(_urlPrefix.length);
|
Logger.root.severe('$pagePrefix visit error: $e');
|
||||||
/// Request the isolate url.
|
return e;
|
||||||
app.vm.get(url).then((isolate) {
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
if (element != null) {
|
||||||
/// Update the page.
|
/// Update the page.
|
||||||
ClassTreeElement page = element;
|
ClassTreeElement page = element;
|
||||||
page.isolate = isolate;
|
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 {
|
class DebuggerPage extends IsolateSuffixPage {
|
||||||
static const _urlPrefix = 'debugger/';
|
DebuggerPage(app) : super('debugger/', 'debugger-page', app);
|
||||||
|
|
||||||
DebuggerPage(app) : super(app);
|
|
||||||
|
|
||||||
void onInstall() {
|
|
||||||
if (element == null) {
|
|
||||||
element = new Element.tag('debugger-page');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _visit(String url) {
|
void _visit(String url) {
|
||||||
assert(element != null);
|
super._visit(url);
|
||||||
assert(canVisit(url));
|
getIsolate().then((isolate) {
|
||||||
// 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) {
|
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
/// Update the page.
|
/// Update the page.
|
||||||
DebuggerPageElement page = element;
|
DebuggerPageElement page = element;
|
||||||
page.isolate = isolate;
|
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 {
|
class CpuProfilerPage extends IsolateSuffixPage {
|
||||||
static const _urlPrefix = 'profiler/';
|
CpuProfilerPage(app) : super('profiler/', 'cpu-profile', app);
|
||||||
|
|
||||||
CpuProfilerPage(app) : super(app);
|
|
||||||
|
|
||||||
void onInstall() {
|
|
||||||
if (element == null) {
|
|
||||||
element = new Element.tag('cpu-profile');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _visit(String url) {
|
void _visit(String url) {
|
||||||
assert(element != null);
|
super._visit(url);
|
||||||
assert(canVisit(url));
|
getIsolate().then((isolate) {
|
||||||
// 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) {
|
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
/// Update the page.
|
/// Update the page.
|
||||||
CpuProfileElement page = element;
|
CpuProfileElement page = element;
|
||||||
page.isolate = isolate;
|
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 {
|
class AllocationProfilerPage extends IsolateSuffixPage {
|
||||||
static const _urlPrefix = 'allocation-profiler/';
|
AllocationProfilerPage(app)
|
||||||
|
: super('allocation-profiler/', 'heap-profile', app);
|
||||||
AllocationProfilerPage(app) : super(app);
|
|
||||||
|
|
||||||
void onInstall() {
|
|
||||||
if (element == null) {
|
|
||||||
element = new Element.tag('heap-profile');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _visit(String url) {
|
void _visit(String url) {
|
||||||
assert(element != null);
|
super._visit(url);
|
||||||
assert(canVisit(url));
|
getIsolate().then((isolate) {
|
||||||
// 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) {
|
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
/// Update the page.
|
/// Update the page.
|
||||||
HeapProfileElement page = element;
|
HeapProfileElement page = element;
|
||||||
page.isolate = isolate;
|
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 {
|
class HeapMapPage extends IsolateSuffixPage {
|
||||||
static const _urlPrefix = 'heap-map/';
|
HeapMapPage(app) : super('heap-map/', 'heap-map', app);
|
||||||
|
|
||||||
HeapMapPage(app) : super(app);
|
|
||||||
|
|
||||||
void onInstall() {
|
|
||||||
if (element == null) {
|
|
||||||
element = new Element.tag('heap-map');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _visit(String url) {
|
void _visit(String url) {
|
||||||
assert(element != null);
|
super._visit(url);
|
||||||
assert(canVisit(url));
|
getIsolate().then((isolate) {
|
||||||
// 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) {
|
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
/// Update the page.
|
/// Update the page.
|
||||||
HeapMapElement page = element;
|
HeapMapElement page = element;
|
||||||
page.isolate = isolate;
|
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 {
|
class ErrorViewPage extends Page {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import 'package:polymer/polymer.dart';
|
||||||
/// elements.
|
/// elements.
|
||||||
@CustomTag('observatory-application')
|
@CustomTag('observatory-application')
|
||||||
class ObservatoryApplicationElement extends ObservatoryElement {
|
class ObservatoryApplicationElement extends ObservatoryElement {
|
||||||
@published bool devtools = false;
|
|
||||||
@reflectable ObservatoryApplication app;
|
@reflectable ObservatoryApplication app;
|
||||||
|
|
||||||
ObservatoryApplicationElement.created() : super.created();
|
ObservatoryApplicationElement.created() : super.created();
|
||||||
|
@ -21,10 +20,6 @@ class ObservatoryApplicationElement extends ObservatoryElement {
|
||||||
@override
|
@override
|
||||||
void attached() {
|
void attached() {
|
||||||
super.attached();
|
super.attached();
|
||||||
if (devtools) {
|
app = new ObservatoryApplication(this);
|
||||||
app = new ObservatoryApplication.devtools(this);
|
|
||||||
} else {
|
|
||||||
app = new ObservatoryApplication(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,6 @@
|
||||||
'lib/src/service/object.dart',
|
'lib/src/service/object.dart',
|
||||||
'lib/tracer.dart',
|
'lib/tracer.dart',
|
||||||
'web/index.html',
|
'web/index.html',
|
||||||
'web/index_devtools.html',
|
|
||||||
'web/main.dart',
|
'web/main.dart',
|
||||||
],
|
],
|
||||||
'actions': [
|
'actions': [
|
||||||
|
@ -187,8 +186,6 @@
|
||||||
'outputs': [
|
'outputs': [
|
||||||
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
||||||
'<(PRODUCT_DIR)/observatory/build/web/index.html_bootstrap.dart.js',
|
'<(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': [
|
'action': [
|
||||||
'python',
|
'python',
|
||||||
|
@ -207,14 +204,10 @@
|
||||||
'../../tools/observatory_tool.py',
|
'../../tools/observatory_tool.py',
|
||||||
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
'<(PRODUCT_DIR)/observatory/build/web/index.html',
|
||||||
'<(PRODUCT_DIR)/observatory/build/web/index.html_bootstrap.dart.js',
|
'<(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': [
|
'outputs': [
|
||||||
'<(PRODUCT_DIR)/observatory/deployed/web/index.html',
|
'<(PRODUCT_DIR)/observatory/deployed/web/index.html',
|
||||||
'<(PRODUCT_DIR)/observatory/deployed/web/index.html_bootstrap.dart.js',
|
'<(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': [
|
'action': [
|
||||||
'python',
|
'python',
|
||||||
|
|
|
@ -66,13 +66,13 @@ var tests = [
|
||||||
|
|
||||||
List tests = [];
|
List tests = [];
|
||||||
// Load code from frame 0.
|
// 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.type, equals('Code'));
|
||||||
expect(code.function.name, equals('funcB'));
|
expect(code.function.name, equals('funcB'));
|
||||||
expect(code.hasDisassembly, equals(true));
|
expect(code.hasDisassembly, equals(true));
|
||||||
}));
|
}));
|
||||||
// Load code from frame 0.
|
// 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.type, equals('Code'));
|
||||||
expect(code.function.name, equals('funcA'));
|
expect(code.function.name, equals('funcA'));
|
||||||
expect(code.hasDisassembly, equals(true));
|
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