Repository: servo/servo
File: components/servo/servo.rs (Rust)

Code before:
    target_env = "ohos",
))]
fn create_sandbox() {
    panic!("Sandboxing is not supported on Windows, iOS, ARM targets and android.");
}

struct DefaultEventLoopWaker;

impl EventLoopWaker for DefaultEventLoopWaker {
    fn clone_box(&self) -> Box<dyn EventLoopWaker> {
        Box::new(DefaultEventLoopWaker)
    }
}

#[cfg(feature = "webxr")]
struct DefaultWebXrRegistry;
#[cfg(feature = "webxr")]
impl webxr::WebXrRegistry for DefaultWebXrRegistry {}

pub struct ServoBuilder {
    opts: Option<Box<Opts>>,
    preferences: Option<Box<Preferences>>,
    event_loop_waker: Box<dyn EventLoopWaker>,
    protocol_registry: ProtocolRegistry,
    #[cfg(feature = "gamepad")]
    gamepad_provider: Option<Rc<dyn GamepadProvider>>,
    #[cfg(feature = "webxr")]
    webxr_registry: Box<dyn webxr::WebXrRegistry>,
}

impl Default for ServoBuilder {
    fn default() -> Self {
        Self {
            opts: Default::default(),
            preferences: Default::default(),
            event_loop_waker: Box::new(DefaultEventLoopWaker),
            protocol_registry: Default::default(),
            #[cfg(feature = "gamepad")]
            gamepad_provider: None,
            #[cfg(feature = "webxr")]
            webxr_registry: Box::new(DefaultWebXrRegistry),
        }
    }
}

impl ServoBuilder {
    pub fn build(self) -> Servo {
        Servo::new(self)
    }

    pub fn opts(mut self, opts: Opts) -> Self {

Review comment (suggestion):
Let's make this per-`WebView` by storing it there as there is no reason not to and that is how we handle the `ClipboardProvider`.

Code after:
                HangMonitorRegister::init(
                    new_event_loop_info.bhm_to_constellation_sender.clone(),
                    new_event_loop_info.constellation_to_bhm_receiver,
                    opts::get().background_hang_monitor,
                );

            let layout_factory = Arc::new(LayoutFactoryImpl());
            let script_join_handle = script::ScriptThread::create(
                new_event_loop_info.initial_script_state,
                layout_factory,
                Arc::new(ImageCacheFactoryImpl::new(
                    new_event_loop_info.broken_image_icon_data,
                )),
                background_hang_monitor_register,
            );

            script_join_handle
                .join()
                .expect("Failed to join on the script thread.");
            background_hang_monitor_join_handle
                .join()
                .expect("Failed to join on the BHM background thread.");

            StyleThreadPool::shutdown();

            // Shut down the fetch thread started above.
            exit_fetch_thread();
            fetch_thread_join_handle
                .join()
                .expect("Failed to join on the fetch thread in the constellation");
        },
        UnprivilegedContent::ServiceWorker(content) => {
            content.start::<ServiceWorkerManager>();
        },
    }
}

#[cfg(all(
    not(target_os = "windows"),
    not(target_os = "ios"),
    not(target_os = "android"),
    not(target_arch = "arm"),
    not(target_arch = "aarch64"),
    not(target_env = "ohos"),
))]
fn create_sandbox() {
    ChildSandbox::new(content_process_sandbox_profile())
        .activate()
        .expect("Failed to activate sandbox!");
}