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 "apps/app_lifetime_monitor_factory.h" | 7 #include "apps/app_lifetime_monitor_factory.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/apps/ephemeral_app_service_factory.h" | 10 #include "chrome/browser/apps/ephemeral_app_service_factory.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 void EphemeralAppService::Init() { | 184 void EphemeralAppService::Init() { |
185 InitEphemeralAppCount(); | 185 InitEphemeralAppCount(); |
186 | 186 |
187 // Start observing. | 187 // Start observing. |
188 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 188 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
189 app_lifetime_monitor_observer_.Add( | 189 app_lifetime_monitor_observer_.Add( |
190 apps::AppLifetimeMonitorFactory::GetForProfile(profile_)); | 190 apps::AppLifetimeMonitorFactory::GetForProfile(profile_)); |
191 | 191 |
192 // Execute startup clean up tasks (except during tests). | 192 // Execute startup clean up tasks (except during tests). |
193 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | 193 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
194 return; | 194 return; |
195 | 195 |
196 TriggerGarbageCollect( | 196 TriggerGarbageCollect( |
197 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay)); | 197 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay)); |
198 | 198 |
199 base::MessageLoop::current()->PostDelayedTask( | 199 base::MessageLoop::current()->PostDelayedTask( |
200 FROM_HERE, | 200 FROM_HERE, |
201 base::Bind(&EphemeralAppService::DisableEphemeralAppsOnStartup, | 201 base::Bind(&EphemeralAppService::DisableEphemeralAppsOnStartup, |
202 weak_ptr_factory_.GetWeakPtr()), | 202 weak_ptr_factory_.GetWeakPtr()), |
203 base::TimeDelta::FromSeconds(kDisableAppsOnStartupDelay)); | 203 base::TimeDelta::FromSeconds(kDisableAppsOnStartupDelay)); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // Remove ephemeral apps that have been inactive for a while or if the cache | 379 // Remove ephemeral apps that have been inactive for a while or if the cache |
380 // is larger than the desired size. | 380 // is larger than the desired size. |
381 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { | 381 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { |
382 remove_app_ids->insert(it->second); | 382 remove_app_ids->insert(it->second); |
383 --app_count; | 383 --app_count; |
384 } else { | 384 } else { |
385 break; | 385 break; |
386 } | 386 } |
387 } | 387 } |
388 } | 388 } |
OLD | NEW |