Auto merge of #11221 - izgzhen:blob-file-backend, r=Manishearth

Add file backend support for Blob and related

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy --faster` does not report any errors
- [x] These changes fix #10851, related to #11131
- [x] These changes do not require tests because the implementation is partial and can't work alone

1. Add new backend to `Blob` and a `BlobImpl` struct to abstract multiple backends
2. Rewrite most interfaces of `Blob` to accommodate the change
3. Change the `read` behaviour of `FileReader`, considering the case when blob is file-backed and not cached

The design is still immature, welcome comments!

- [x] I used `DOMRefCell` to cache the bytes in `BlobImpl`, is it sound?
- [x] The interfaces (like `BlobImpl::get_bytes`) handle requests in a default-to-empty way when the inner `DataSlice` is not cached. It might be possible to handle this condition better.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11221)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-01 05:09:21 -05:00
commit 3d7b17681d
18 changed files with 253 additions and 152 deletions

View file

@ -1573,9 +1573,9 @@ impl ScriptThread {
}
});
let loader = DocumentLoader::new_with_thread(Arc::new(self.resource_threads.sender()),
Some(browsing_context.pipeline()),
Some(incomplete.url.clone()));
let loader = DocumentLoader::new_with_threads(self.resource_threads.clone(),
Some(browsing_context.pipeline()),
Some(incomplete.url.clone()));
let is_html_document = match metadata.content_type {
Some(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _))) |