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 bd1b520e80342d7aa987e80ce6e8c5beb35f1196..86cf81a1a6979cde30cc4385f3602df4de914689 100644 |
--- a/chrome/browser/chromeos/file_system_provider/service.cc |
+++ b/chrome/browser/chromeos/file_system_provider/service.cc |
@@ -16,7 +16,9 @@ |
#include "chrome/browser/chromeos/login/user_manager.h" |
#include "content/public/browser/browser_thread.h" |
#include "extensions/browser/event_router.h" |
+#include "extensions/browser/extension_registry.h" |
#include "extensions/browser/extension_system.h" |
+#include "extensions/common/extension.h" |
#include "webkit/browser/fileapi/external_mount_points.h" |
namespace chromeos { |
@@ -47,9 +49,14 @@ base::FilePath GetMountPointPath(Profile* profile, |
} // namespace |
-Service::Service(Profile* profile) |
- : profile_(profile), next_id_(1), weak_ptr_factory_(this) { |
+Service::Service(Profile* profile, |
+ extensions::ExtensionRegistry* extension_registry) |
+ : profile_(profile), |
+ extension_registry_(extension_registry), |
+ next_id_(1), |
+ weak_ptr_factory_(this) { |
AddObserver(&request_manager_); |
+ extension_registry_->AddObserver(this); |
} |
Service::~Service() { STLDeleteValues(&file_system_map_); } |
@@ -226,7 +233,30 @@ ProvidedFileSystemInterface* Service::GetProvidedFileSystem( |
return file_system_it->second; |
} |
-void Service::Shutdown() { RemoveObserver(&request_manager_); } |
+void Service::Shutdown() { |
+ RemoveObserver(&request_manager_); |
+ extension_registry_->RemoveObserver(this); |
+} |
+ |
+void Service::OnExtensionUnloaded(const extensions::Extension* extension) { |
+ // Unmount all of the provided file systems associated with this extension. |
+ ProvidedFileSystemMap::iterator it = file_system_map_.begin(); |
+ while (it != file_system_map_.end()) { |
+ const ProvidedFileSystemInfo& file_system_info = |
+ it->second->GetFileSystemInfo(); |
+ LOG(ERROR) << extension->id() << " vs. " << file_system_info.extension_id(); |
hashimoto
2014/03/27 09:18:49
No need to corrupt the feedback log with this info
mtomasz
2014/03/28 06:01:10
Done.
|
+ if (file_system_info.extension_id() == extension->id()) { |
+ // Advance the iterator beforehand, otherwise it will become invalidated |
+ // by the UnmountFileSystem() call. |
+ ++it; |
+ bool result = UnmountFileSystem(file_system_info.extension_id(), |
+ file_system_info.file_system_id()); |
+ DCHECK(result); |
+ } else { |
+ ++it; |
hashimoto
2014/03/27 09:18:49
nit: How about moving this ++it to above the if-st
mtomasz
2014/03/28 06:01:10
Good idea. Done.
|
+ } |
+ } |
+} |
void Service::OnRequestUnmountStatus( |
const ProvidedFileSystemInfo& file_system_info, |