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

Unified Diff: chrome/browser/extensions/extension_updater.h

Issue 6965018: Install CRX updates one at a time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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/extensions/extension_updater.h
diff --git a/chrome/browser/extensions/extension_updater.h b/chrome/browser/extensions/extension_updater.h
index f6806f745950cf72153599ce08517ef2777a7f4b..a010fc2332736944ba2b84fcd9f93b5015ecd1d0 100644
--- a/chrome/browser/extensions/extension_updater.h
+++ b/chrome/browser/extensions/extension_updater.h
@@ -9,6 +9,7 @@
#include <deque>
#include <map>
#include <set>
+#include <stack>
#include <string>
#include <vector>
@@ -164,7 +165,8 @@ class ManifestFetchesBuilder {
// updater->Start();
// ....
// updater->Stop();
-class ExtensionUpdater : public URLFetcher::Delegate {
+class ExtensionUpdater : public URLFetcher::Delegate,
+ public NotificationObserver {
public:
// Holds a pointer to the passed |service|, using it for querying installed
// extensions and installing updated ones. The |frequency_seconds| parameter
@@ -221,6 +223,19 @@ class ExtensionUpdater : public URLFetcher::Delegate {
std::string version;
};
+ // FetchedCrxFile holds information about a CRX file we fetched to disk,
+ // but have not yet installed.
+ struct FetchedCrxFile {
Matt Perry 2011/05/31 21:34:25 I think the implementation of this can be moved to
Matt Perry 2011/05/31 21:34:25 Put CRX in caps for consistency. Same with other m
Sam Kerner (Chrome) 2011/05/31 23:16:15 Done.
Sam Kerner (Chrome) 2011/05/31 23:16:15 Done.
+ FetchedCrxFile();
+ FetchedCrxFile(const std::string& id,
+ const FilePath& path,
+ const GURL& download_url);
+ ~FetchedCrxFile();
+ std::string id;
+ FilePath path;
+ GURL download_url;
+ };
+
// These are needed for unit testing, to help identify the correct mock
// URLFetcher objects.
static const int kManifestFetcherId = 1;
@@ -310,6 +325,16 @@ class ExtensionUpdater : public URLFetcher::Delegate {
// Removes a set of ids from in_progress_ids_.
void RemoveFromInProgress(const std::set<std::string>& ids);
+ // If a CRX file has been fetched but not installed, and no install is
+ // currently running, start installing. Returns true if an install was
+ // started.
+ bool MaybeUpdateCrxFile();
Matt Perry 2011/05/31 21:34:25 I think MaybeInstallCRXFile would mke more sense.
Sam Kerner (Chrome) 2011/05/31 23:16:15 Done.
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Whether Start() has been called but not Stop().
bool alive_;
@@ -324,6 +349,7 @@ class ExtensionUpdater : public URLFetcher::Delegate {
std::deque<ManifestFetchData*> manifests_pending_;
std::deque<ExtensionFetch> extensions_pending_;
Matt Perry 2011/05/31 21:34:25 nit: remove extra newline
Sam Kerner (Chrome) 2011/05/31 23:16:15 Done.
+
// The manifest currently being fetched (if any).
scoped_ptr<ManifestFetchData> current_manifest_fetch_;
@@ -348,6 +374,16 @@ class ExtensionUpdater : public URLFetcher::Delegate {
// The ids of extensions that have in-progress update checks.
std::set<std::string> in_progress_ids_;
+ // Observes CRX installs we initiate.
+ NotificationRegistrar registrar_;
+
+ // True when a CrxInstaller is doing an install. Used in MaybeUpdateCrxFile()
+ // to keep more than one install from running at once.
+ bool crx_install_is_running_;
+
+ // Fetched CRX files waiting to be installed.
+ std::stack<FetchedCrxFile> fetched_crx_files_;
+
FRIEND_TEST(ExtensionUpdaterTest, TestStartUpdateCheckMemory);
FRIEND_TEST(ExtensionUpdaterTest, TestAfterStopBehavior);

Powered by Google App Engine
This is Rietveld 408576698