Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blob loader #11536

Merged
merged 1 commit into from Jun 8, 2016
Merged

Add blob loader #11536

merged 1 commit into from Jun 8, 2016

Conversation

@izgzhen
Copy link
Contributor

izgzhen commented Jun 1, 2016

Add a blob loader to implement Blob URL. The related interfaces to script thread are also declared.

Progressing in parallel with PR #11534. Related to #11131.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix part of #10539
  • These changes do not require tests because not integrated yet.

This change is Reviewable

@highfive
Copy link

highfive commented Jun 1, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/net_traits/blob_url_store.rs, components/net_traits/blob_url_store.rs, components/net/lib.rs, components/net/blob_loader.rs, components/net_traits/lib.rs, components/net_traits/lib.rs
@highfive
Copy link

highfive commented Jun 1, 2016

warning Warning warning

  • These commits modify net code, but no tests are modified. Please consider adding a test!
@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 1, 2016

cc @Manishearth. BTW, I have not plug the loader into the core_resource_thread or file_manager or something else yet. It would be more convenient to let CoreResourceManager::load to attach the proposed loader and dispatch request to it, since I almost mimicked the way about_loader::factory and friends works. But I still remember the clogging possibility you mentioned and might put it under file_manager (which might require us to factor the more general functionality from resource_thread.rs out.)

@izgzhen izgzhen force-pushed the izgzhen:add-blob-loader branch from 39b2c9d to 94181c1 Jun 3, 2016
@highfive
Copy link

highfive commented Jun 3, 2016

New code was committed to pull request.

@izgzhen
Copy link
Contributor Author

izgzhen commented Jun 3, 2016

@highfive highfive assigned Manishearth and unassigned asajeffrey Jun 3, 2016
}
Some((uuid, _fragment)) => {
let (tx, rx) = ipc::channel().unwrap();
let _ = blob_url_store.send(BlobURLStoreMsg::Request(uuid, tx)).unwrap();

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 4, 2016

Member

Should this be messaging the blob store or directly accessing it?

Direct access means that you may have to put synchronization primitives on your blob store, so perhaps this is better.

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 4, 2016

Author Contributor

As I observe, it is more natural to let threads in net task to handle the requests (instead of directly consume it inside script), so I need to somehow message script thread to fetch the content of blob. Not sure if it makes a lot of sense

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 4, 2016

Member

(we discussed this and fixing it will be done in a future PR)

// TODO: Check on GET
// https://w3c.github.io/FileAPI/#requestResponseModel

pub fn factory(load_data: LoadData,

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 4, 2016

Member

I don't think this is how the factories work. This function is more like load_for_consumer in http_loader, the factory is a function that returns functions that call load_for_consumer.

Additionally, there should be a thread involved here.

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 4, 2016

Author Contributor

I agree

start_chan: LoadConsumer,
classifier: Arc<MIMEClassifier>,
_cancel_listener: CancellationListener,
blob_url_store: IpcSender<BlobURLStoreMsg>) {

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 4, 2016

Member

This is a different blob url store than the one from #11534, yes?

If not, I'm not sure if resource_task should ever depend on data from the script task. Additionally, the data in the script task would be destroyed when the task closes, which is a problem if you want to navigate to a blob url.

If it is a new blob url store, do we need a message and event loop? Can we make do with an Arc<Mutex<HashMap<Key, Mutex<Entry>>>>> or something that is shared in the loader? (Similar to how HttpState is shared in http_loader instances)

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 4, 2016

Author Contributor

I am not sure how long the blob uuid should be valid, I think it is natural to let it die when the task closes, since it is the same task that create it by the DOM API.

Besides, I have to manage the store in script thread due to the Origin problem

@highfive
Copy link

highfive commented Jun 6, 2016

New code was committed to pull request.

pub fn load(load_data: LoadData, consumer: LoadConsumer,
blob_url_store: Arc<RwLock<BlobURLStore>>,
classifier: Arc<MIMEClassifier>) { // XXX: Move it into net process later

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 6, 2016

Author Contributor

@Manishearth Regarding factory, it is totally gone here. And load is just a function that will be called with the extended FileManager's attributes.

@@ -41,6 +48,8 @@ impl FileManager {
FileManager {
receiver: recv,
idmap: HashMap::new(),
classifier: Arc::new(MIMEClassifier::new()),
blob_url_store: Arc::new(RwLock::new(BlobURLStore::new())),

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 6, 2016

Author Contributor

I moved the stuff here (although far from the final model). If this might work, I will change the concrete store previously implemented in script thread to IpcSenders.

@izgzhen izgzhen force-pushed the izgzhen:add-blob-loader branch from 1b95198 to 679cf0a Jun 6, 2016
@highfive
Copy link

highfive commented Jun 6, 2016

New code was committed to pull request.

/// Size of content in bytes
pub size: u64,
/// Content of blob
pub bytes: Vec<u8>,

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jun 8, 2016

Member

This will eventually become an enum between bytes, on-disk file name, and slice, right?

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jun 8, 2016

Author Contributor

Yes, the Optioned filename looks awkward itself :P

@Manishearth
Copy link
Member

Manishearth commented Jun 8, 2016

@bors-servo r+

This looks good to me! Next up we need to add ways for script to insert blobs into the store, and make script smart as to when it stores blobs locally and when it forwards them to net (though I recommend talking with the gecko folks first)

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2016

📌 Commit 679cf0a has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2016

Testing commit 679cf0a with merge 3977128...

bors-servo added a commit that referenced this pull request Jun 8, 2016
Add blob loader

Add a blob loader to implement [Blob URL](https://w3c.github.io/FileAPI/#url). The related interfaces to script thread are also declared.

Progressing in parallel with PR #11534. Related to #11131.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix part of #10539

<!-- Either: -->
- [x] These changes do not require tests because not integrated yet.

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11536)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2016

@bors-servo bors-servo merged commit 679cf0a into servo:master Jun 8, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.