summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_file_util.cc
diff options
context:
space:
mode:
authormek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:55:05 +0000
committermek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:55:05 +0000
commit0db124b0b4d60f0c5780ec1dbb52717386097388 (patch)
tree51df669139dedb3e046cd2b9a948554cc781ac43 /chrome/common/extensions/extension_file_util.cc
parent6ea9b656cd9aeedcf6537509d781dec47efb298f (diff)
downloadchromium_src-0db124b0b4d60f0c5780ec1dbb52717386097388.zip
chromium_src-0db124b0b4d60f0c5780ec1dbb52717386097388.tar.gz
chromium_src-0db124b0b4d60f0c5780ec1dbb52717386097388.tar.bz2
First couple of steps of improving the extension/app update process.
For Apps and Extensions with a lazy background page, this will delay installing an update until the background page gets unloaded (or next chrome restart). Also adds a chrome.runtime.onUpdateAvailable event which is fired when an update is available but isn't being installed immediately because the app is not idle. It doesn't change anything yet for Extensions with a persistent background page (or extensions without a background page at all). Those still get updated as soon as an update is found. BUG=37971 BUG=143260 TBR=nick@chromium.org Review URL: https://chromiumcodereview.appspot.com/11293002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_file_util.cc')
-rw-r--r--chrome/common/extensions/extension_file_util.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index 137536c..7d857b5 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -422,7 +422,7 @@ bool ValidateExtension(const Extension* extension,
void GarbageCollectExtensions(
const FilePath& install_directory,
- const std::map<std::string, FilePath>& extension_paths) {
+ const std::multimap<std::string, FilePath>& extension_paths) {
// Nothing to clean up if it doesn't exist.
if (!file_util::DirectoryExists(install_directory))
return;
@@ -461,13 +461,13 @@ void GarbageCollectExtensions(
continue;
}
- std::map<std::string, FilePath>::const_iterator iter =
- extension_paths.find(extension_id);
+ typedef std::multimap<std::string, FilePath>::const_iterator Iter;
+ std::pair<Iter, Iter> iter_pair = extension_paths.equal_range(extension_id);
// If there is no entry in the prefs file, just delete the directory and
// move on. This can legitimately happen when an uninstall does not
// complete, for example, when a plugin is in use at uninstall time.
- if (iter == extension_paths.end()) {
+ if (iter_pair.first == iter_pair.second) {
DVLOG(1) << "Deleting unreferenced install for directory "
<< extension_path.LossyDisplayName() << ".";
file_util::Delete(extension_path, true); // Recursive.
@@ -482,7 +482,13 @@ void GarbageCollectExtensions(
for (FilePath version_dir = versions_enumerator.Next();
!version_dir.value().empty();
version_dir = versions_enumerator.Next()) {
- if (version_dir.BaseName() != iter->second.BaseName()) {
+ bool knownVersion = false;
+ for (Iter it = iter_pair.first; it != iter_pair.second; ++it)
+ if (version_dir.BaseName() == it->second.BaseName()) {
+ knownVersion = true;
+ break;
+ }
+ if (!knownVersion) {
DVLOG(1) << "Deleting old version for directory "
<< version_dir.LossyDisplayName() << ".";
file_util::Delete(version_dir, true); // Recursive.