17d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 27d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 37d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// found in the LICENSE file. 47d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 57d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#ifndef APPS_APP_LIFETIME_MONITOR_FACTORY_H_ 67d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#define APPS_APP_LIFETIME_MONITOR_FACTORY_H_ 77d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 87d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/memory/singleton.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_keyed_service_factory.h" 107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class Profile; 127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)namespace apps { 147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class AppLifetimeMonitor; 167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 177d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Singleton that owns all AppLifetimeMonitors and associates them with 187d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Profiles. Listens for the Profile's destruction notification and cleans up 197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// the associated AppLifetimeMonitor. 207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class AppLifetimeMonitorFactory : public BrowserContextKeyedServiceFactory { 217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) public: 227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) static AppLifetimeMonitor* GetForProfile(Profile* profile); 237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) static AppLifetimeMonitorFactory* GetInstance(); 257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) private: 277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) friend struct DefaultSingletonTraits<AppLifetimeMonitorFactory>; 287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) AppLifetimeMonitorFactory(); 307d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual ~AppLifetimeMonitorFactory(); 317d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 327d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // BrowserContextKeyedServiceFactory: 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual KeyedService* BuildServiceInstanceFor( 347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) content::BrowserContext* profile) const OVERRIDE; 357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; 367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) virtual content::BrowserContext* GetBrowserContextToUse( 377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) content::BrowserContext* context) const OVERRIDE; 387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)}; 397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} // namespace apps 417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif // APPS_APP_LIFETIME_MONITOR_FACTORY_H_ 43