mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
Add support for launching devtools server on random port
Assign random port to devtools server in case user does not specify a port explicitly and report it to the embedding layer for display to user.
This commit is contained in:
parent
6ab923c8e8
commit
94db0d61cb
10 changed files with 73 additions and 9 deletions
|
@ -515,6 +515,12 @@ where
|
|||
debug!("MediaSessionEvent received");
|
||||
// TODO(ferjm): MediaSession support for Glutin based browsers.
|
||||
},
|
||||
EmbedderMsg::OnDevtoolsStarted(port) => {
|
||||
match port {
|
||||
Ok(p) => info!("Devtools Server running on port {}", p),
|
||||
Err(()) => error!("Error running devtools server"),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,6 +423,13 @@ impl HostTrait for HostCallbacks {
|
|||
}
|
||||
|
||||
fn set_clipboard_contents(&self, _contents: String) {}
|
||||
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>) {
|
||||
match port {
|
||||
Ok(p) => info!("Devtools Server running on port {}", p),
|
||||
Err(()) => error!("Error running Devtools server"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ServoInstance {
|
||||
|
|
|
@ -146,6 +146,8 @@ pub trait HostTrait {
|
|||
fn on_media_session_playback_state_change(&self, state: MediaSessionPlaybackState);
|
||||
/// Called when the media session position state is set.
|
||||
fn on_media_session_set_position_state(&self, duration: f64, position: f64, playback_rate: f64);
|
||||
/// Called when devtools server is started
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>);
|
||||
}
|
||||
|
||||
pub struct ServoGlue {
|
||||
|
@ -670,6 +672,9 @@ impl ServoGlue {
|
|||
),
|
||||
};
|
||||
},
|
||||
EmbedderMsg::OnDevtoolsStarted(port) => {
|
||||
self.callbacks.host_callbacks.on_devtools_started(port);
|
||||
},
|
||||
EmbedderMsg::Status(..) |
|
||||
EmbedderMsg::SelectFiles(..) |
|
||||
EmbedderMsg::MoveTo(..) |
|
||||
|
|
|
@ -23,7 +23,7 @@ use simpleservo::{
|
|||
use std::ffi::{CStr, CString};
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::mem;
|
||||
use std::os::raw::{c_char, c_void};
|
||||
use std::os::raw::{c_char, c_uint, c_void};
|
||||
use std::panic::{self, UnwindSafe};
|
||||
use std::slice;
|
||||
use std::str::FromStr;
|
||||
|
@ -229,6 +229,7 @@ pub struct CHostCallbacks {
|
|||
default: *const c_char,
|
||||
trusted: bool,
|
||||
) -> *const c_char,
|
||||
pub on_devtools_started: extern "C" fn(result: CDevtoolsServerState, port: c_uint),
|
||||
}
|
||||
|
||||
/// Servo options
|
||||
|
@ -286,6 +287,12 @@ pub enum CMediaSessionPlaybackState {
|
|||
Paused,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum CDevtoolsServerState {
|
||||
Started,
|
||||
Error,
|
||||
}
|
||||
|
||||
impl From<MediaSessionPlaybackState> for CMediaSessionPlaybackState {
|
||||
fn from(state: MediaSessionPlaybackState) -> Self {
|
||||
match state {
|
||||
|
@ -854,4 +861,17 @@ impl HostTrait for HostCallbacks {
|
|||
let contents_str = c_str.to_str().expect("Can't create str");
|
||||
Some(contents_str.to_owned())
|
||||
}
|
||||
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>) {
|
||||
match port {
|
||||
Ok(p) => {
|
||||
info!("Devtools Server running on port {}", p);
|
||||
(self.0.on_devtools_started)(CDevtoolsServerState::Started, p.into());
|
||||
},
|
||||
Err(()) => {
|
||||
error!("Error running devtools server");
|
||||
(self.0.on_devtools_started)(CDevtoolsServerState::Error, 0);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -603,6 +603,13 @@ impl HostTrait for HostCallbacks {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>) {
|
||||
match port {
|
||||
Ok(p) => info!("Devtools Server running on port {}", p),
|
||||
Err(()) => error!("Error running devtools server"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn initialize_android_glue(env: &JNIEnv, activity: JObject) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue