blob: a90db3a5d4c9d533b57f42a113efdc1211ef3dc2 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "mojo/public/mojom/base/time.mojom";
import "third_party/blink/public/mojom/blob/blob.mojom";
import "third_party/blink/public/mojom/fetch/fetch_api_response.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_stream_handle.mojom";
// This struct contains timing information recorded in the context of a
// controller service worker.
struct ServiceWorkerFetchEventTiming {
// Recorded just before a fetch event is dispatched.
mojo_base.mojom.TimeTicks dispatch_event_time;
// Recorded when respondWith()'s promise is settled, or the fetch event
// dispatch finished without respondWith() being called.
mojo_base.mojom.TimeTicks respond_with_settled_time;
};
// Callback interface which is passed to a controller service worker through
// DispatchFetchEvent (either via ServiceWorker or via ControllerServiceWorker
// interface).
// The receiver service worker uses this interface to respond to a fetch event.
interface ServiceWorkerFetchResponseCallback {
// Responds to the request with |response|.
OnResponse(FetchAPIResponse response,
ServiceWorkerFetchEventTiming timing);
// Responds to the request with |response|. |response.blob| should be empty
// since the body is provided as a stream.
OnResponseStream(FetchAPIResponse response,
ServiceWorkerStreamHandle body_as_stream,
ServiceWorkerFetchEventTiming timing);
// Provides no response to the request. The callee should fall back to the
// network.
OnFallback(ServiceWorkerFetchEventTiming timing);
};