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
Improve File API related comments #12897
Merged
+18
−20
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Improve File API related comments
- Loading branch information
commit cd9fc4919dfd626b0bac5d899860d4ee8f963355
| @@ -23,7 +23,7 @@ use util::prefs::PREFS; | ||
| use util::thread::spawn_named; | ||
| use uuid::Uuid; | ||
|
|
||
| /// Trait that provider of file-dialog UI should implement. | ||
| /// The provider of file-dialog UI should implement this trait. | ||
| /// It will be used to initialize a generic FileManager. | ||
| /// For example, we can choose a dummy UI for testing purpose. | ||
| pub trait UIProvider where Self: Sync { | ||
| @@ -82,8 +82,10 @@ struct FileStoreEntry { | ||
| origin: FileOrigin, | ||
| /// Backend implementation | ||
| file_impl: FileImpl, | ||
| /// Number of `FileImpl::Sliced` entries in `FileManagerStore` | ||
| /// that has a reference (FileID) to this entry | ||
| /// Number of FileID holders that the ID is used to | ||
| /// index this entry in `FileManagerStore`. | ||
| /// Reference holders include a FileStoreEntry or | ||
| /// a script-side File-based Blob | ||
| refs: AtomicUsize, | ||
| /// UUIDs only become valid blob URIs when explicitly requested | ||
| /// by the user with createObjectURL. Validity can be revoked as well. | ||
| @@ -157,8 +159,6 @@ impl<UI: 'static + UIProvider> FileManager<UI> { | ||
| FileManagerThreadMsg::DecRef(id, origin, sender) => { | ||
| if let Ok(id) = Uuid::parse_str(&id.0) { | ||
izgzhen
Author
Contributor
|
||
| spawn_named("dec ref".to_owned(), move || { | ||
| // Since it is simple DecRef (possibly caused by close/drop), | ||
| // unset_url_validity is false | ||
| let _ = sender.send(store.dec_ref(&id, &origin)); | ||
| }) | ||
| } else { | ||
| @@ -168,7 +168,6 @@ impl<UI: 'static + UIProvider> FileManager<UI> { | ||
| FileManagerThreadMsg::RevokeBlobURL(id, origin, sender) => { | ||
| if let Ok(id) = Uuid::parse_str(&id.0) { | ||
| spawn_named("revoke blob url".to_owned(), move || { | ||
| // Since it is revocation, unset_url_validity is true | ||
| let _ = sender.send(store.set_blob_url_validity(false, &id, &origin)); | ||
| }) | ||
| } else { | ||
| @@ -487,8 +486,6 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> { | ||
| self.remove(id); | ||
|
|
||
| if let Some(parent_id) = opt_parent_id { | ||
| // unset_url_validity for parent is false since we only need | ||
| // to unset the initial requesting URL | ||
| return self.dec_ref(&parent_id, origin_in); | ||
| } | ||
| } | ||
| @@ -505,7 +502,6 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> { | ||
| origin: origin.clone(), | ||
| file_impl: FileImpl::Memory(blob_buf), | ||
| refs: AtomicUsize::new(1), | ||
| // Valid here since PromoteMemory implies URL creation | ||
| is_valid_url: AtomicBool::new(set_valid), | ||
| }); | ||
|
|
||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Any reasons for removing these?