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

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

Issue 389613006: Prevent duplicate concurrent installs of the same extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed update of webstore_result Created 6 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/extensions/active_install_data.h
diff --git a/chrome/browser/extensions/active_install_data.h b/chrome/browser/extensions/active_install_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..e8c04a2c992855133217d765960bbac740e5ce8e
--- /dev/null
+++ b/chrome/browser/extensions/active_install_data.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_
+#define CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/scoped_observer.h"
+#include "chrome/browser/extensions/install_observer.h"
+
+class Profile;
+
+namespace extensions {
+
+class InstallTracker;
+
+// Details of an active extension install.
+struct ActiveInstallData {
+ public:
+ ActiveInstallData();
+ explicit ActiveInstallData(const std::string& extension_id);
+
+ std::string extension_id;
+ int percent_downloaded;
+ bool is_ephemeral;
+};
+
+// Registers and deregisters and an active extension install with the
+// InstallTracker.
+class ScopedActiveInstall : public InstallObserver {
+ public:
+ // This constructor registers an active install with the InstallTracker.
+ ScopedActiveInstall(InstallTracker* tracker,
+ const ActiveInstallData& install_data);
+
+ // This constructor does not register an active install. The extension install
+ // is still deregistered upon destruction.
+ ScopedActiveInstall(InstallTracker* tracker, const std::string& extension_id);
+
+ virtual ~ScopedActiveInstall();
+
+ // Ensures that the active install is not deregistered upon destruction. This
+ // may be necessary if the extension install outlives the lifetime of this
+ // instance.
+ void CancelDeregister();
+
+ private:
+ void Init();
+
+ // InstallObserver implementation.
+ virtual void OnShutdown() OVERRIDE;
+
+ InstallTracker* tracker_;
+ ScopedObserver<InstallTracker, InstallObserver> tracker_observer_;
+ std::string extension_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedActiveInstall);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_
« no previous file with comments | « chrome/browser/apps/ephemeral_app_launcher_browsertest.cc ('k') | chrome/browser/extensions/active_install_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698