forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of servo#21170 - gterzian:use_remote_event_task_source_for…
…_eventsource, r=jdm Use remote-event task source in EventSource <!-- Please describe your changes on the following line: --> Follow up on servo#21126, this again 'changes nothing', but will be useful for servo#21114 in the context of servo#21111. Trying to break up work into smaller PR's ;) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix servo#21112 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21170) <!-- Reviewable:end -->
- Loading branch information
Showing
7 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use msg::constellation_msg::PipelineId; | ||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory}; | ||
use task::{TaskCanceller, TaskOnce}; | ||
use task_source::{TaskSource, TaskSourceName}; | ||
|
||
#[derive(JSTraceable)] | ||
pub struct RemoteEventTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId); | ||
|
||
impl Clone for RemoteEventTaskSource { | ||
fn clone(&self) -> RemoteEventTaskSource { | ||
RemoteEventTaskSource(self.0.clone(), self.1.clone()) | ||
} | ||
} | ||
|
||
impl TaskSource for RemoteEventTaskSource { | ||
const NAME: TaskSourceName = TaskSourceName::RemoteEvent; | ||
|
||
fn queue_with_canceller<T>( | ||
&self, | ||
task: T, | ||
canceller: &TaskCanceller, | ||
) -> Result<(), ()> | ||
where | ||
T: TaskOnce + 'static, | ||
{ | ||
self.0.send(CommonScriptMsg::Task( | ||
ScriptThreadEventCategory::NetworkEvent, | ||
Box::new(canceller.wrap_task(task)), | ||
Some(self.1), | ||
)) | ||
} | ||
} |