mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Privatize PendingAsyncLoad.
This commit is contained in:
parent
aa48ec7628
commit
1a2db0b327
3 changed files with 42 additions and 25 deletions
|
@ -7,7 +7,7 @@ use fontsan;
|
|||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use mime::{TopLevel, SubLevel};
|
||||
use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, CoreResourceThread, ResponseAction};
|
||||
use net_traits::{AsyncResponseTarget, LoadContext, CoreResourceThread, ResponseAction, load_async};
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font_list::SANS_SERIF_FONT_FAMILY;
|
||||
use platform::font_list::for_each_available_family;
|
||||
|
@ -208,17 +208,17 @@ impl FontCache {
|
|||
match src {
|
||||
Source::Url(ref url_source) => {
|
||||
let url = &url_source.url;
|
||||
let load = PendingAsyncLoad::new(LoadContext::Font,
|
||||
self.core_resource_thread.clone(),
|
||||
url.clone(),
|
||||
None,
|
||||
None,
|
||||
None);
|
||||
let (data_sender, data_receiver) = ipc::channel().unwrap();
|
||||
let data_target = AsyncResponseTarget {
|
||||
sender: data_sender,
|
||||
};
|
||||
load.load_async(data_target);
|
||||
load_async(LoadContext::Font,
|
||||
self.core_resource_thread.clone(),
|
||||
url.clone(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
data_target);
|
||||
let channel_to_self = self.channel_to_self.clone();
|
||||
let url = (*url).clone();
|
||||
let bytes = Mutex::new(Vec::new());
|
||||
|
|
|
@ -467,7 +467,7 @@ pub enum CoreResourceMsg {
|
|||
/// Initialized but unsent request. Encapsulates everything necessary to instruct
|
||||
/// the resource thread to make a new request. The `load` method *must* be called before
|
||||
/// destruction or the thread will panic.
|
||||
pub struct PendingAsyncLoad {
|
||||
struct PendingAsyncLoad {
|
||||
core_resource_thread: CoreResourceThread,
|
||||
url: Url,
|
||||
pipeline: Option<PipelineId>,
|
||||
|
@ -508,7 +508,7 @@ impl LoadOrigin for PendingAsyncLoad {
|
|||
}
|
||||
|
||||
impl PendingAsyncLoad {
|
||||
pub fn new(context: LoadContext,
|
||||
fn new(context: LoadContext,
|
||||
core_resource_thread: CoreResourceThread,
|
||||
url: Url,
|
||||
pipeline: Option<PipelineId>,
|
||||
|
@ -527,7 +527,7 @@ impl PendingAsyncLoad {
|
|||
}
|
||||
|
||||
/// Initiate the network request associated with this pending load, using the provided target.
|
||||
pub fn load_async(mut self, listener: AsyncResponseTarget) {
|
||||
fn load_async(mut self, listener: AsyncResponseTarget) {
|
||||
self.guard.neuter();
|
||||
|
||||
let load_data = LoadData::new(self.context.clone(),
|
||||
|
@ -538,6 +538,23 @@ impl PendingAsyncLoad {
|
|||
}
|
||||
}
|
||||
|
||||
/// Instruct the resource thread to make a new request.
|
||||
pub fn load_async(context: LoadContext,
|
||||
core_resource_thread: CoreResourceThread,
|
||||
url: Url,
|
||||
pipeline: Option<PipelineId>,
|
||||
referrer_policy: Option<ReferrerPolicy>,
|
||||
referrer_url: Option<Url>,
|
||||
listener: AsyncResponseTarget) {
|
||||
let load = PendingAsyncLoad::new(context,
|
||||
core_resource_thread,
|
||||
url,
|
||||
pipeline,
|
||||
referrer_policy,
|
||||
referrer_url);
|
||||
load.load_async(listener);
|
||||
}
|
||||
|
||||
/// Message sent in response to `Load`. Contains metadata, and a port
|
||||
/// for receiving the data.
|
||||
///
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::js::JS;
|
|||
use dom::document::Document;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net_traits::{AsyncResponseTarget, CoreResourceMsg, PendingAsyncLoad};
|
||||
use net_traits::{AsyncResponseTarget, CoreResourceMsg, load_async};
|
||||
use net_traits::{FetchResponseMsg, LoadContext, ResourceThreads, IpcSend};
|
||||
use net_traits::request::RequestInit;
|
||||
use std::thread;
|
||||
|
@ -132,13 +132,13 @@ impl DocumentLoader {
|
|||
let context = load.to_load_context();
|
||||
let url = load.url().clone();
|
||||
self.add_blocking_load(load);
|
||||
let pending = PendingAsyncLoad::new(context,
|
||||
load_async(context,
|
||||
self.resource_threads.sender(),
|
||||
url,
|
||||
self.pipeline,
|
||||
referrer_policy.or(referrer.get_referrer_policy()),
|
||||
Some(referrer.url().clone()));
|
||||
pending.load_async(listener)
|
||||
Some(referrer.url().clone()),
|
||||
listener);
|
||||
}
|
||||
|
||||
/// Initiate a new fetch.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue