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

Unified Diff: chrome/browser/apps/ephemeral_app_service.h

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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/apps/ephemeral_app_service.h
diff --git a/chrome/browser/apps/ephemeral_app_service.h b/chrome/browser/apps/ephemeral_app_service.h
index ede710a63624489179cb236f2531edf1b3e7cc35..be96c6810ac66ea9d062b3c2347ae7c49fa2c6e0 100644
--- a/chrome/browser/apps/ephemeral_app_service.h
+++ b/chrome/browser/apps/ephemeral_app_service.h
@@ -8,6 +8,8 @@
#include <map>
#include <set>
+#include "apps/app_lifetime_monitor.h"
+#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/timer/timer.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -25,7 +27,8 @@ class ExtensionRegistry;
// Performs the background garbage collection of ephemeral apps.
class EphemeralAppService : public KeyedService,
public content::NotificationObserver,
- public extensions::ExtensionRegistryObserver {
+ public extensions::ExtensionRegistryObserver,
+ public apps::AppLifetimeMonitor::Observer {
public:
// Returns the instance for the given profile. This is a convenience wrapper
// around EphemeralAppServiceFactory::GetForProfile.
@@ -39,6 +42,8 @@ class EphemeralAppService : public KeyedService,
int ephemeral_app_count() const { return ephemeral_app_count_; }
+ void set_unload_delay_for_test(int delay) { unload_idle_app_delay_ = delay; }
+
// Constants exposed for testing purposes:
// The number of days of inactivity before an ephemeral app will be removed.
@@ -70,9 +75,18 @@ class EphemeralAppService : public KeyedService,
const extensions::Extension* extension,
extensions::UninstallReason reason) OVERRIDE;
+ // apps::AppLifetimeMonitor::Observer implementation.
+ virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE;
+ virtual void OnChromeTerminating() OVERRIDE;
+
void Init();
void InitEphemeralAppCount();
+ void UnloadEphemeralApp(const std::string& app_id);
+ void UnloadEphemeralAppsOnStartup();
+
+ void HandleEphemeralAppPromoted(const extensions::Extension* app);
+
// Garbage collect ephemeral apps.
void TriggerGarbageCollect(const base::TimeDelta& delay);
void GarbageCollectApps();
@@ -92,6 +106,12 @@ class EphemeralAppService : public KeyedService,
// The count of cached ephemeral apps.
int ephemeral_app_count_;
+ // Number of seconds before unloading idle ephemeral apps.
+ // Overridden in tests.
+ int unload_idle_app_delay_;
+
+ base::WeakPtrFactory<EphemeralAppService> weak_ptr_factory_;
+
friend class EphemeralAppServiceTest;
friend class EphemeralAppServiceBrowserTest;

Powered by Google App Engine
This is Rietveld 408576698