mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
DevTools: Display console messages and errors (#32727)
* feat: add streams to browsing context * feat: console now works! * feat: order console messages * feat: add streams to new browsing contexts * fix: apply suggestions Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
34d9be70f9
commit
33f3c34d28
6 changed files with 141 additions and 119 deletions
|
@ -191,13 +191,11 @@ fn run_server(
|
|||
|
||||
let actors = registry.create_shareable();
|
||||
|
||||
let mut accepted_connections: Vec<TcpStream> = Vec::new();
|
||||
|
||||
let mut browsing_contexts: HashMap<BrowsingContextId, String> = HashMap::new();
|
||||
let mut pipelines: HashMap<PipelineId, BrowsingContextId> = HashMap::new();
|
||||
let mut actor_requests: HashMap<String, String> = HashMap::new();
|
||||
|
||||
let mut actor_workers: HashMap<WorkerId, String> = HashMap::new();
|
||||
let mut accepted_connections = HashMap::new();
|
||||
let mut browsing_contexts: HashMap<_, String> = HashMap::new();
|
||||
let mut pipelines = HashMap::new();
|
||||
let mut actor_requests = HashMap::new();
|
||||
let mut actor_workers = HashMap::new();
|
||||
|
||||
/// Process the input from a single devtools client until EOF.
|
||||
fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream, id: StreamId) {
|
||||
|
@ -289,6 +287,7 @@ fn run_server(
|
|||
pipelines: &mut HashMap<PipelineId, BrowsingContextId>,
|
||||
actor_workers: &mut HashMap<WorkerId, String>,
|
||||
page_info: DevtoolsPageInfo,
|
||||
connections: &HashMap<StreamId, TcpStream>,
|
||||
) {
|
||||
let mut actors = actors.lock().unwrap();
|
||||
|
||||
|
@ -324,10 +323,9 @@ fn run_server(
|
|||
Root::DedicatedWorker(worker_name)
|
||||
} else {
|
||||
pipelines.insert(pipeline, browsing_context);
|
||||
Root::BrowsingContext(
|
||||
if let Some(actor) = browsing_contexts.get(&browsing_context) {
|
||||
actor.to_owned()
|
||||
} else {
|
||||
let name = browsing_contexts
|
||||
.entry(browsing_context)
|
||||
.or_insert_with(|| {
|
||||
let browsing_context_actor = BrowsingContextActor::new(
|
||||
console_name.clone(),
|
||||
browsing_context,
|
||||
|
@ -337,11 +335,18 @@ fn run_server(
|
|||
&mut actors,
|
||||
);
|
||||
let name = browsing_context_actor.name();
|
||||
browsing_contexts.insert(browsing_context, name.clone());
|
||||
actors.register(Box::new(browsing_context_actor));
|
||||
name
|
||||
},
|
||||
)
|
||||
});
|
||||
|
||||
// Add existing streams to the new browsing context
|
||||
let browsing_context = actors.find::<BrowsingContextActor>(&name);
|
||||
let mut streams = browsing_context.streams.borrow_mut();
|
||||
for (id, stream) in connections {
|
||||
streams.insert(*id, stream.try_clone().unwrap());
|
||||
}
|
||||
|
||||
Root::BrowsingContext(name.clone())
|
||||
};
|
||||
|
||||
let console = ConsoleActor {
|
||||
|
@ -609,7 +614,15 @@ fn run_server(
|
|||
let actors = actors.clone();
|
||||
let id = next_id;
|
||||
next_id = StreamId(id.0 + 1);
|
||||
accepted_connections.push(stream.try_clone().unwrap());
|
||||
accepted_connections.insert(id, stream.try_clone().unwrap());
|
||||
|
||||
// Inform every browsing context of the new stream
|
||||
for name in browsing_contexts.values() {
|
||||
let actors = actors.lock().unwrap();
|
||||
let browsing_context = actors.find::<BrowsingContextActor>(name);
|
||||
let mut streams = browsing_context.streams.borrow_mut();
|
||||
streams.insert(id, stream.try_clone().unwrap());
|
||||
}
|
||||
thread::Builder::new()
|
||||
.name("DevtoolsClientHandler".to_owned())
|
||||
.spawn(move || handle_client(actors, stream.try_clone().unwrap(), id))
|
||||
|
@ -641,6 +654,7 @@ fn run_server(
|
|||
&mut pipelines,
|
||||
&mut actor_workers,
|
||||
pageinfo,
|
||||
&accepted_connections,
|
||||
),
|
||||
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::Navigate(
|
||||
browsing_context,
|
||||
|
@ -698,7 +712,7 @@ fn run_server(
|
|||
)) => {
|
||||
// copy the accepted_connections vector
|
||||
let mut connections = Vec::<TcpStream>::new();
|
||||
for stream in &accepted_connections {
|
||||
for stream in accepted_connections.values() {
|
||||
connections.push(stream.try_clone().unwrap());
|
||||
}
|
||||
|
||||
|
@ -721,7 +735,7 @@ fn run_server(
|
|||
DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::ServerExitMsg) => break,
|
||||
}
|
||||
}
|
||||
for connection in &mut accepted_connections {
|
||||
for connection in accepted_connections.values_mut() {
|
||||
let _ = connection.shutdown(Shutdown::Both);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue