feat: implement web-tracing-framework support

This includes implementation and minimal instrumentation

Closes #2610
This commit is contained in:
Misko Hevery
2015-06-14 16:42:26 -07:00
parent 6d272cc5f9
commit 77875a270d
17 changed files with 357 additions and 19 deletions

View File

@ -1,5 +1,7 @@
import {List, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {normalizeBlank, isPresent, global} from 'angular2/src/facade/lang';
import {wtfLeave, wtfCreateScope, WtfScopeFn} from '../../profile/profile';
export interface NgZoneZone extends Zone { _innerZone: boolean; }
@ -13,6 +15,9 @@ export interface NgZoneZone extends Zone { _innerZone: boolean; }
* `Zone`. The default `onTurnDone` runs the Angular change detection.
*/
export class NgZone {
_zone_run_scope: WtfScopeFn = wtfCreateScope(`NgZone#run()`);
_zone_microtask: WtfScopeFn = wtfCreateScope(`NgZone#microtask()`);
// Code executed in _mountZone does not trigger the onTurnDone.
_mountZone;
// _innerZone is the child of _mountZone. Any code executed in this zone will trigger the
@ -134,7 +139,12 @@ export class NgZone {
*/
run(fn: () => any): any {
if (this._disabled) {
return fn();
var s = this._zone_run_scope();
try {
return fn();
} finally {
wtfLeave(s);
}
} else {
return this._innerZone.run(fn);
}
@ -165,6 +175,7 @@ export class NgZone {
}
_createInnerZone(zone, enableLongStackTrace) {
var _zone_microtask = this._zone_microtask;
var ngZone = this;
var errorHandling;
@ -217,10 +228,12 @@ export class NgZone {
return function(fn) {
ngZone._pendingMicrotasks++;
var microtask = function() {
var s = _zone_microtask();
try {
fn();
} finally {
ngZone._pendingMicrotasks--;
wtfLeave(s);
}
};
parentScheduleMicrotask.call(this, microtask);