aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_runtime.rs
diff options
context:
space:
mode:
authorRidhim Rastogi <ridhimrastogi@gmail.com>2019-11-30 00:54:11 -0500
committerJosh Matthews <josh@joshmatthews.net>2019-12-03 15:59:35 -0500
commita5469f871073c4cf7912719c8fd47e233805e4e8 (patch)
tree5c78332f057f8c36faeaf555595cd7a929ea23fc /components/script/script_runtime.rs
parent87c1019c5deafd128acd76f083e63f1a285bb1e0 (diff)
downloadservo-a5469f871073c4cf7912719c8fd47e233805e4e8.tar.gz
servo-a5469f871073c4cf7912719c8fd47e233805e4e8.zip
Add StreamConsumer wrapper and methods to response
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r--components/script/script_runtime.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs
index fa02e7e564e..02a6b42b854 100644
--- a/components/script/script_runtime.rs
+++ b/components/script/script_runtime.rs
@@ -853,26 +853,30 @@ pub struct StreamConsumer(*mut JSStreamConsumer);
#[allow(unsafe_code)]
impl StreamConsumer {
- fn consume_chunk(&self, stream: &[u8]) -> bool {
+ pub fn consume_chunk(&self, stream: &[u8]) -> bool {
unsafe {
let stream_ptr = stream.as_ptr();
return StreamConsumerConsumeChunk(self.0, stream_ptr, stream.len());
}
}
- fn stream_end(&self) {
+ pub fn stream_end(&self) {
unsafe {
StreamConsumerStreamEnd(self.0);
}
}
- fn stream_error(&self, error_code: usize) {
+ pub fn stream_error(&self, error_code: usize) {
unsafe {
StreamConsumerStreamError(self.0, error_code);
}
}
- fn note_response_urls(&self, maybe_url: Option<String>, maybe_source_map_url: Option<String>) {
+ pub fn note_response_urls(
+ &self,
+ maybe_url: Option<String>,
+ maybe_source_map_url: Option<String>,
+ ) {
unsafe {
let maybe_url = maybe_url.map(|url| CString::new(url).unwrap());
let maybe_source_map_url = maybe_source_map_url.map(|url| CString::new(url).unwrap());
@@ -965,6 +969,7 @@ unsafe extern "C" fn consume_stream(
);
return false;
}
+ unwrapped_source.set_stream_consumer(Some(StreamConsumer(_consumer)));
} else {
//Step 3 Upon rejection of source, return with reason.
throw_dom_exception(