src/wtf/trace/providers/xhrprovider.js
function XMLHttpRequest() {
    var scope = ctorEvent();
    goog.base(this, descriptor);

    /**
     * Real XHR.
     * @type {!XMLHttpRequest}
     * @private
     */
    this.handle_ = new originalXhr();

    /**
     * Event type trackers, by name.
     * @type {!Object.<Function>}
     * @private
     */
    this.trackers_ = {};

    /**
     * Properties, accumulated during setup before send().
     * @type {!Object}
     * @private
     */
    this.props_ = {
      'method': null,
      'url': null,
      'async': true,
      'user': null,
      'headers': {},
      'timeout': 0,
      'withCredentials': false,
      'overrideMimeType': null,
      'responseType': ''
    };

    /**
     * Active flow, if any.
     * @type {wtf.trace.Flow}
     * @private
     */
    this.flow_ = null;

    // Always hook onreadystatechange.
    // By doing it here we get first access to the event.
    var self = this;
    var handle = this.handle_;
    var props = this.props_;
    this.handle_.addEventListener('readystatechange', function(e) {
      var flow = self.flow_;
      if (!flow) {
        return;
      }

      var value = undefined;
      if (handle.readyState == 2) {
        var headers = {};
        var allHeaders = handle.getAllResponseHeaders().split('\r\n');
        for (var n = 0; n < allHeaders.length; n++) {
          if (allHeaders[n].length) {
            var parts = allHeaders[n].split(':');
            headers[parts[0]] = parts[1].substr(1);
          }
        }
        value = {
          'status': this.status,
          'statusText': this.statusText,
          'headers': headers
        };
        // TODO(benvanik): appendFlowData
      }
      // TODO(benvanik): response size/type/etc

      // Extend flow, terminate if required.
      if (handle.readyState < 4) {
        wtf.trace.Flow.extend(flow, 'readyState: ' + handle.readyState, value);
      } else {
        wtf.trace.Flow.terminate(flow, 'readyState: ' + handle.readyState);
      }
    }, false);

    // Add data to interesting events.
    this.setEventHook('readystatechange', function(e) {
      wtf.trace.appendScopeData('url', props['url']);
      wtf.trace.appendScopeData('readyState', handle['readyState']);
    });
    this.setEventHook('load', function(e) {
      wtf.trace.appendScopeData('url', props['url']);
    });

    wtf.trace.Scope.leave(scope);
  }
function XMLHttpRequest() {
    var scope = ctorEvent();
    goog.base(this, descriptor);

    /**
     * Real XHR.
     * @type {!XMLHttpRequest}
     * @private
     */
    this.handle_ = new originalXhr();

    /**
     * Event type trackers, by name.
     * @type {!Object.<Function>}
     * @private
     */
    this.trackers_ = {};

    /**
     * Properties, accumulated during setup before send().
     * @type {!Object}
     * @private
     */
    this.props_ = {
      'method': null,
      'url': null,
      'async': true,
      'user': null,
      'headers': {},
      'timeout': 0,
      'withCredentials': false,
      'overrideMimeType': null,
      'responseType': ''
    };

    /**
     * Active flow, if any.
     * @type {wtf.trace.Flow}
     * @private
     */
    this.flow_ = null;

    // Always hook onreadystatechange.
    // By doing it here we get first access to the event.
    var self = this;
    var handle = this.handle_;
    var props = this.props_;
    this.handle_.addEventListener('readystatechange', function(e) {
      var flow = self.flow_;
      if (!flow) {
        return;
      }

      var value = undefined;
      if (handle.readyState == 2) {
        var headers = {};
        var allHeaders = handle.getAllResponseHeaders().split('\r\n');
        for (var n = 0; n < allHeaders.length; n++) {
          if (allHeaders[n].length) {
            var parts = allHeaders[n].split(':');
            headers[parts[0]] = parts[1].substr(1);
          }
        }
        value = {
          'status': this.status,
          'statusText': this.statusText,
          'headers': headers
        };
        // TODO(benvanik): appendFlowData
      }
      // TODO(benvanik): response size/type/etc

      // Extend flow, terminate if required.
      if (handle.readyState < 4) {
        wtf.trace.Flow.extend(flow, 'readyState: ' + handle.readyState, value);
      } else {
        wtf.trace.Flow.terminate(flow, 'readyState: ' + handle.readyState);
      }
    }, false);

    // Add data to interesting events.
    this.setEventHook('readystatechange', function(e) {
      wtf.trace.appendScopeData('url', props['url']);
      wtf.trace.appendScopeData('readyState', handle['readyState']);
    });
    this.setEventHook('load', function(e) {
      wtf.trace.appendScopeData('url', props['url']);
    });

    wtf.trace.Scope.leave(scope);
  }
function XMLHttpRequest ( ) { var scope = ctorEvent ( ) ; goog . base ( this , descriptor ) ; /**
     * Real XHR.
     * @type {!XMLHttpRequest}
     * @private
     */ this . handle_ = new originalXhr ( ) ; /**
     * Event type trackers, by name.
     * @type {!Object.<Function>}
     * @private
     */ this . trackers_ = { } ; /**
     * Properties, accumulated during setup before send().
     * @type {!Object}
     * @private
     */ this . props_ = { 'method' : null , 'url' : null , 'async' : true , 'user' : null , 'headers' : { } , 'timeout' : 0 , 'withCredentials' : false , 'overrideMimeType' : null , 'responseType' : '' } ; /**
     * Active flow, if any.
     * @type {wtf.trace.Flow}
     * @private
     */ this . flow_ = null ; // Always hook onreadystatechange. // By doing it here we get first access to the event. var self = this ; var handle = this . handle_ ; var props = this . props_ ; this . handle_ . addEventListener ( 'readystatechange' , function ( e ) { var flow = self . flow_ ; if ( ! flow ) { return ; } var value = undefined ; if ( handle . readyState == 2 ) { var headers = { } ; var allHeaders = handle . getAllResponseHeaders ( ) . split ( '\r\n' ) ; for ( var n = 0 ; n < allHeaders . length ; n ++ ) { if ( allHeaders [ n ] . length ) { var parts = allHeaders [ n ] . split ( ':' ) ; headers [ parts [ 0 ] ] = parts [ 1 ] . substr ( 1 ) ; } } value = { 'status' : this . status , 'statusText' : this . statusText , 'headers' : headers } ; // TODO(benvanik): appendFlowData } // TODO(benvanik): response size/type/etc // Extend flow, terminate if required. if ( handle . readyState < 4 ) { wtf . trace . Flow . extend ( flow , 'readyState: ' + handle . readyState , value ) ; } else { wtf . trace . Flow . terminate ( flow , 'readyState: ' + handle . readyState ) ; } } , false ) ; // Add data to interesting events. this . setEventHook ( 'readystatechange' , function ( e ) { wtf . trace . appendScopeData ( 'url' , props [ 'url' ] ) ; wtf . trace . appendScopeData ( 'readyState' , handle [ 'readyState' ] ) ; } ) ; this . setEventHook ( 'load' , function ( e ) { wtf . trace . appendScopeData ( 'url' , props [ 'url' ] ) ; } ) ; wtf . trace . Scope . leave ( scope ) ; }
Proxy XHR.
@constructor
@extends {wtf.trace.eventtarget.BaseEventTarget}
Proxy XHR .