| // 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 content.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"; |
| |
| // 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|. The body is empty. |
| OnResponse(blink.mojom.FetchAPIResponse response, |
| mojo_base.mojom.Time dispatch_event_time); |
| // Responds to the request with |response|. The body is returned as a blob. |
| // TODO(leonhsl): We can remove this method by using the above OnResponse() |
| // transferring blob within |response|. |
| OnResponseBlob(blink.mojom.FetchAPIResponse response, |
| blink.mojom.Blob body_as_blob, |
| mojo_base.mojom.Time dispatch_event_time); |
| // Responds to the request with |response|. The body is returned as a stream. |
| OnResponseStream(blink.mojom.FetchAPIResponse response, |
| blink.mojom.ServiceWorkerStreamHandle body_as_stream, |
| mojo_base.mojom.Time dispatch_event_time); |
| // Provides no response to the request. The callee should fall back to the |
| // network. |
| OnFallback(mojo_base.mojom.Time dispatch_event_time); |
| }; |