OLD | NEW |
---|---|
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> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 // Constants exposed for testing purposes: | 39 // Constants exposed for testing purposes: |
40 | 40 |
41 // The number of days of inactivity before an ephemeral app will be removed. | 41 // The number of days of inactivity before an ephemeral app will be removed. |
42 static const int kAppInactiveThreshold; | 42 static const int kAppInactiveThreshold; |
43 // If the ephemeral app has been launched within this number of days, it will | 43 // If the ephemeral app has been launched within this number of days, it will |
44 // definitely not be garbage collected. | 44 // definitely not be garbage collected. |
45 static const int kAppKeepThreshold; | 45 static const int kAppKeepThreshold; |
46 // The maximum number of ephemeral apps to keep cached. Excess may be removed. | 46 // The maximum number of ephemeral apps to keep cached. Excess may be removed. |
47 static const int kMaxEphemeralAppsCount; | 47 static const int kMaxEphemeralAppsCount; |
48 // The number of days of inactivity before the data of an already evicted | |
49 // ephemeral app will be removed. | |
50 static const int kDataInactiveThreshold; | |
benwells
2014/06/18 00:21:47
If we just change the value of this constant, woul
tmdiep
2014/06/18 01:04:57
Not identical as the data garbage collection only
| |
51 | 48 |
52 private: | 49 private: |
53 // A map used to order the ephemeral apps by their last launch time. | 50 // A map used to order the ephemeral apps by their last launch time. |
54 typedef std::multimap<base::Time, std::string> LaunchTimeAppMap; | 51 typedef std::multimap<base::Time, std::string> LaunchTimeAppMap; |
55 | 52 |
56 // content::NotificationObserver implementation. | 53 // content::NotificationObserver implementation. |
57 virtual void Observe(int type, | 54 virtual void Observe(int type, |
58 const content::NotificationSource& source, | 55 const content::NotificationSource& source, |
59 const content::NotificationDetails& details) OVERRIDE; | 56 const content::NotificationDetails& details) OVERRIDE; |
60 | 57 |
(...skipping 11 matching lines...) Expand all Loading... | |
72 void Init(); | 69 void Init(); |
73 void InitEphemeralAppCount(); | 70 void InitEphemeralAppCount(); |
74 | 71 |
75 // Garbage collect ephemeral apps. | 72 // Garbage collect ephemeral apps. |
76 void TriggerGarbageCollect(const base::TimeDelta& delay); | 73 void TriggerGarbageCollect(const base::TimeDelta& delay); |
77 void GarbageCollectApps(); | 74 void GarbageCollectApps(); |
78 static void GetAppsToRemove(int app_count, | 75 static void GetAppsToRemove(int app_count, |
79 const LaunchTimeAppMap& app_launch_times, | 76 const LaunchTimeAppMap& app_launch_times, |
80 std::set<std::string>* remove_app_ids); | 77 std::set<std::string>* remove_app_ids); |
81 | 78 |
82 // Garbage collect the data of ephemeral apps that have been evicted and | |
83 // inactive for a long period of time. | |
84 void GarbageCollectData(); | |
85 | |
86 Profile* profile_; | 79 Profile* profile_; |
87 | 80 |
88 content::NotificationRegistrar registrar_; | 81 content::NotificationRegistrar registrar_; |
89 | |
90 ScopedObserver<extensions::ExtensionRegistry, | 82 ScopedObserver<extensions::ExtensionRegistry, |
91 extensions::ExtensionRegistryObserver> | 83 extensions::ExtensionRegistryObserver> |
92 extension_registry_observer_; | 84 extension_registry_observer_; |
93 | 85 |
94 base::OneShotTimer<EphemeralAppService> garbage_collect_apps_timer_; | 86 base::OneShotTimer<EphemeralAppService> garbage_collect_apps_timer_; |
95 base::OneShotTimer<EphemeralAppService> garbage_collect_data_timer_; | |
96 | 87 |
97 // The count of cached ephemeral apps. | 88 // The count of cached ephemeral apps. |
98 int ephemeral_app_count_; | 89 int ephemeral_app_count_; |
99 | 90 |
100 friend class EphemeralAppBrowserTest; | |
101 friend class EphemeralAppServiceTest; | 91 friend class EphemeralAppServiceTest; |
102 friend class EphemeralAppServiceBrowserTest; | 92 friend class EphemeralAppServiceBrowserTest; |
103 | 93 |
104 DISALLOW_COPY_AND_ASSIGN(EphemeralAppService); | 94 DISALLOW_COPY_AND_ASSIGN(EphemeralAppService); |
105 }; | 95 }; |
106 | 96 |
107 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_ | 97 #endif // CHROME_BROWSER_APPS_EPHEMERAL_APP_SERVICE_H_ |
OLD | NEW |