diff options
author | Josh Matthews <josh@joshmatthews.net> | 2016-06-03 13:39:38 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2016-06-06 00:51:36 +0100 |
commit | 7bf2e19437ad954bd1d03bb52b86551546ae8ba5 (patch) | |
tree | 96d085e4a406776ce766e10b4c236be831e4cf65 /components/devtools/protocol.rs | |
parent | 1f5b0008ac763bbb2209a70afddb6434d18cff9d (diff) | |
download | servo-7bf2e19437ad954bd1d03bb52b86551546ae8ba5.tar.gz servo-7bf2e19437ad954bd1d03bb52b86551546ae8ba5.zip |
Make the net monitor panel in FF's devtools show meaningful output.
0) Advertise support for the network monitor in the initial protocol communication.
1) Only notify the developer tools server about the final request in an HTTP transaction.
2) Add timing information for connecting to the HTTP server and sending the HTTP request.
3) Reduce duplication between various networkEventUpdate structures by creating a helper function
that merges two JSON structures together. This also corrects the JSON structure so the devtools
client interprets the output correctly.
4) Calculate various header size fields correctly.
5) Remove unnecessary usize->u32 casts by making the appropriate fields usize.
6) Add header values to request and response header messages.
7) Support triggering page reloads via the devtools client.
Diffstat (limited to 'components/devtools/protocol.rs')
-rw-r--r-- | components/devtools/protocol.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index 3da44cc5323..b385f396c1b 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -28,6 +28,7 @@ pub struct Method { pub trait JsonPacketStream { fn write_json_packet<T: Serialize>(&mut self, obj: &T); + fn write_merged_json_packet<T: Serialize, U: Serialize>(&mut self, base: &T, extra: &U); fn read_json_packet(&mut self) -> Result<Option<Value>, String>; } @@ -38,6 +39,19 @@ impl JsonPacketStream for TcpStream { write!(self, "{}:{}", s.len(), s).unwrap(); } + fn write_merged_json_packet<T: Serialize, U: Serialize>(&mut self, base: &T, extra: &U) { + let mut obj = serde_json::to_value(base); + let obj = obj.as_object_mut().unwrap(); + let extra = serde_json::to_value(extra); + let extra = extra.as_object().unwrap(); + + for (key, value) in extra { + obj.insert(key.to_owned(), value.to_owned()); + } + + self.write_json_packet(obj); + } + fn read_json_packet(&mut self) -> Result<Option<Value>, String> { // https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport // In short, each JSON packet is [ascii length]:[JSON data of given length] |