mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fix network event update Message (#37543)
- Add `ResourceArrayType` with `Available` and `Updated` variants - Rename `resources-available` and `resource-available` to `resources-array` ,`resource-array` - Add `ResourceArrayType` as an argument to decide the type of resources - Add `Option<ResponseContentMsg>`,`Option<ResponseStartMsg>`, `Option<ResponseCookiesMsg>`, `Option<ResponseHeadersMsg>`,`Option<RequestCookiesMsg>`, `Option<RequestHeadersMsg>`, `total_time`, `security_state` to `NetworkEventActor` struct , and serialize the data in each to `resource_updates` , flattening the nested arrays into a single JSON - Refactor the following methods `request_headers`,`response_start` , `response_content`,`response_cookies`,`response_headers`, `request_cookies`,`total_time` to associated functions passing `HttpRequest` and `HttpResponse` as parameters . Testing: Ran servo with devtools flag to see the logs corresponding to the changes Fixes: https://github.com/servo/servo/issues/37479 This PR Builds on https://github.com/servo/servo/pull/37517 and was opened due to merge conflicts and branch issues --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
parent
8edae71286
commit
7d2c9ec19c
6 changed files with 216 additions and 138 deletions
|
@ -8,6 +8,11 @@ use serde::Serialize;
|
|||
|
||||
use crate::protocol::JsonPacketStream;
|
||||
|
||||
pub enum ResourceArrayType {
|
||||
Available,
|
||||
Updated,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct ResourceAvailableReply<T: Serialize> {
|
||||
pub from: String,
|
||||
|
@ -19,24 +24,29 @@ pub(crate) struct ResourceAvailableReply<T: Serialize> {
|
|||
pub(crate) trait ResourceAvailable {
|
||||
fn actor_name(&self) -> String;
|
||||
|
||||
fn resource_available<T: Serialize>(
|
||||
fn resource_array<T: Serialize>(
|
||||
&self,
|
||||
resource: T,
|
||||
resource_type: String,
|
||||
array_type: ResourceArrayType,
|
||||
stream: &mut TcpStream,
|
||||
) {
|
||||
self.resources_available(vec![resource], resource_type, stream);
|
||||
self.resources_array(vec![resource], resource_type, array_type, stream);
|
||||
}
|
||||
|
||||
fn resources_available<T: Serialize>(
|
||||
fn resources_array<T: Serialize>(
|
||||
&self,
|
||||
resources: Vec<T>,
|
||||
resource_type: String,
|
||||
array_type: ResourceArrayType,
|
||||
stream: &mut TcpStream,
|
||||
) {
|
||||
let msg = ResourceAvailableReply::<T> {
|
||||
from: self.actor_name(),
|
||||
type_: "resources-available-array".into(),
|
||||
type_: match array_type {
|
||||
ResourceArrayType::Available => "resources-available-array".to_string(),
|
||||
ResourceArrayType::Updated => "resources-updated-array".to_string(),
|
||||
},
|
||||
array: vec![(resource_type, resources)],
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue