summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/public/mojom/worker/dedicated_worker_host_factory.mojom
blob: 831bfa8ec5932a80c8b18620c0b0b0d65f71b2ea (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
// 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/fetch_api.mojom";
import "third_party/blink/public/mojom/blob/blob_url_store.mojom";
import "third_party/blink/public/mojom/browser_interface_broker.mojom";
import "third_party/blink/public/mojom/loader/fetch_client_settings_object.mojom";
import "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom";
import "third_party/blink/public/mojom/loader/url_loader_factory_bundle.mojom";
import "third_party/blink/public/mojom/worker/dedicated_worker_host.mojom";
import "third_party/blink/public/mojom/worker/worker_main_script_load_params.mojom";
import "third_party/blink/public/mojom/service_worker/controller_service_worker.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom";
import "url/mojom/url.mojom";

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

// PlzDedicatedWorker:
// An interface implemented by clients (e.g., the renderer where "new Worker()"
// was invoked) to observe events on the DedicatedWorkerHostFactory.
interface DedicatedWorkerHostFactoryClient {
  // Called when the worker host is created.
  OnWorkerHostCreated(
      // Used for accessing services from the worker.
      pending_remote<blink.mojom.BrowserInterfaceBroker>
          browser_interface_broker);

  // Called when the worker host started loading the main worker script. This
  // is called after OnWorkerHostCreated(). This is never called when
  // OnScriptLoadStartFailed() is called.
  OnScriptLoadStarted(
      // The info about the service worker provider in the browser process that
      // provides support for this worker to be a service worker client.
      //
      // This is null if the dedicated worker cannot be a service
      // worker client, because for example, the worker's URL is
      // not http(s) or another service worker supported scheme.
      ServiceWorkerProviderInfoForClient? service_worker_provider_info,

      // Used for passing the main script pre-requested by the browser process
      // and its redirect information.
      WorkerMainScriptLoadParams main_script_load_params,

      // Used for loading subresources. This also supports non-network URLs like
      // chrome-extension:// URLs.
      URLLoaderFactoryBundle subresource_loader_factories,

      // Used for updating subresource loaders after NetworkService crash.
      pending_receiver<SubresourceLoaderUpdater> subresource_loader_updater,

      // Used to make fetches from the worker go through the controller service
      // worker. This is null when there're no controller service worker.
      ControllerServiceWorkerInfo? controller_info);

  // Called when the worker host fails to start loading the main worker script.
  // This is called after OnWorkerHostCreated(). This is never called when
  // OnScriptLoadStarted() is called.
  OnScriptLoadStartFailed();
};

// An interface used to instantiate a dedicated worker host. The implementation
// of this interface lives in the browser process.
interface DedicatedWorkerHostFactory {
  // Non-PlzDedicatedWorker:
  // The factory client should call this instead of
  // CreateWorkerHostAndStartScriptLoad() when PlzDedicatedWorker is disabled.
  //
  // Creates a new DedicatedWorkerHost, and requests |browser_interface_broker|
  // to provide the worker access to mojo interfaces.
  CreateWorkerHost(
      pending_receiver<blink.mojom.BrowserInterfaceBroker>
          browser_interface_broker,
      pending_receiver<DedicatedWorkerHost> host);

  // PlzDedicatedWorker:
  // The factory client should call this instead of CreateWorkerHost() when
  // PlzDedicatedWorker is enabled.
  //
  // Creates a new DedicatedWorkerHost, and requests to start top-level worker
  // script loading for |script_url| using |credentials_mode| and
  // |outside_fetch_client_settings_object|.
  // |blob_url_token| should be non-null when |script_url| is a blob URL.
  // |client| is used for notifying the renderer process of results of worker
  // host creation and script loading.
  CreateWorkerHostAndStartScriptLoad(
      url.mojom.Url script_url,
      network.mojom.CredentialsMode credentials_mode,
      blink.mojom.FetchClientSettingsObject
          outside_fetch_client_settings_object,
      pending_remote<blink.mojom.BlobURLToken>? blob_url_token,
      pending_remote<DedicatedWorkerHostFactoryClient> client,
      pending_receiver<DedicatedWorkerHost> host);
};