public void deliver() {
    String url = Configuration.getEndpointUrl();
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);

    List<PerformanceTiming> timings = deliveryQueue.popTimings();
    List<IncidentReport> incidents = deliveryQueue.popIncidents();

    ResultInjector injector = new RequestBodyInjector();
    HeaderInjector.Result result = injector.inject(builder, timings, incidents);

    if (result.shouldSend()) {
      MeasurementRequestCallback callback = new MeasurementRequestCallback(timings, incidents);
      builder.setCallback(callback);
      try {
        builder.send();
      } catch (RequestException e) {
        deliveryQueue.pushTiming(timings);
        deliveryQueue.pushIncident(incidents);
        // TODO Consider lost piggybacked timings as well
      }
    }
  }
    public void onError(Request request, Throwable exception) {
      DeliveryQueue deliveryQueue = DeliveryQueue.instance();

      deliveryQueue.pushTiming(timings);
      deliveryQueue.pushIncident(incidents);
    }