OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/scoped_observer.h" |
| 12 #include "chrome/browser/extensions/install_observer.h" |
| 13 |
| 14 class Profile; |
| 15 |
| 16 namespace extensions { |
| 17 |
| 18 class InstallTracker; |
| 19 |
| 20 // Details of an active extension install. |
| 21 struct ActiveInstallData { |
| 22 public: |
| 23 ActiveInstallData(); |
| 24 explicit ActiveInstallData(const std::string& extension_id); |
| 25 |
| 26 std::string extension_id; |
| 27 int percent_downloaded; |
| 28 bool is_ephemeral; |
| 29 }; |
| 30 |
| 31 // Registers and deregisters and an active extension install with the |
| 32 // InstallTracker. |
| 33 class ScopedActiveInstall : public InstallObserver { |
| 34 public: |
| 35 // This constructor registers an active install with the InstallTracker. |
| 36 ScopedActiveInstall(InstallTracker* tracker, |
| 37 const ActiveInstallData& install_data); |
| 38 |
| 39 // This constructor does not register an active install. The extension install |
| 40 // is still deregistered upon destruction. |
| 41 ScopedActiveInstall(InstallTracker* tracker, const std::string& extension_id); |
| 42 |
| 43 virtual ~ScopedActiveInstall(); |
| 44 |
| 45 // Ensures that the active install is not deregistered upon destruction. This |
| 46 // may be necessary if the extension install outlives the lifetime of this |
| 47 // instance. |
| 48 void CancelDeregister(); |
| 49 |
| 50 private: |
| 51 void Init(); |
| 52 |
| 53 // InstallObserver implementation. |
| 54 virtual void OnShutdown() OVERRIDE; |
| 55 |
| 56 InstallTracker* tracker_; |
| 57 ScopedObserver<InstallTracker, InstallObserver> tracker_observer_; |
| 58 std::string extension_id_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ScopedActiveInstall); |
| 61 }; |
| 62 |
| 63 } // namespace extensions |
| 64 |
| 65 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_INSTALL_DATA_H_ |
OLD | NEW |