Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: webkit/fileapi/isolated_context.h

Issue 10829136: Adding RevokeFileSystemByPath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.cc ('k') | webkit/fileapi/isolated_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/isolated_context.h
diff --git a/webkit/fileapi/isolated_context.h b/webkit/fileapi/isolated_context.h
index ca891062f02148e0c0db31736e93f1c51982bfba..1d2215809f47bc45f8a33e1a0640a93152731ea2 100644
--- a/webkit/fileapi/isolated_context.h
+++ b/webkit/fileapi/isolated_context.h
@@ -101,11 +101,15 @@ class FILEAPI_EXPORT IsolatedContext {
const FilePath& path,
std::string* register_name);
- // Revokes filesystem specified by the given filesystem_id.
+ // Revokes all filesystem(s) registerred for the given path.
kmadhusu 2012/08/02 20:07:03 nit: typo "registered"
kinuko 2012/08/02 20:36:22 Done.
+ // This is assumed to be called when the registerred path becomes
+ // globally invalid, e.g. when a device for the path is detached.
+ //
// Note that this revokes the filesystem no matter how many references it has.
- // It is ok to call this on the filesystem that has been already deleted
- // (if its reference count had reached 0).
- void RevokeFileSystem(const std::string& filesystem_id);
+ // It is ok to call this for the path that has no associated filesystems.
+ // Note that this only works for the filesystems registered by
+ // |RegisterFileSystemForPath|.
+ void RevokeFileSystemByPath(const FilePath& path);
// Adds a reference to a filesystem specified by the given filesystem_id.
void AddReference(const std::string& filesystem_id);
@@ -113,7 +117,7 @@ class FILEAPI_EXPORT IsolatedContext {
// Removes a reference to a filesystem specified by the given filesystem_id.
// If the reference count reaches 0 the isolated context gets destroyed.
// It is ok to call this on the filesystem that has been already deleted
- // (e.g. by RevokeFileSystem).
+ // (e.g. by RevokeFileSystemByPath).
void RemoveReference(const std::string& filesystem_id);
// Cracks the given |virtual_path| (which should look like
@@ -156,25 +160,37 @@ class FILEAPI_EXPORT IsolatedContext {
class Instance {
public:
Instance(FileSystemType type, const FileInfo& file_info);
- explicit Instance(const std::set<FileInfo>& dragged_files);
+ explicit Instance(FileSystemType type, const std::set<FileInfo>& files);
~Instance();
FileSystemType type() const { return type_; }
const FileInfo& file_info() const { return file_info_; }
- const std::set<FileInfo>& dragged_files() const { return dragged_files_; }
+ const std::set<FileInfo>& files() const { return files_; }
int ref_counts() const { return ref_counts_; }
void AddRef() { ++ref_counts_; }
void RemoveRef() { --ref_counts_; }
- bool ResolvePathForName(const std::string& name, FilePath* path);
+ bool ResolvePathForName(const std::string& name, FilePath* path) const;
+
+ bool IsSinglePathInstance() const {
+ return instance_type_ == kSinglePathInstance;
+ }
private:
+ enum InstanceType {
+ kSinglePathInstance,
+ kMultiplePathInstance,
kmadhusu 2012/08/02 20:03:59 nit: Can you please more comments on when we will
kinuko 2012/08/02 20:36:22 I removed this type but instead added IsSinglePath
+ };
+
const FileSystemType type_;
+ const InstanceType instance_type_;
+
+ // For single-path instance.
const FileInfo file_info_;
- // For dragged file system.
- const std::set<FileInfo> dragged_files_;
+ // For multiple-path instance (e.g. dragged file system).
+ const std::set<FileInfo> files_;
// Reference counts. Note that an isolated filesystem is created with ref==0
// and will get deleted when the ref count reaches <=0.
@@ -185,6 +201,9 @@ class FILEAPI_EXPORT IsolatedContext {
typedef std::map<std::string, Instance*> IDToInstance;
+ // Reverse map from registerred path to IDs.
+ typedef std::map<FilePath, std::set<std::string> > PathToID;
+
// Obtain an instance of this class via GetInstance().
IsolatedContext();
~IsolatedContext();
@@ -196,6 +215,7 @@ class FILEAPI_EXPORT IsolatedContext {
mutable base::Lock lock_;
IDToInstance instance_map_;
+ PathToID path_to_id_map_;
DISALLOW_COPY_AND_ASSIGN(IsolatedContext);
};
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.cc ('k') | webkit/fileapi/isolated_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698