| 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 #include "chrome/browser/apps/ephemeral_app_service.h" | 5 #include "chrome/browser/apps/ephemeral_app_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/apps/ephemeral_app_service_factory.h" | 8 #include "chrome/browser/apps/ephemeral_app_service_factory.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 delay, | 145 delay, |
| 146 this, | 146 this, |
| 147 &EphemeralAppService::GarbageCollectApps); | 147 &EphemeralAppService::GarbageCollectApps); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void EphemeralAppService::GarbageCollectApps() { | 150 void EphemeralAppService::GarbageCollectApps() { |
| 151 ExtensionSystem* system = ExtensionSystem::Get(profile_); | 151 ExtensionSystem* system = ExtensionSystem::Get(profile_); |
| 152 DCHECK(system); | 152 DCHECK(system); |
| 153 ExtensionService* service = system->extension_service(); | 153 ExtensionService* service = system->extension_service(); |
| 154 DCHECK(service); | 154 DCHECK(service); |
| 155 ExtensionPrefs* prefs = service->extension_prefs(); | 155 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
| 156 scoped_ptr<ExtensionSet> extensions = | 156 scoped_ptr<ExtensionSet> extensions = |
| 157 service->GenerateInstalledExtensionsSet(); | 157 service->GenerateInstalledExtensionsSet(); |
| 158 | 158 |
| 159 int app_count = 0; | 159 int app_count = 0; |
| 160 LaunchTimeAppMap app_launch_times; | 160 LaunchTimeAppMap app_launch_times; |
| 161 std::set<std::string> remove_app_ids; | 161 std::set<std::string> remove_app_ids; |
| 162 | 162 |
| 163 // Populate a list of ephemeral apps, ordered by their last launch time. | 163 // Populate a list of ephemeral apps, ordered by their last launch time. |
| 164 for (ExtensionSet::const_iterator it = extensions->begin(); | 164 for (ExtensionSet::const_iterator it = extensions->begin(); |
| 165 it != extensions->end(); ++it) { | 165 it != extensions->end(); ++it) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // Remove ephemeral apps that have been inactive for a while or if the cache | 219 // Remove ephemeral apps that have been inactive for a while or if the cache |
| 220 // is larger than the desired size. | 220 // is larger than the desired size. |
| 221 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { | 221 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { |
| 222 remove_app_ids->insert(it->second); | 222 remove_app_ids->insert(it->second); |
| 223 --app_count; | 223 --app_count; |
| 224 } else { | 224 } else { |
| 225 break; | 225 break; |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |