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

Side by Side Diff: chrome/browser/apps/ephemeral_app_service.h

Issue 1102193002: Remove NOTIFICATION_EXTENSIONS_READY from ephemeral_app_service.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_ 5 #ifndef CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_
6 #define CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_ 6 #define CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_
7 7
8 #include <map>
9 #include <set> 8 #include <set>
10 9
11 #include "apps/app_lifetime_monitor.h" 10 #include "apps/app_lifetime_monitor.h"
12 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
14 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
15 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "extensions/browser/extension_registry_observer.h" 15 #include "extensions/browser/extension_registry_observer.h"
19 16
20 class Profile; 17 class Profile;
21 18
22 namespace extensions { 19 namespace extensions {
23 class Extension; 20 class Extension;
24 class ExtensionRegistry; 21 class ExtensionRegistry;
25 } // namespace extensions 22 } // namespace extensions
26 23
27 // Performs the background garbage collection of ephemeral apps. 24 // Performs the background garbage collection of ephemeral apps.
28 class EphemeralAppService : public KeyedService, 25 class EphemeralAppService : public KeyedService,
29 public content::NotificationObserver,
30 public extensions::ExtensionRegistryObserver, 26 public extensions::ExtensionRegistryObserver,
31 public apps::AppLifetimeMonitor::Observer { 27 public apps::AppLifetimeMonitor::Observer {
32 public: 28 public:
33 // Returns the instance for the given profile. This is a convenience wrapper 29 // Returns the instance for the given profile. This is a convenience wrapper
34 // around EphemeralAppServiceFactory::GetForProfile. 30 // around EphemeralAppServiceFactory::GetForProfile.
35 static EphemeralAppService* Get(Profile* profile); 31 static EphemeralAppService* Get(Profile* profile);
36 32
37 explicit EphemeralAppService(Profile* profile); 33 explicit EphemeralAppService(Profile* profile);
38 ~EphemeralAppService() override; 34 ~EphemeralAppService() override;
39 35
(...skipping 13 matching lines...) Expand all
53 // If the ephemeral app has been launched within this number of days, it will 49 // If the ephemeral app has been launched within this number of days, it will
54 // definitely not be garbage collected. 50 // definitely not be garbage collected.
55 static const int kAppKeepThreshold; 51 static const int kAppKeepThreshold;
56 // The maximum number of ephemeral apps to keep cached. Excess may be removed. 52 // The maximum number of ephemeral apps to keep cached. Excess may be removed.
57 static const int kMaxEphemeralAppsCount; 53 static const int kMaxEphemeralAppsCount;
58 54
59 private: 55 private:
60 // A map used to order the ephemeral apps by their last launch time. 56 // A map used to order the ephemeral apps by their last launch time.
61 typedef std::multimap<base::Time, std::string> LaunchTimeAppMap; 57 typedef std::multimap<base::Time, std::string> LaunchTimeAppMap;
62 58
63 // content::NotificationObserver implementation.
64 void Observe(int type,
65 const content::NotificationSource& source,
66 const content::NotificationDetails& details) override;
67
68 // extensions::ExtensionRegistryObserver. 59 // extensions::ExtensionRegistryObserver.
69 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, 60 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
70 const extensions::Extension* extension, 61 const extensions::Extension* extension,
71 bool is_update, 62 bool is_update,
72 bool from_ephemeral, 63 bool from_ephemeral,
73 const std::string& old_name) override; 64 const std::string& old_name) override;
74 void OnExtensionUninstalled(content::BrowserContext* browser_context, 65 void OnExtensionUninstalled(content::BrowserContext* browser_context,
75 const extensions::Extension* extension, 66 const extensions::Extension* extension,
76 extensions::UninstallReason reason) override; 67 extensions::UninstallReason reason) override;
77 68
(...skipping 11 matching lines...) Expand all
89 80
90 // Garbage collect ephemeral apps. 81 // Garbage collect ephemeral apps.
91 void TriggerGarbageCollect(const base::TimeDelta& delay); 82 void TriggerGarbageCollect(const base::TimeDelta& delay);
92 void GarbageCollectApps(); 83 void GarbageCollectApps();
93 static void GetAppsToRemove(int app_count, 84 static void GetAppsToRemove(int app_count,
94 const LaunchTimeAppMap& app_launch_times, 85 const LaunchTimeAppMap& app_launch_times,
95 std::set<std::string>* remove_app_ids); 86 std::set<std::string>* remove_app_ids);
96 87
97 Profile* profile_; 88 Profile* profile_;
98 89
99 content::NotificationRegistrar registrar_;
100 ScopedObserver<extensions::ExtensionRegistry, 90 ScopedObserver<extensions::ExtensionRegistry,
101 extensions::ExtensionRegistryObserver> 91 extensions::ExtensionRegistryObserver>
102 extension_registry_observer_; 92 extension_registry_observer_;
103 ScopedObserver<apps::AppLifetimeMonitor, apps::AppLifetimeMonitor::Observer> 93 ScopedObserver<apps::AppLifetimeMonitor, apps::AppLifetimeMonitor::Observer>
104 app_lifetime_monitor_observer_; 94 app_lifetime_monitor_observer_;
105 95
106 base::OneShotTimer<EphemeralAppService> garbage_collect_apps_timer_; 96 base::OneShotTimer<EphemeralAppService> garbage_collect_apps_timer_;
107 97
108 // The count of cached ephemeral apps. 98 // The count of cached ephemeral apps.
109 int ephemeral_app_count_; 99 int ephemeral_app_count_;
110 100
111 // Number of seconds before disabling idle ephemeral apps. 101 // Number of seconds before disabling idle ephemeral apps.
112 // Overridden in tests. 102 // Overridden in tests.
113 int disable_idle_app_delay_; 103 int disable_idle_app_delay_;
114 104
115 base::WeakPtrFactory<EphemeralAppService> weak_ptr_factory_; 105 base::WeakPtrFactory<EphemeralAppService> weak_ptr_factory_;
116 106
117 friend class EphemeralAppServiceTest; 107 friend class EphemeralAppServiceTest;
118 friend class EphemeralAppServiceBrowserTest; 108 friend class EphemeralAppServiceBrowserTest;
119 109
120 DISALLOW_COPY_AND_ASSIGN(EphemeralAppService); 110 DISALLOW_COPY_AND_ASSIGN(EphemeralAppService);
121 }; 111 };
122 112
123 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_ 113 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/ephemeral_app_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698