diff options
author | Ridhim Rastogi <ridhimrastogi@gmail.com> | 2019-11-30 00:54:11 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2019-12-03 15:59:35 -0500 |
commit | a5469f871073c4cf7912719c8fd47e233805e4e8 (patch) | |
tree | 5c78332f057f8c36faeaf555595cd7a929ea23fc /components/script/script_runtime.rs | |
parent | 87c1019c5deafd128acd76f083e63f1a285bb1e0 (diff) | |
download | servo-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.rs | 13 |
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( |