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::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use mime::{TopLevel, SubLevel};
|
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_context::FontContextHandle;
|
||||||
use platform::font_list::SANS_SERIF_FONT_FAMILY;
|
use platform::font_list::SANS_SERIF_FONT_FAMILY;
|
||||||
use platform::font_list::for_each_available_family;
|
use platform::font_list::for_each_available_family;
|
||||||
|
@ -208,17 +208,17 @@ impl FontCache {
|
||||||
match src {
|
match src {
|
||||||
Source::Url(ref url_source) => {
|
Source::Url(ref url_source) => {
|
||||||
let url = &url_source.url;
|
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_sender, data_receiver) = ipc::channel().unwrap();
|
||||||
let data_target = AsyncResponseTarget {
|
let data_target = AsyncResponseTarget {
|
||||||
sender: data_sender,
|
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 channel_to_self = self.channel_to_self.clone();
|
||||||
let url = (*url).clone();
|
let url = (*url).clone();
|
||||||
let bytes = Mutex::new(Vec::new());
|
let bytes = Mutex::new(Vec::new());
|
||||||
|
|
|
@ -467,7 +467,7 @@ pub enum CoreResourceMsg {
|
||||||
/// Initialized but unsent request. Encapsulates everything necessary to instruct
|
/// Initialized but unsent request. Encapsulates everything necessary to instruct
|
||||||
/// the resource thread to make a new request. The `load` method *must* be called before
|
/// the resource thread to make a new request. The `load` method *must* be called before
|
||||||
/// destruction or the thread will panic.
|
/// destruction or the thread will panic.
|
||||||
pub struct PendingAsyncLoad {
|
struct PendingAsyncLoad {
|
||||||
core_resource_thread: CoreResourceThread,
|
core_resource_thread: CoreResourceThread,
|
||||||
url: Url,
|
url: Url,
|
||||||
pipeline: Option<PipelineId>,
|
pipeline: Option<PipelineId>,
|
||||||
|
@ -508,13 +508,13 @@ impl LoadOrigin for PendingAsyncLoad {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PendingAsyncLoad {
|
impl PendingAsyncLoad {
|
||||||
pub fn new(context: LoadContext,
|
fn new(context: LoadContext,
|
||||||
core_resource_thread: CoreResourceThread,
|
core_resource_thread: CoreResourceThread,
|
||||||
url: Url,
|
url: Url,
|
||||||
pipeline: Option<PipelineId>,
|
pipeline: Option<PipelineId>,
|
||||||
referrer_policy: Option<ReferrerPolicy>,
|
referrer_policy: Option<ReferrerPolicy>,
|
||||||
referrer_url: Option<Url>)
|
referrer_url: Option<Url>)
|
||||||
-> PendingAsyncLoad {
|
-> PendingAsyncLoad {
|
||||||
PendingAsyncLoad {
|
PendingAsyncLoad {
|
||||||
core_resource_thread: core_resource_thread,
|
core_resource_thread: core_resource_thread,
|
||||||
url: url,
|
url: url,
|
||||||
|
@ -527,7 +527,7 @@ impl PendingAsyncLoad {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initiate the network request associated with this pending load, using the provided target.
|
/// 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();
|
self.guard.neuter();
|
||||||
|
|
||||||
let load_data = LoadData::new(self.context.clone(),
|
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
|
/// Message sent in response to `Load`. Contains metadata, and a port
|
||||||
/// for receiving the data.
|
/// for receiving the data.
|
||||||
///
|
///
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::js::JS;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
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::{FetchResponseMsg, LoadContext, ResourceThreads, IpcSend};
|
||||||
use net_traits::request::RequestInit;
|
use net_traits::request::RequestInit;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -132,13 +132,13 @@ impl DocumentLoader {
|
||||||
let context = load.to_load_context();
|
let context = load.to_load_context();
|
||||||
let url = load.url().clone();
|
let url = load.url().clone();
|
||||||
self.add_blocking_load(load);
|
self.add_blocking_load(load);
|
||||||
let pending = PendingAsyncLoad::new(context,
|
load_async(context,
|
||||||
self.resource_threads.sender(),
|
self.resource_threads.sender(),
|
||||||
url,
|
url,
|
||||||
self.pipeline,
|
self.pipeline,
|
||||||
referrer_policy.or(referrer.get_referrer_policy()),
|
referrer_policy.or(referrer.get_referrer_policy()),
|
||||||
Some(referrer.url().clone()));
|
Some(referrer.url().clone()),
|
||||||
pending.load_async(listener)
|
listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initiate a new fetch.
|
/// Initiate a new fetch.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue