mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Auto merge of #5727 - jdm:parserinterrupt2, r=mbrubeck
...r parsing. Hook up document loading to async networking events. Relies on https://github.com/servo/html5ever/pull/107, so we'll likely need to backport it rather than wait for the next rustc upgrade. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5727) <!-- Reviewable:end -->
This commit is contained in:
commit
dd319c1a99
36 changed files with 442 additions and 302 deletions
|
@ -132,8 +132,6 @@ pub struct PendingAsyncLoad {
|
|||
resource_task: ResourceTask,
|
||||
url: Url,
|
||||
pipeline: Option<PipelineId>,
|
||||
input_sender: Sender<LoadResponse>,
|
||||
input_receiver: Receiver<LoadResponse>,
|
||||
guard: PendingLoadGuard,
|
||||
}
|
||||
|
||||
|
@ -156,13 +154,10 @@ impl Drop for PendingLoadGuard {
|
|||
impl PendingAsyncLoad {
|
||||
pub fn new(resource_task: ResourceTask, url: Url, pipeline: Option<PipelineId>)
|
||||
-> PendingAsyncLoad {
|
||||
let (sender, receiver) = channel();
|
||||
PendingAsyncLoad {
|
||||
resource_task: resource_task,
|
||||
url: url,
|
||||
pipeline: pipeline,
|
||||
input_sender: sender,
|
||||
input_receiver: receiver,
|
||||
guard: PendingLoadGuard { loaded: false, },
|
||||
}
|
||||
}
|
||||
|
@ -171,9 +166,18 @@ impl PendingAsyncLoad {
|
|||
pub fn load(mut self) -> Receiver<LoadResponse> {
|
||||
self.guard.neuter();
|
||||
let load_data = LoadData::new(self.url, self.pipeline);
|
||||
let consumer = LoadConsumer::Channel(self.input_sender);
|
||||
let (sender, receiver) = channel();
|
||||
let consumer = LoadConsumer::Channel(sender);
|
||||
self.resource_task.send(ControlMsg::Load(load_data, consumer)).unwrap();
|
||||
receiver
|
||||
}
|
||||
|
||||
/// Initiate the network request associated with this pending load, using the provided target.
|
||||
pub fn load_async(mut self, listener: Box<AsyncResponseTarget + Send>) {
|
||||
self.guard.neuter();
|
||||
let load_data = LoadData::new(self.url, self.pipeline);
|
||||
let consumer = LoadConsumer::Listener(listener);
|
||||
self.resource_task.send(ControlMsg::Load(load_data, consumer)).unwrap();
|
||||
self.input_receiver
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue