Commit 26f8f3aa authored by vandebo@chromium.org's avatar vandebo@chromium.org

Remove dead code in media galleries file system registry.

Since adding the preferences observer, RevokeOldGalleries() has been dead code.

BUG=NONE

Review URL: https://codereview.chromium.org/164983006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251541 0039d316-1c4b-4281-b951-d872f2087c98
parent 29742ef8
...@@ -285,26 +285,6 @@ class ExtensionGalleriesHost ...@@ -285,26 +285,6 @@ class ExtensionGalleriesHost
base::Owned(device_ids), galleries, galleries_info, callback)); base::Owned(device_ids), galleries, galleries_info, callback));
} }
void RevokeOldGalleries(const MediaGalleryPrefIdSet& new_galleries) {
if (new_galleries.size() == pref_id_map_.size())
return;
MediaGalleryPrefIdSet old_galleries;
for (PrefIdFsInfoMap::const_iterator it = pref_id_map_.begin();
it != pref_id_map_.end();
++it) {
old_galleries.insert(it->first);
}
MediaGalleryPrefIdSet invalid_galleries =
base::STLSetDifference<MediaGalleryPrefIdSet>(old_galleries,
new_galleries);
for (MediaGalleryPrefIdSet::const_iterator it = invalid_galleries.begin();
it != invalid_galleries.end();
++it) {
RevokeGalleryByPrefId(*it);
}
}
// Revoke the file system for |id| if this extension has created one for |id|. // Revoke the file system for |id| if this extension has created one for |id|.
void RevokeGalleryByPrefId(MediaGalleryPrefId id) { void RevokeGalleryByPrefId(MediaGalleryPrefId id) {
PrefIdFsInfoMap::iterator gallery = pref_id_map_.find(id); PrefIdFsInfoMap::iterator gallery = pref_id_map_.find(id);
...@@ -352,7 +332,6 @@ class ExtensionGalleriesHost ...@@ -352,7 +332,6 @@ class ExtensionGalleriesHost
return; return;
} }
MediaGalleryPrefIdSet new_galleries;
for (std::set<MediaGalleryPrefId>::const_iterator pref_id_it = for (std::set<MediaGalleryPrefId>::const_iterator pref_id_it =
galleries.begin(); galleries.begin();
pref_id_it != galleries.end(); pref_id_it != galleries.end();
...@@ -368,7 +347,6 @@ class ExtensionGalleriesHost ...@@ -368,7 +347,6 @@ class ExtensionGalleriesHost
pref_id_map_.find(pref_id); pref_id_map_.find(pref_id);
if (existing_info != pref_id_map_.end()) { if (existing_info != pref_id_map_.end()) {
result.push_back(existing_info->second); result.push_back(existing_info->second);
new_galleries.insert(pref_id);
continue; continue;
} }
...@@ -390,17 +368,15 @@ class ExtensionGalleriesHost ...@@ -390,17 +368,15 @@ class ExtensionGalleriesHost
StorageInfo::IsRemovableDevice(device_id), StorageInfo::IsRemovableDevice(device_id),
StorageInfo::IsMediaDevice(device_id)); StorageInfo::IsMediaDevice(device_id));
result.push_back(new_entry); result.push_back(new_entry);
new_galleries.insert(pref_id);
pref_id_map_[pref_id] = new_entry; pref_id_map_[pref_id] = new_entry;
} }
if (result.size() == 0) { if (result.size() == 0) {
rph_refs_.Reset(); rph_refs_.Reset();
CleanUp(); CleanUp();
} else {
RevokeOldGalleries(new_galleries);
} }
DCHECK_EQ(pref_id_map_.size(), result.size());
callback.Run(result); callback.Run(result);
} }
......
...@@ -1046,3 +1046,32 @@ TEST_F(MediaFileSystemRegistryTest, TestNameConstruction) { ...@@ -1046,3 +1046,32 @@ TEST_F(MediaFileSystemRegistryTest, TestNameConstruction) {
profile_state->CheckGalleries("names", one_expectation, one_expectation); profile_state->CheckGalleries("names", one_expectation, one_expectation);
} }
} }
TEST_F(MediaFileSystemRegistryTest, PreferenceListener) {
CreateProfileState(1);
AssertAllAutoAddedGalleries();
// Add a user gallery to the regular permission extension.
std::string device_id = AddUserGallery(StorageInfo::FIXED_MASS_STORAGE,
empty_dir().AsUTF8Unsafe(),
empty_dir());
ProfileState* profile_state = GetProfileState(0);
SetGalleryPermission(profile_state,
profile_state->regular_permission_extension(),
device_id,
true /*has access*/);
FSInfoMap fs_info = profile_state->GetGalleriesInfo(
profile_state->regular_permission_extension());
ASSERT_EQ(1U, fs_info.size());
EXPECT_FALSE(test_file_system_context()->GetPathForId(
fs_info.begin()->second.fsid).empty());
// Revoke permission and ensure that the file system is revoked.
SetGalleryPermission(profile_state,
profile_state->regular_permission_extension(),
device_id,
false /*has access*/);
EXPECT_TRUE(test_file_system_context()->GetPathForId(
fs_info.begin()->second.fsid).empty());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment