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); |
}; |