Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/push_messaging/background_budget_service_factory.h" | |
| 6 | |
| 7 #include "chrome/browser/engagement/site_engagement_service_factory.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/push_messaging/background_budget_service.h" | |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 11 #include "content/public/browser/browser_context.h" | |
| 12 | |
| 13 // static | |
| 14 BackgroundBudgetService* BackgroundBudgetServiceFactory::GetForProfile( | |
| 15 content::BrowserContext* profile) { | |
| 16 // Budget tracking is not supported in incognito mode. | |
| 17 if (profile->IsOffTheRecord()) | |
|
Peter Beverloo
2016/04/15 12:22:24
Why not? The dependency (SiteEngagementServiceFact
| |
| 18 return nullptr; | |
| 19 | |
| 20 return static_cast<BackgroundBudgetService*>( | |
| 21 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
| 22 } | |
| 23 | |
| 24 // static | |
| 25 BackgroundBudgetServiceFactory* BackgroundBudgetServiceFactory::GetInstance() { | |
| 26 return base::Singleton<BackgroundBudgetServiceFactory>::get(); | |
| 27 } | |
| 28 | |
| 29 BackgroundBudgetServiceFactory::BackgroundBudgetServiceFactory() | |
| 30 : BrowserContextKeyedServiceFactory( | |
| 31 "BackgroundBudgetService", | |
| 32 BrowserContextDependencyManager::GetInstance()) { | |
| 33 DependsOn(SiteEngagementServiceFactory::GetInstance()); | |
| 34 } | |
| 35 | |
| 36 KeyedService* BackgroundBudgetServiceFactory::BuildServiceInstanceFor( | |
| 37 content::BrowserContext* profile) const { | |
| 38 return new BackgroundBudgetService(static_cast<Profile*>(profile)); | |
| 39 } | |
| OLD | NEW |