Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd blob loader #11536
Add blob loader #11536
Conversation
highfive
commented
Jun 1, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 1, 2016
|
cc @Manishearth. BTW, I have not plug the loader into the |
highfive
commented
Jun 3, 2016
|
New code was committed to pull request. |
|
r? @Manishearth |
| } | ||
| Some((uuid, _fragment)) => { | ||
| let (tx, rx) = ipc::channel().unwrap(); | ||
| let _ = blob_url_store.send(BlobURLStoreMsg::Request(uuid, tx)).unwrap(); |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
| // TODO: Check on GET | ||
| // https://w3c.github.io/FileAPI/#requestResponseModel | ||
|
|
||
| pub fn factory(load_data: LoadData, |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
| start_chan: LoadConsumer, | ||
| classifier: Arc<MIMEClassifier>, | ||
| _cancel_listener: CancellationListener, | ||
| blob_url_store: IpcSender<BlobURLStoreMsg>) { |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
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.
This comment has been minimized.
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.
This comment has been minimized.
|
@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) |
|
|
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 -->
|
|
izgzhen commentedJun 1, 2016
•
edited
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is