This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn fourth() { | |
enum WorkMsg { | |
Work(u8), | |
Exit, | |
} | |
#[derive(Debug, Eq, PartialEq)] | |
enum WorkPerformed { | |
FromCache, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn third() { | |
enum WorkMsg { | |
Work(u8), | |
Exit, | |
} | |
enum ResultMsg { | |
Result(u8), | |
Exited, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn second() { | |
enum WorkMsg { | |
Work(u8), | |
Exit, | |
} | |
enum ResultMsg { | |
Result(u8), | |
Exited, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn first() { | |
/// The messages sent from the "main" component, | |
/// to the other component running in parallel. | |
enum WorkMsg { | |
Work(u8), | |
Exit, | |
} | |
/// The messages sent from the "parallel" component, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Content process entry point. | |
pub fn run_content_process(token: String) { | |
// Same stuff as before here... | |
let unprivileged_content = unprivileged_content_receiver.recv().unwrap(); | |
match unprivileged_content { | |
UnprivilegedContent::Pipeline(mut content) => { | |
content.start_all(); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Constellation { | |
/// A map of origin to sender to a Service worker manager. | |
sw_managers: HashMap<ImmutableOrigin, IpcSender<ServiceWorkerMsg>>, | |
} | |
impl Constellation { | |
fn handle_register_serviceworker(&mut self, scope_things: ScopeThings, scope: ServoUrl) { | |
let origin = scope.origin(); | |
if let Some(mgr) = self.sw_managers.get(&origin) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Content process entry point, contains init of service worker manager. | |
pub fn run_content_process(token: String) { | |
// Same stuff as before here... | |
// send the required channels to the service worker manager | |
let sw_senders = unprivileged_content.swmanager_senders(); | |
script::init_service_workers(sw_senders); | |
unprivileged_content.start_all(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Content process entry point. | |
pub fn run_content_process(token: String) { | |
let (unprivileged_content_sender, unprivileged_content_receiver) = | |
ipc::channel::<UnprivilegedContent>().unwrap(); | |
let connection_bootstrap: IpcSender<IpcSender<UnprivilegedContent>> = | |
IpcSender::connect(token).unwrap(); | |
connection_bootstrap | |
.send(unprivileged_content_sender) | |
.unwrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(any( | |
target_os = "android", | |
target_arch = "arm", | |
all(target_arch = "aarch64", not(target_os = "windows")) | |
))] | |
pub fn spawn_multiprocess(content: UnprivilegedContent) -> Result<(), Error> { | |
use ipc_channel::ipc::{IpcOneShotServer, IpcSender}; | |
// Note that this function can panic, due to process creation, | |
// avoiding this panic would require a mechanism for dealing | |
// with low-resource scenarios. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (script_chan, script_port) = ipc::channel().expect("Pipeline script chan"); | |
let mut unprivileged_pipeline_content = UnprivilegedPipelineContent { | |
script_port, | |
// bunch of other stuff needed to start the event-loop... | |
}; | |
// Spawn the child process. | |
// | |
// Yes, that's all there is to it! |