diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-07-29 04:41:19 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-07-29 04:41:19 -0600 |
commit | 96b0f96ce2829cc38457ace22be4f731f8ca9d77 (patch) | |
tree | 14a7e549707c3e98d38397a6f62076def1d23dae /components/script/dom/blob.rs | |
parent | 2ec4c49de8c57ecd93abdd145d7929d5c85c1669 (diff) | |
parent | 20f99e92d81601f323660df52f31544adf38334a (diff) | |
download | servo-96b0f96ce2829cc38457ace22be4f731f8ca9d77.tar.gz servo-96b0f96ce2829cc38457ace22be4f731f8ca9d77.zip |
Auto merge of #6803 - farodin91:blob, r=Ms2ger
Adding for support Blob.{close,isClose} #6723
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6803)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/blob.rs')
-rw-r--r-- | components/script/dom/blob.rs | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 1ba7b929eaf..4213b8ff2a6 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -18,6 +18,7 @@ use num::ToPrimitive; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cmp::{min, max}; +use std::cell::{Cell}; #[derive(JSTraceable)] pub enum BlobTypeId { @@ -32,8 +33,8 @@ pub struct Blob { type_: BlobTypeId, bytes: Option<Vec<u8>>, typeString: DOMString, - global: GlobalField - // isClosed_: bool + global: GlobalField, + isClosed_: Cell<bool> } fn is_ascii_printable(string: &DOMString) -> bool{ @@ -50,8 +51,8 @@ impl Blob { type_: type_, bytes: bytes, typeString: typeString.to_owned(), - global: GlobalField::from_rooted(&global) - //isClosed_: false + global: GlobalField::from_rooted(&global), + isClosed_: Cell::new(false) } } @@ -83,7 +84,6 @@ impl Blob { pub trait BlobHelpers { fn read_out_buffer(self) -> Receiver<Vec<u8>>; - fn read_out_type(self) -> DOMString; } impl<'a> BlobHelpers for &'a Blob { @@ -92,9 +92,6 @@ impl<'a> BlobHelpers for &'a Blob { send.send(self.bytes.clone().unwrap_or(vec![])).unwrap(); recv } - fn read_out_type(self) -> DOMString { - self.typeString.clone() - } } impl<'a> BlobMethods for &'a Blob { @@ -159,15 +156,24 @@ impl<'a> BlobMethods for &'a Blob { } } - // http://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed - //fn IsClosed(self) -> bool { - // self.isClosed_.clone() - //} + // https://dev.w3.org/2006/webapi/FileAPI/#dfn-isClosed + fn IsClosed(self) -> bool { + self.isClosed_.get() + } + + // https://dev.w3.org/2006/webapi/FileAPI/#dfn-close + fn Close(self) { + // Step 1 + if self.isClosed_.get() { + return; + } + + // Step 2 + self.isClosed_.set(true); - // http://dev.w3.org/2006/webapi/FileAPI/#dfn-close - //fn Close(self) { - // TODO - //} + // TODO Step 3 if Blob URL Store is implemented + + } } impl FileDerived for Blob { |