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

Unified Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix shared_build compile error. 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
Index: chrome/browser/media_gallery/media_file_system_registry.cc
diff --git a/chrome/browser/media_gallery/media_file_system_registry.cc b/chrome/browser/media_gallery/media_file_system_registry.cc
index 455b4a180a96f6b9051e59f4604dd18388db04b8..50b02c06b095ad15e5036cd024d062116c2bd696 100644
--- a/chrome/browser/media_gallery/media_file_system_registry.cc
+++ b/chrome/browser/media_gallery/media_file_system_registry.cc
@@ -20,6 +20,13 @@
#include "content/public/browser/render_process_host.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/isolated_context.h"
+#include "webkit/fileapi/media/media_file_system_config.h"
+
+#if defined(SUPPORT_MEDIA_FILESYSTEM)
+#include "webkit/fileapi/media/media_device_map_service.h"
+
+using fileapi::MediaDeviceMapService;
+#endif
namespace chrome {
@@ -75,7 +82,9 @@ MediaFileSystemRegistry::GetMediaFileSystems(
if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) &&
IsGalleryPermittedForExtension(extension, SystemMonitor::TYPE_PATH,
pictures_path.value())) {
- std::string fsid = RegisterPathAsFileSystem(pictures_path);
+
+ std::string fsid = RegisterPathAsFileSystem(pictures_path,
+ SystemMonitor::TYPE_PATH);
child_it->second.insert(std::make_pair(pictures_path, fsid));
}
}
@@ -90,7 +99,8 @@ MediaFileSystemRegistry::GetMediaFileSystems(
media_devices[i].location)) {
FilePath path(media_devices[i].location);
device_id_map_.insert(std::make_pair(media_devices[i].unique_id, path));
- const std::string fsid = RegisterPathAsFileSystem(path);
+ const std::string fsid = RegisterPathAsFileSystem(path,
+ media_devices[i].type);
child_it->second.insert(std::make_pair(path, fsid));
}
}
@@ -106,12 +116,19 @@ MediaFileSystemRegistry::GetMediaFileSystems(
return results;
}
-void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) {
+void MediaFileSystemRegistry::OnMediaDeviceDetached(
+ const std::string& id,
+ const FilePath::StringType& location) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id);
if (it == device_id_map_.end())
return;
+
+#if defined(SUPPORT_MEDIA_FILESYSTEM)
+ MediaDeviceMapService::GetInstance()->RemoveMediaDevice(location);
+#endif
+
RevokeMediaFileSystem(it->second);
device_id_map_.erase(it);
}
@@ -161,19 +178,23 @@ void MediaFileSystemRegistry::UnregisterForRPHGoneNotifications(
}
std::string MediaFileSystemRegistry::RegisterPathAsFileSystem(
- const FilePath& path) {
+ const FilePath& path, const SystemMonitor::MediaDeviceType& device_type) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Sanity checks for |path|.
CHECK(path.IsAbsolute());
CHECK(!path.ReferencesParent());
+ fileapi::FileSystemType type = fileapi::kFileSystemTypeIsolated;
+ if (device_type == SystemMonitor::TYPE_MTP)
+ type = fileapi::kFileSystemTypeDeviceMedia;
+
// The directory name is not exposed to the js layer and we simply use
// a fixed name (as we only register a single directory per file system).
std::string register_name("_");
const std::string fsid =
IsolatedContext::GetInstance()->RegisterFileSystemForPath(
- fileapi::kFileSystemTypeIsolated, path, &register_name);
+ type, path, &register_name);
CHECK(!fsid.empty());
return fsid;
}

Powered by Google App Engine
This is Rietveld 408576698