Chromium Code Reviews| Index: chrome/browser/push_messaging/background_budget_service_factory.cc |
| diff --git a/chrome/browser/push_messaging/background_budget_service_factory.cc b/chrome/browser/push_messaging/background_budget_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aeca47038eeb35be3acf83329d93a99b1d828dd5 |
| --- /dev/null |
| +++ b/chrome/browser/push_messaging/background_budget_service_factory.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/push_messaging/background_budget_service_factory.h" |
| + |
| +#include "chrome/browser/engagement/site_engagement_service_factory.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/push_messaging/background_budget_service.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "content/public/browser/browser_context.h" |
| + |
| +// static |
| +BackgroundBudgetService* BackgroundBudgetServiceFactory::GetForProfile( |
| + content::BrowserContext* profile) { |
| + // Budget tracking is not supported in incognito mode. |
| + if (profile->IsOffTheRecord()) |
| + return NULL; |
|
Michael van Ouwerkerk
2016/04/14 14:36:31
nit: s/NULL/nullptr/
harkness
2016/04/14 17:44:19
Done.
|
| + |
| + return static_cast<BackgroundBudgetService*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| +} |
| + |
| +// static |
| +BackgroundBudgetServiceFactory* BackgroundBudgetServiceFactory::GetInstance() { |
| + return base::Singleton<BackgroundBudgetServiceFactory>::get(); |
| +} |
| + |
| +BackgroundBudgetServiceFactory::BackgroundBudgetServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "BackgroundBudgetService", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn(SiteEngagementServiceFactory::GetInstance()); |
|
Peter Beverloo
2016/04/14 16:01:18
PushMessagingServiceFactory should declare a depen
harkness
2016/04/14 17:44:19
Done.
|
| +} |
| + |
| +KeyedService* BackgroundBudgetServiceFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* profile) const { |
| + return new BackgroundBudgetService(static_cast<Profile*>(profile)); |
| +} |