Support responseCookies, responseContent, responseHeaders, requestCookies, getResponseHeaders,

getResponseContent, getRequestPostData, getRequestCookies, getResponseCookies, getEventTimings and
getSecurityInfo message for network devtools

Fixing Indentation
This commit is contained in:
Abhishek Kumar 2015-12-01 15:50:43 -05:00
parent 552df7e79e
commit f889b1ccd7
5 changed files with 405 additions and 27 deletions

View file

@ -35,7 +35,8 @@ use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
use actors::framerate::FramerateActor;
use actors::inspector::InspectorActor;
use actors::network_event::{EventActor, NetworkEventActor, ResponseStartMsg};
use actors::network_event::{EventActor, NetworkEventActor, RequestCookiesMsg, ResponseCookiesMsg };
use actors::network_event::{ResponseContentMsg, ResponseHeadersMsg, ResponseStartMsg };
use actors::performance::PerformanceActor;
use actors::profiler::ProfilerActor;
use actors::root::RootActor;
@ -102,13 +103,61 @@ struct NetworkEventMsg {
}
#[derive(RustcEncodable)]
struct NetworkEventUpdateMsg {
struct ResponseStartUpdateMsg {
from: String,
__type__: String,
updateType: String,
response: ResponseStartMsg,
}
#[derive(RustcEncodable)]
struct ResponseContentUpdateMsg {
from: String,
__type__: String,
updateType: String,
responseContent: ResponseContentMsg,
}
#[derive(RustcEncodable)]
struct ResponseCookiesUpdateMsg {
from: String,
__type__: String,
updateType: String,
responseCookies: ResponseCookiesMsg,
}
#[derive(RustcEncodable)]
struct ResponseHeadersUpdateMsg {
from: String,
__type__: String,
updateType: String,
responseHeaders: ResponseHeadersMsg,
}
#[derive(RustcEncodable)]
struct RequestCookiesUpdateMsg {
from: String,
__type__: String,
updateType: String,
requestcookies: RequestCookiesMsg,
}
#[derive(RustcEncodable)]
struct EventTimingsUpdateMsg {
from: String,
__type__: String,
updateType: String,
totalTime: u32,
}
#[derive(RustcEncodable)]
struct SecurityInfoUpdateMsg {
from: String,
__type__: String,
updateType: String,
securityState: String,
}
/// Spin up a devtools server that listens for connections on the specified port.
pub fn start_server(port: u16) -> Sender<DevtoolsControlMsg> {
let (sender, receiver) = channel();
@ -348,14 +397,25 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
for stream in &mut connections {
stream.write_json_packet(&msg);
}
}
NetworkEvent::HttpResponse(httpresponse) => {
//Store the response information in the actor
actor.add_response(httpresponse);
let msg7 = RequestCookiesUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "requestCookies".to_owned(),
requestcookies: actor.request_cookies(),
};
for stream in &mut connections {
stream.write_json_packet(&msg7);
}
//Send a networkEventUpdate (responseStart) to the client
let msg = NetworkEventUpdateMsg {
from: netevent_actor_name,
let msg = ResponseStartUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "responseStart".to_owned(),
response: actor.response_start()
@ -364,9 +424,62 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
for stream in &mut connections {
stream.write_json_packet(&msg);
}
let msg2 = EventTimingsUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "eventTimings".to_owned(),
totalTime: 0
};
for stream in &mut connections {
stream.write_json_packet(&msg2);
}
let msg3 = SecurityInfoUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "securityInfo".to_owned(),
securityState: "".to_owned(),
};
for stream in &mut connections {
stream.write_json_packet(&msg3);
}
let msg4 = ResponseContentUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "responseContent".to_owned(),
responseContent: actor.response_content(),
};
for stream in &mut connections {
stream.write_json_packet(&msg4);
}
let msg5 = ResponseCookiesUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "responseCookies".to_owned(),
responseCookies: actor.response_cookies(),
};
for stream in &mut connections {
stream.write_json_packet(&msg5);
}
let msg6 = ResponseHeadersUpdateMsg {
from: netevent_actor_name.clone(),
__type__: "networkEventUpdate".to_owned(),
updateType: "responseHeaders".to_owned(),
responseHeaders: actor.response_headers(),
};
for stream in &mut connections {
stream.write_json_packet(&msg6);
}
}
//TODO: Send the other types of update messages at appropriate times
// requestHeaders, requestCookies, responseHeaders, securityInfo, etc
}
}