summaryrefslogtreecommitdiff
path: root/chromium/content/common/service_worker/service_worker_fetch_response_callback.mojom
blob: 105b2639cacbb8304a7e90e54544a59fe7c46c97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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/service_worker/service_worker_stream_handle.mojom";

[Native]
struct ServiceWorkerResponse;

// Callback interface which is passed to a controller service worker through
// DispatchFetchEvent (either via ServiceWorkerEventDispatcher 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(ServiceWorkerResponse response,
             mojo_base.mojom.Time dispatch_event_time);
  // Responds to the request with |response|. The body is returned as a blob.
  // TODO(kinuko): This should not be necessary once we properly support
  // transferring blob within |response|. See crbug.com/75523 for more details.
  OnResponseBlob(ServiceWorkerResponse response,
                 blink.mojom.Blob body_as_blob,
                 mojo_base.mojom.Time dispatch_event_time);
   // Responds to the request with |response|. The body is provided as a
   // non-Mojo Blob via |response.blob_uuid|. The callback is useful for Blob
   // lifetime management purposes and is called once the caller is done with
   // the Blob. TODO(kinuko): Remove this once MojoBlob is fully shipped.
  OnResponseLegacyBlob(ServiceWorkerResponse response,
                       mojo_base.mojom.Time dispatch_event_time) => ();
  // Responds to the request with |response|. The body is returned as a stream.
  OnResponseStream(ServiceWorkerResponse 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);
};