|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 Sony Interactive Entertainment Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions |
| 7 | + * are met: |
| 8 | + * 1. Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer in the |
| 12 | + * documentation and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 17 | + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 | + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | + |
| 27 | +#if !defined(__WPE_H_INSIDE__) && !defined(WPE_COMPILATION) |
| 28 | +#error "Only <wpe/wpe.h> can be included directly." |
| 29 | +#endif |
| 30 | + |
| 31 | +#ifndef wpe_process_h |
| 32 | +#define wpe_process_h |
| 33 | + |
| 34 | +/** |
| 35 | + * SECTION:process |
| 36 | + * @short_description: Process management |
| 37 | + * @title: Process |
| 38 | + */ |
| 39 | + |
| 40 | +#if defined(WPE_COMPILATION) |
| 41 | +#include "export.h" |
| 42 | +#endif |
| 43 | + |
| 44 | +#include <stdint.h> |
| 45 | + |
| 46 | +#ifdef __cplusplus |
| 47 | +extern "C" { |
| 48 | +#endif |
| 49 | + |
| 50 | +/** |
| 51 | + * wpe_process_type: |
| 52 | + * @WPE_PROCESS_TYPE_WEB: WebKit's WebProcess. |
| 53 | + * @WPE_PROCESS_TYPE_NETWORK: WebKit's NetworkProcess. |
| 54 | + * @WPE_PROCESS_TYPE_GPU: WebKit's GPUProcess. |
| 55 | + * @WPE_PROCESS_TYPE_WEB_AUTHN: WebKit's WebAuthNProcess. |
| 56 | + * |
| 57 | + * Maps to the processes launched by WebKit. |
| 58 | + */ |
| 59 | +enum wpe_process_type { |
| 60 | + WPE_PROCESS_TYPE_WEB, |
| 61 | + WPE_PROCESS_TYPE_NETWORK, |
| 62 | + WPE_PROCESS_TYPE_GPU, |
| 63 | + WPE_PROCESS_TYPE_WEB_AUTHN, |
| 64 | +}; |
| 65 | + |
| 66 | +struct wpe_process_provider; |
| 67 | + |
| 68 | +/** |
| 69 | + * wpe_process_provider_interface: |
| 70 | + * @create: create an internal representation of a process provider. |
| 71 | + * @destroy: destroy instance process provider. |
| 72 | + * @launch: launches the specified WebKit process. |
| 73 | + * @terminate: terminates the specified Webkit process. |
| 74 | + * |
| 75 | + * Methods called by WebKit requesting process provider operations to implementator. |
| 76 | + * |
| 77 | + * Since: 1.14 |
| 78 | + */ |
| 79 | +struct wpe_process_provider_interface { |
| 80 | + void* (*create)(struct wpe_process_provider*); |
| 81 | + void (*destroy)(void*); |
| 82 | + int64_t (*launch)(void*, enum wpe_process_type, void*); |
| 83 | + void (*terminate)(void*, int64_t); |
| 84 | + |
| 85 | + /*< private >*/ |
| 86 | + void (*_wpe_reserved1)(void); |
| 87 | + void (*_wpe_reserved2)(void); |
| 88 | + void (*_wpe_reserved3)(void); |
| 89 | + void (*_wpe_reserved4)(void); |
| 90 | + void (*_wpe_reserved5)(void); |
| 91 | +}; |
| 92 | + |
| 93 | +/** |
| 94 | + * wpe_process_provider_create: |
| 95 | + * |
| 96 | + * This method is called by WPEWebKit. |
| 97 | + * |
| 98 | + * Returns: an opaque object representing the process provider in libwpe. |
| 99 | + * |
| 100 | + * Since: 1.14 |
| 101 | + */ |
| 102 | +WPE_EXPORT |
| 103 | +struct wpe_process_provider* wpe_process_provider_create(void); |
| 104 | + |
| 105 | +/** |
| 106 | + * wpe_process_provider_destroy: |
| 107 | + * @provider: opaque libwpe's representation of the process provider. |
| 108 | + * |
| 109 | + * Frees the internal resources used by @provider. |
| 110 | + * |
| 111 | + * This method is called by WPEWebKit. |
| 112 | + * |
| 113 | + * Since: 1.14 |
| 114 | + */ |
| 115 | +WPE_EXPORT |
| 116 | +void wpe_process_provider_destroy(struct wpe_process_provider*); |
| 117 | + |
| 118 | +/** |
| 119 | + * wpe_process_launch: |
| 120 | + * @provider: opaque libwpe's representation of the process provider. |
| 121 | + * @type: the process type to launch. |
| 122 | + * @userdata: user data passed needed to launch the process. |
| 123 | + * |
| 124 | + * Launches the specified WebKit process. |
| 125 | + * |
| 126 | + * Returns: an identifier for the process. |
| 127 | + * |
| 128 | + * Since: 1.14 |
| 129 | + */ |
| 130 | +WPE_EXPORT |
| 131 | +int64_t wpe_process_launch(struct wpe_process_provider*, enum wpe_process_type, void*); |
| 132 | + |
| 133 | +/** |
| 134 | + * wpe_process_terminate: |
| 135 | + * @provider: opaque libwpe's representation of the process provider. |
| 136 | + * @process: identifier for the process to terminate. |
| 137 | + * |
| 138 | + * Terminates the specified WebKit process. |
| 139 | + * |
| 140 | + * Since: 1.14 |
| 141 | + */ |
| 142 | +WPE_EXPORT |
| 143 | +void wpe_process_terminate(struct wpe_process_provider*, int64_t); |
| 144 | + |
| 145 | +/** |
| 146 | + * wpe_process_provider_register_interface: |
| 147 | + * @iface: interface for the process provider. |
| 148 | + * |
| 149 | + * Sets the process provider interface. |
| 150 | + * |
| 151 | + * This method is called by WPEWebKit. |
| 152 | + * |
| 153 | + * Since: 1.14 |
| 154 | + */ |
| 155 | +WPE_EXPORT |
| 156 | +void wpe_process_provider_register_interface(const struct wpe_process_provider_interface*); |
| 157 | + |
| 158 | +#ifdef __cplusplus |
| 159 | +} |
| 160 | +#endif |
| 161 | + |
| 162 | +#endif /* wpe_process_h */ |
0 commit comments