Android: proper shutdown mechanism

This commit is contained in:
Paul Rouget 2018-10-26 09:38:10 +02:00
parent b19f9d9c5b
commit 549c8c565a
7 changed files with 145 additions and 17 deletions

View file

@ -35,6 +35,7 @@ pub struct CHostCallbacks {
pub on_url_changed: extern fn(url: *const c_char),
pub on_history_changed: extern fn(can_go_back: bool, can_go_forward: bool),
pub on_animating_changed: extern fn(animating: bool),
pub on_shutdown_complete: extern fn(),
}
/// Servo options
@ -108,6 +109,18 @@ pub extern "C" fn init_with_gl(
init(opts, gl, wakeup, readfile, callbacks)
}
#[no_mangle]
pub extern "C" fn deinit() {
debug!("deinit");
api::deinit();
}
#[no_mangle]
pub extern "C" fn request_shutdown() {
debug!("request_shutdown");
call(|s| s.request_shutdown());
}
#[no_mangle]
pub extern "C" fn set_batch_mode(batch: bool) {
debug!("set_batch_mode");
@ -296,4 +309,9 @@ impl HostTrait for HostCallbacks {
debug!("on_animating_changed");
(self.0.on_animating_changed)(animating);
}
fn on_shutdown_complete(&self) {
debug!("on_shutdown_complete");
(self.0.on_shutdown_complete)();
}
}