summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/public/mojom/service_worker/service_worker_provider.mojom
blob: 63d23fd87ec1c75021cc1fd6e67d586264bea1ce (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// 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 "services/network/public/mojom/url_loader_factory.mojom";
import "services/service_manager/public/mojom/interface_provider.mojom";
import "third_party/blink/public/mojom/cache_storage/cache_storage.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_container.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_object.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_provider_type.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom";

// The name of the InterfaceProviderSpec in service manifests used by the
// frame tree to expose service-worker-specific interfaces between renderer
// and browser.
const string kNavigation_ServiceWorkerSpec = "navigation:service_worker";

// S13nServiceWorker:
// Sent from the browser process to the renderer. Contains parameters for the
// WebServiceWorkerNetworkProvider used for starting a web worker (dedicated
// worker or shared worker).
struct ServiceWorkerProviderInfoForWorker {
  int32 provider_id;
  associated ServiceWorkerContainerHost host_ptr_info;
  associated ServiceWorkerContainer& client_request;
};

// Sent from the browser process to the renderer. Contains parameters for the
// WebServiceWorkerNetworkProvider used for starting a service worker.
struct ServiceWorkerProviderInfoForStartWorker {
  int32 provider_id;

  associated ServiceWorkerContainerHost host_ptr_info;
  associated ServiceWorkerContainer& client_request;

  // S13nServiceWorker:
  // The loader to use for loading the worker's main script and
  // importScripts().
  associated network.mojom.URLLoaderFactory? script_loader_factory_ptr_info;

  // |cache_storage| is an optional optimization so the service worker can use
  // the Cache Storage API immediately without using InterfaceProvider. May be
  // null for service workers created for update checks, as the optimization
  // would be wasteful because these workers usually are aborted after the
  // byte-to-byte update check before running.
  CacheStorage? cache_storage;

  service_manager.mojom.InterfaceProvider interface_provider;
};

// Describes a browser-side provider host. See
// content::ServiceWorkerProviderHost.
struct ServiceWorkerProviderHostInfo {
  // |provider_id| may be browser-assigned or renderer-assigned.
  // Browser-assigned ids are unique among all providers. Renderer-assigned ids
  // are unique among providers in a given renderer process. Most providers have
  // browser-assigned ids. The exceptions are about:blank iframes, and shared
  // workers (in the non-S13nServiceWorker case).
  int32 provider_id;

  // When this provider is created for a document, |route_id| is the frame ID of
  // it. Otherwise |route_id| is MSG_ROUTING_NONE.
  int32 route_id;

  // This identifies whether this provider is for a service worker or for a
  // service worker client (Documents and Shared Workers).
  ServiceWorkerProviderType type;

  // |is_parent_frame_secure| is false if the provider is created for a document
  // whose parent frame is not secure from the point of view of the document;
  // that is, blink::WebFrame::canHaveSecureChild() returns false. This doesn't
  // mean the document is necessarily an insecure context, because the document
  // may have a URL whose scheme is granted an exception that allows bypassing
  // the ancestor secure context check. See the comment in
  // blink::Document::isSecureContextImpl for more details. If the provider is
  // not created for a document, or the document does not have a parent frame,
  // is_parent_frame_secure| is true.
  bool is_parent_frame_secure;

  // Mojo endpoint to send a message from the renderer to the browser. This
  // will be associated with ServiceWorkerDisptacherHost. |host_request| should
  // be valid when ServiceWorkerProviderHostInfo is passed to any Mojo method.
  // After used to create the ServiceWorkerProviderHost, this will be invalid.
  associated ServiceWorkerContainerHost& host_request;

  // Mojo endpoint to send a message from the browser to the renderer. This
  // will be associated with ServiceWorkerDispatcherHost. |client_ptr_info|
  // should be valid when ServiceWorkerProviderHostInfo is passed to any Mojo
  // method.
  // After used to create the ServiceWorkerProviderHost, this will be invalid.
  associated ServiceWorkerContainer client_ptr_info;
};

// ServiceWorkerWorkerClient represents a service worker client that is a worker
// (i.e., a shared worker or dedicated worker). The main thread of
// the renderer process uses this interface to tell the worker thread
// when the controller service worker changes.
interface ServiceWorkerWorkerClient {
  // Called when the worker is controlled by a new service worker. This is only
  // used to let the worker know that we now have a service worker (while there
  // may or may not have been one previously), but not the other way around.
  OnControllerChanged(ControllerServiceWorkerMode mode);
};

// ServiceWorkerWorkerClientRegistry is a mojo interface for hosting and
// registering ServiceWorkerWorkerClients. An instance of this interface is
// implemented by ServiceWorkerProviderContext and lives in the same renderer
// process as the worker clients.
// This interface is useful when one needs to register a new worker client
// for an existing ServiceWorkerProviderContext on non-main thread, i.e. for
// nested workers.
interface ServiceWorkerWorkerClientRegistry {
  // Adds a new ServiceWorkerWorkerClient.
  RegisterWorkerClient(ServiceWorkerWorkerClient client);

  // Clones this host.
  CloneWorkerClientRegistry(ServiceWorkerWorkerClientRegistry& host);
};

// An interface implemented by the browser process, with one implementation per
// renderer process. The renderer uses this interface to tell the browser when
// potential service worker clients are created.
//
// This interface is on the channel-associated interface to the renderer
// process.
interface ServiceWorkerDispatcherHost {
  // Creates a content::ServiceWorkerProviderHost on the browser
  // process. |provider_info| has Mojo endpoints to connect the container host
  // and the container on the renderer together. The lifetime of
  // ServiceWorkerProviderHost will be tied to the
  // blink::mojom::ServiceWorkerContainerHost interface.
  OnProviderCreated(ServiceWorkerProviderHostInfo provider_info);
};