Give names to all utility processes.
[chromium-blink-merge.git] / chrome / browser / drive / drive_notification_manager_factory.cc
blobae63f36eca71336b7182403f40fa6a8f0e6938ce
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
3 // found in the LICENSE file.
5 #include "chrome/browser/drive/drive_notification_manager_factory.h"
7 #include "base/logging.h"
8 #include "chrome/browser/drive/drive_notification_manager.h"
9 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "components/invalidation/profile_invalidation_provider.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 namespace drive {
18 // static
19 DriveNotificationManager*
20 DriveNotificationManagerFactory::FindForBrowserContext(
21 content::BrowserContext* context) {
22 return static_cast<DriveNotificationManager*>(
23 GetInstance()->GetServiceForBrowserContext(context, false));
26 // static
27 DriveNotificationManager*
28 DriveNotificationManagerFactory::GetForBrowserContext(
29 content::BrowserContext* context) {
30 if (!ProfileSyncService::IsSyncEnabled())
31 return NULL;
32 if (!invalidation::ProfileInvalidationProviderFactory::GetForProfile(
33 Profile::FromBrowserContext(context))) {
34 // Do not create a DriveNotificationManager for |context|s that do not
35 // support invalidation.
36 return NULL;
39 return static_cast<DriveNotificationManager*>(
40 GetInstance()->GetServiceForBrowserContext(context, true));
43 // static
44 DriveNotificationManagerFactory*
45 DriveNotificationManagerFactory::GetInstance() {
46 return Singleton<DriveNotificationManagerFactory>::get();
49 DriveNotificationManagerFactory::DriveNotificationManagerFactory()
50 : BrowserContextKeyedServiceFactory(
51 "DriveNotificationManager",
52 BrowserContextDependencyManager::GetInstance()) {
53 DependsOn(ProfileSyncServiceFactory::GetInstance());
54 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
57 DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
59 KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
60 content::BrowserContext* context) const {
61 invalidation::ProfileInvalidationProvider* invalidation_provider =
62 invalidation::ProfileInvalidationProviderFactory::GetForProfile(
63 Profile::FromBrowserContext(context));
64 DCHECK(invalidation_provider);
65 DCHECK(invalidation_provider->GetInvalidationService());
66 return new DriveNotificationManager(
67 invalidation_provider->GetInvalidationService());
70 } // namespace drive