| Index: chrome/browser/chromeos/file_system_provider/service.cc
|
| diff --git a/chrome/browser/chromeos/file_system_provider/service.cc b/chrome/browser/chromeos/file_system_provider/service.cc
|
| index ba822d364e24d91045f6deed6e7266ae40f14a1a..36bdda0063284813622296953f2129446cca7003 100644
|
| --- a/chrome/browser/chromeos/file_system_provider/service.cc
|
| +++ b/chrome/browser/chromeos/file_system_provider/service.cc
|
| @@ -47,7 +47,16 @@ Service::Service(Profile* profile,
|
| }
|
|
|
| Service::~Service() {
|
| - extension_registry_->RemoveObserver(this);
|
| + ProvidedFileSystemMap::iterator it = file_system_map_.begin();
|
| + while (it != file_system_map_.end()) {
|
| + const int file_system_id = it->first;
|
| + const std::string extension_id =
|
| + it->second->GetFileSystemInfo().extension_id();
|
| + ++it;
|
| + UnmountFileSystem(extension_id, file_system_id);
|
| + }
|
| +
|
| + DCHECK_EQ(0u, file_system_map_.size());
|
| STLDeleteValues(&file_system_map_);
|
| }
|
|
|
| @@ -95,15 +104,14 @@ int Service::MountFileSystem(const std::string& extension_id,
|
|
|
| // The mount point path and name are unique per system, since they are system
|
| // wide. This is necessary for copying between profiles.
|
| - const base::FilePath& mount_point_path =
|
| - util::GetMountPointPath(profile_, extension_id, file_system_id);
|
| - const std::string mount_point_name =
|
| - mount_point_path.BaseName().AsUTF8Unsafe();
|
| + const base::FilePath& mount_path =
|
| + util::GetMountPath(profile_, extension_id, file_system_id);
|
| + const std::string mount_point_name = mount_path.BaseName().AsUTF8Unsafe();
|
|
|
| if (!mount_points->RegisterFileSystem(mount_point_name,
|
| fileapi::kFileSystemTypeProvided,
|
| fileapi::FileSystemMountOption(),
|
| - mount_point_path)) {
|
| + mount_path)) {
|
| FOR_EACH_OBSERVER(
|
| Observer,
|
| observers_,
|
| @@ -116,10 +124,10 @@ int Service::MountFileSystem(const std::string& extension_id,
|
| // system provider file system id.
|
| // Examples:
|
| // file_system_id = 41
|
| - // mount_point_name = file_system_id = b33f1337-41-5aa5
|
| - // mount_point_path = /provided/b33f1337-41-5aa5
|
| + // mount_point_name = b33f1337-41-5aa5
|
| + // mount_path = /provided/b33f1337-41-5aa5
|
| ProvidedFileSystemInfo file_system_info(
|
| - extension_id, file_system_id, file_system_name, mount_point_path);
|
| + extension_id, file_system_id, file_system_name, mount_path);
|
|
|
| // The event router may be NULL for unit tests.
|
| extensions::EventRouter* router = extensions::EventRouter::Get(profile_);
|
| @@ -128,6 +136,7 @@ int Service::MountFileSystem(const std::string& extension_id,
|
| file_system_factory_.Run(router, file_system_info);
|
| DCHECK(file_system);
|
| file_system_map_[file_system_id] = file_system;
|
| + mount_point_name_to_id_map_[mount_point_name] = file_system_id;
|
|
|
| FOR_EACH_OBSERVER(
|
| Observer,
|
| @@ -142,7 +151,7 @@ bool Service::UnmountFileSystem(const std::string& extension_id,
|
| int file_system_id) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| - ProvidedFileSystemMap::iterator file_system_it =
|
| + const ProvidedFileSystemMap::iterator file_system_it =
|
| file_system_map_.find(file_system_id);
|
| if (file_system_it == file_system_map_.end() ||
|
| file_system_it->second->GetFileSystemInfo().extension_id() !=
|
| @@ -179,8 +188,11 @@ bool Service::UnmountFileSystem(const std::string& extension_id,
|
| observers_,
|
| OnProvidedFileSystemUnmount(file_system_info, base::File::FILE_OK));
|
|
|
| + mount_point_name_to_id_map_.erase(mount_point_name);
|
| +
|
| delete file_system_it->second;
|
| file_system_map_.erase(file_system_it);
|
| +
|
| return true;
|
| }
|
|
|
| @@ -215,7 +227,7 @@ ProvidedFileSystemInterface* Service::GetProvidedFileSystem(
|
| int file_system_id) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| - ProvidedFileSystemMap::iterator file_system_it =
|
| + const ProvidedFileSystemMap::const_iterator file_system_it =
|
| file_system_map_.find(file_system_id);
|
| if (file_system_it == file_system_map_.end() ||
|
| file_system_it->second->GetFileSystemInfo().extension_id() !=
|
| @@ -246,6 +258,23 @@ void Service::OnExtensionUnloaded(
|
| }
|
| }
|
|
|
| +ProvidedFileSystemInterface* Service::GetProvidedFileSystem(
|
| + const std::string& mount_point_name) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +
|
| + const MountPointNameToIdMap::const_iterator mapping_it =
|
| + mount_point_name_to_id_map_.find(mount_point_name);
|
| + if (mapping_it == mount_point_name_to_id_map_.end())
|
| + return NULL;
|
| +
|
| + const ProvidedFileSystemMap::const_iterator file_system_it =
|
| + file_system_map_.find(mapping_it->second);
|
| + if (file_system_it == file_system_map_.end())
|
| + return NULL;
|
| +
|
| + return file_system_it->second;
|
| +}
|
| +
|
| void Service::OnRequestUnmountStatus(
|
| const ProvidedFileSystemInfo& file_system_info,
|
| base::File::Error error) {
|
|
|