• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2021 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// This file defines the API of messages exchanged between frontend and
16// {engine, controller} worker when bootstrapping the workers.
17// Those messages are sent only once. The rest of the communication happens
18// over the MessagePort(s) that are sent in the init message.
19
20// This is so we can create all the workers in a central place in the frontend
21// (Safari still doesn't spawning workers from other workers) but then let them
22// communicate by sending the right MessagePort to them.
23
24// Frontend -> Engine initialization message.
25export interface EngineWorkerInitMessage {
26  // The port used to receive engine messages (e.g., query commands).
27  // The controller owns the other end of the MessageChannel
28  // (see resetEngineWorker()).
29  enginePort: MessagePort;
30}
31
32// Frontend -> Controller initialization message.
33export interface ControllerWorkerInitMessage {
34  // For receiving dispatch() commands from the frontend. This is where most of
35  // the frontend <> controller interaction happens.
36  controllerPort: MessagePort;
37
38  // For controller <> Chrome extension communication.
39  extensionPort: MessagePort;
40
41  // For reporting errors back to the frontend. This is a dedicated port to
42  // reduce depdencies on the business logic behind the other ports.
43  errorReportingPort: MessagePort;
44}
45