Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fetch infrastructure to load external scripts #12472

Merged
merged 8 commits into from Sep 22, 2016

Fix incorrect indentation

  • Loading branch information
KiChjang committed Sep 21, 2016
commit 5729a4a3d42baadf6e903177658eea7324c39597
@@ -219,35 +219,39 @@ impl XMLHttpRequest {
core_resource_thread: CoreResourceThread,
init: RequestInit) {
impl FetchResponseListener for XHRContext {
fn process_request_body(&mut self) {
// todo
}
fn process_request_eof(&mut self) {
// todo
}
fn process_response(&mut self, metadata: Result<Metadata, NetworkError>) {
let xhr = self.xhr.root();
let rv = xhr.process_headers_available(self.gen_id,
metadata);
if rv.is_err() {
*self.sync_status.borrow_mut() = Some(rv);
}
}
fn process_response_chunk(&mut self, mut chunk: Vec<u8>) {
self.buf.borrow_mut().append(&mut chunk);
self.xhr.root().process_data_available(self.gen_id, self.buf.borrow().clone());
}
fn process_response_eof(&mut self, response: Result<(), NetworkError>) {
let rv = match response {
Ok(()) => {
self.xhr.root().process_response_complete(self.gen_id, Ok(()))
}
Err(e) => {
self.xhr.root().process_response_complete(self.gen_id, Err(e))
}
};
fn process_request_body(&mut self) {
// todo
}

fn process_request_eof(&mut self) {
// todo
}

fn process_response(&mut self, metadata: Result<Metadata, NetworkError>) {
let xhr = self.xhr.root();
let rv = xhr.process_headers_available(self.gen_id,
metadata);
if rv.is_err() {
*self.sync_status.borrow_mut() = Some(rv);
}
}

fn process_response_chunk(&mut self, mut chunk: Vec<u8>) {
self.buf.borrow_mut().append(&mut chunk);
self.xhr.root().process_data_available(self.gen_id, self.buf.borrow().clone());
}

fn process_response_eof(&mut self, response: Result<(), NetworkError>) {
let rv = match response {
Ok(()) => {
self.xhr.root().process_response_complete(self.gen_id, Ok(()))
}
Err(e) => {
self.xhr.root().process_response_complete(self.gen_id, Err(e))
}
};
*self.sync_status.borrow_mut() = Some(rv);
}
}

impl PreInvoke for XHRContext {
@@ -273,9 +277,11 @@ impl LoadOrigin for XMLHttpRequest {
fn referrer_url(&self) -> Option<Url> {
return self.referrer_url.clone();
}

fn referrer_policy(&self) -> Option<ReferrerPolicy> {
return self.referrer_policy;
}

fn pipeline_id(&self) -> Option<PipelineId> {
let global = self.global();
Some(global.r().pipeline_id())
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.