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

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

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
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 #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/location.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/apps/ephemeral_app_service_factory.h" 12 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
11 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_util.h" 14 #include "chrome/browser/extensions/extension_util.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
15 #include "extensions/browser/extension_prefs.h" 17 #include "extensions/browser/extension_prefs.h"
16 #include "extensions/browser/extension_registry.h" 18 #include "extensions/browser/extension_registry.h"
17 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
18 #include "extensions/browser/extension_util.h" 20 #include "extensions/browser/extension_util.h"
19 #include "extensions/browser/uninstall_reason.h" 21 #include "extensions/browser/uninstall_reason.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 --ephemeral_app_count_; 143 --ephemeral_app_count_;
142 DCHECK_GE(ephemeral_app_count_, 0); 144 DCHECK_GE(ephemeral_app_count_, 0);
143 } 145 }
144 } 146 }
145 147
146 void EphemeralAppService::OnAppStop(Profile* profile, 148 void EphemeralAppService::OnAppStop(Profile* profile,
147 const std::string& app_id) { 149 const std::string& app_id) {
148 if (!extensions::util::IsEphemeralApp(app_id, profile_)) 150 if (!extensions::util::IsEphemeralApp(app_id, profile_))
149 return; 151 return;
150 152
151 base::MessageLoop::current()->PostDelayedTask( 153 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
152 FROM_HERE, 154 FROM_HERE, base::Bind(&EphemeralAppService::DisableEphemeralApp,
153 base::Bind(&EphemeralAppService::DisableEphemeralApp, 155 weak_ptr_factory_.GetWeakPtr(), app_id),
154 weak_ptr_factory_.GetWeakPtr(),
155 app_id),
156 base::TimeDelta::FromSeconds(disable_idle_app_delay_)); 156 base::TimeDelta::FromSeconds(disable_idle_app_delay_));
157 } 157 }
158 158
159 void EphemeralAppService::OnChromeTerminating() { 159 void EphemeralAppService::OnChromeTerminating() {
160 garbage_collect_apps_timer_.Stop(); 160 garbage_collect_apps_timer_.Stop();
161 161
162 extension_registry_observer_.RemoveAll(); 162 extension_registry_observer_.RemoveAll();
163 app_lifetime_monitor_observer_.RemoveAll(); 163 app_lifetime_monitor_observer_.RemoveAll();
164 } 164 }
165 165
166 void EphemeralAppService::Init() { 166 void EphemeralAppService::Init() {
167 InitEphemeralAppCount(); 167 InitEphemeralAppCount();
168 168
169 // Start observing. 169 // Start observing.
170 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 170 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
171 app_lifetime_monitor_observer_.Add( 171 app_lifetime_monitor_observer_.Add(
172 apps::AppLifetimeMonitorFactory::GetForProfile(profile_)); 172 apps::AppLifetimeMonitorFactory::GetForProfile(profile_));
173 173
174 // Execute startup clean up tasks (except during tests). 174 // Execute startup clean up tasks (except during tests).
175 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) 175 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType))
176 return; 176 return;
177 177
178 TriggerGarbageCollect( 178 TriggerGarbageCollect(
179 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay)); 179 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay));
180 180
181 base::MessageLoop::current()->PostDelayedTask( 181 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
182 FROM_HERE, 182 FROM_HERE, base::Bind(&EphemeralAppService::DisableEphemeralAppsOnStartup,
183 base::Bind(&EphemeralAppService::DisableEphemeralAppsOnStartup, 183 weak_ptr_factory_.GetWeakPtr()),
184 weak_ptr_factory_.GetWeakPtr()),
185 base::TimeDelta::FromSeconds(kDisableAppsOnStartupDelay)); 184 base::TimeDelta::FromSeconds(kDisableAppsOnStartupDelay));
186 } 185 }
187 186
188 void EphemeralAppService::InitEphemeralAppCount() { 187 void EphemeralAppService::InitEphemeralAppCount() {
189 scoped_ptr<ExtensionSet> extensions = 188 scoped_ptr<ExtensionSet> extensions =
190 ExtensionRegistry::Get(profile_)->GenerateInstalledExtensionsSet(); 189 ExtensionRegistry::Get(profile_)->GenerateInstalledExtensionsSet();
191 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); 190 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
192 DCHECK(prefs); 191 DCHECK(prefs);
193 192
194 ephemeral_app_count_ = 0; 193 ephemeral_app_count_ = 0;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // Remove ephemeral apps that have been inactive for a while or if the cache 360 // Remove ephemeral apps that have been inactive for a while or if the cache
362 // is larger than the desired size. 361 // is larger than the desired size.
363 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) { 362 if (it->first < inactive_threshold || app_count > kMaxEphemeralAppsCount) {
364 remove_app_ids->insert(it->second); 363 remove_app_ids->insert(it->second);
365 --app_count; 364 --app_count;
366 } else { 365 } else {
367 break; 366 break;
368 } 367 }
369 } 368 }
370 } 369 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/drive/drive_app_provider.cc ('k') | chrome/browser/apps/guest_view/web_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698