mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #23045 - miller-time:promote-memory-blob, r=jdm
create uuid before sending PromoteMemory message <!-- Please describe your changes on the following line: --> When `Blob::promote` is promoting a `BlobImpl::Memory`, create uuid and send it with the `FileManagerThreadMsg::PromoteMemory` message rather than blocking until one is received. --- <!-- 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 #23032 (GitHub issue number if applicable) <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23045) <!-- Reviewable:end -->
This commit is contained in:
commit
452d2dcdef
4 changed files with 20 additions and 56 deletions
|
@ -125,20 +125,8 @@ impl FileManager {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn promote_memory(
|
||||
&self,
|
||||
blob_buf: BlobBuf,
|
||||
set_valid: bool,
|
||||
sender: IpcSender<Result<Uuid, BlobURLStoreError>>,
|
||||
origin: FileOrigin,
|
||||
) {
|
||||
let store = self.store.clone();
|
||||
thread::Builder::new()
|
||||
.name("transfer memory".to_owned())
|
||||
.spawn(move || {
|
||||
store.promote_memory(blob_buf, set_valid, sender, origin);
|
||||
})
|
||||
.expect("Thread spawning failed");
|
||||
pub fn promote_memory(&self, id: Uuid, blob_buf: BlobBuf, set_valid: bool, origin: FileOrigin) {
|
||||
self.store.promote_memory(id, blob_buf, set_valid, origin);
|
||||
}
|
||||
|
||||
/// Message handler
|
||||
|
@ -167,8 +155,8 @@ impl FileManager {
|
|||
FileManagerThreadMsg::ReadFile(sender, id, check_url_validity, origin) => {
|
||||
self.read_file(sender, id, check_url_validity, origin);
|
||||
},
|
||||
FileManagerThreadMsg::PromoteMemory(blob_buf, set_valid, sender, origin) => {
|
||||
self.promote_memory(blob_buf, set_valid, sender, origin);
|
||||
FileManagerThreadMsg::PromoteMemory(id, blob_buf, set_valid, origin) => {
|
||||
self.promote_memory(id, blob_buf, set_valid, origin);
|
||||
},
|
||||
FileManagerThreadMsg::AddSlicedURLEntry(id, rel_pos, sender, origin) => {
|
||||
self.store.add_sliced_url_entry(id, rel_pos, sender, origin);
|
||||
|
@ -666,17 +654,10 @@ impl FileManagerStore {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn promote_memory(
|
||||
&self,
|
||||
blob_buf: BlobBuf,
|
||||
set_valid: bool,
|
||||
sender: IpcSender<Result<Uuid, BlobURLStoreError>>,
|
||||
origin: FileOrigin,
|
||||
) {
|
||||
fn promote_memory(&self, id: Uuid, blob_buf: BlobBuf, set_valid: bool, origin: FileOrigin) {
|
||||
match Url::parse(&origin) {
|
||||
// parse to check sanity
|
||||
Ok(_) => {
|
||||
let id = Uuid::new_v4();
|
||||
self.insert(
|
||||
id,
|
||||
FileStoreEntry {
|
||||
|
@ -686,12 +667,8 @@ impl FileManagerStore {
|
|||
is_valid_url: AtomicBool::new(set_valid),
|
||||
},
|
||||
);
|
||||
|
||||
let _ = sender.send(Ok(id));
|
||||
},
|
||||
Err(_) => {
|
||||
let _ = sender.send(Err(BlobURLStoreError::InvalidOrigin));
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue