requestAnimationFrame = function requestAnimationFrame(cb) {
    // Hack to get the handle in the closure.
    var handleRef = [-1];

    // Flow-spanning logic.
    var flow; // NOTE: flow is branched below so event order is correct
    var handle = originalRequestAnimationFrame.call(goog.global, function() {
      var now = wtf.now();

      // If this is the first rAF of the frame, handle frame-start and list
      // swapping.
      if (!frameRafs.length) {
        frameNumber++;
        frameRafs.push.apply(frameRafs, pendingRafs);
        pendingRafs.length = 0;
        events.frameStart(frameNumber, now);
      }

      var scope = events.requestAnimationFrameCallback(handleRef[0], now);
      wtf.trace.extendFlow(flow, 'callback');
      try {
        cb.apply(this, arguments);
      } finally {
        delete rafFlows[handleRef[0]];
        wtf.trace.terminateFlow(flow);
        wtf.trace.leaveScope(scope);

        // If this is the last rAF of the frame, handle frame-end and list
        // resetting.
        if (frameRafs[frameRafs.length - 1] == handleRef[0]) {
          now = wtf.now();
          events.frameEnd(frameNumber, now);
          frameRafs.length = 0;
        }
      }
    });
    handleRef[0] = handle;

    // Queue in pending rAF list.
    pendingRafs.push(handle);

    // Append event (making it easy to identify requestAnimationFrames).
    events.requestAnimationFrame(handle);

    // Branch flow after the requestAnimationFrame so that the event order looks
    // right.
    flow = wtf.trace.branchFlow('window#requestAnimationFrame');
    rafFlows[handle] = flow;

    return handle;
  }
Injects requestAnimationFrame.
@param {string} requestName Name of the requestAnimationFrame method.
@param {string} cancelName Name of the cancelAnimationFrame method.
@param {!Object.<!wtf.trace.EventType>} events rAF events.
@private