diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2016-07-16 12:33:40 -0700 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2016-09-21 11:50:54 -0700 |
commit | d4816762fa9db76d56014caa50243f40f481265b (patch) | |
tree | 178083686984f2d3613cb264313de80fe56d9288 /components/script/document_loader.rs | |
parent | 2bb95989c52721a0260aa687d604733f0eb17af6 (diff) | |
download | servo-d4816762fa9db76d56014caa50243f40f481265b.tar.gz servo-d4816762fa9db76d56014caa50243f40f481265b.zip |
Add fetch_async to PendingAsyncLoad, DocumentLoader and Document
Diffstat (limited to 'components/script/document_loader.rs')
-rw-r--r-- | components/script/document_loader.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index 0fc1e5e06c5..c38a234b2c1 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -7,9 +7,11 @@ use dom::bindings::js::JS; use dom::document::Document; +use ipc_channel::ipc::IpcSender; use msg::constellation_msg::{PipelineId, ReferrerPolicy}; -use net_traits::{PendingAsyncLoad, AsyncResponseTarget, LoadContext}; -use net_traits::{ResourceThreads, IpcSend}; +use net_traits::request::RequestInit; +use net_traits::{AsyncResponseTarget, PendingAsyncLoad, LoadContext}; +use net_traits::{FetchResponseMsg, ResourceThreads, IpcSend}; use std::thread; use url::Url; @@ -148,6 +150,17 @@ impl DocumentLoader { pending.load_async(listener) } + /// Initiate a new fetch. + pub fn fetch_async(&mut self, + load: LoadType, + request: RequestInit, + fetch_target: IpcSender<FetchResponseMsg>, + referrer: &Document, + referrer_policy: Option<ReferrerPolicy>) { + let pending = self.prepare_async_load(load, referrer, referrer_policy); + pending.fetch_async(request, fetch_target); + } + /// Mark an in-progress network request complete. pub fn finish_load(&mut self, load: &LoadType) { let idx = self.blocking_loads.iter().position(|unfinished| *unfinished == *load); |