Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / drive / drive_notification_manager_factory.cc
blobbec2c9ca8972dfb44fc25b791a16ebad1fddca27
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/invalidation_service_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/keyed_service/content/browser_context_dependency_manager.h"
15 namespace drive {
17 // static
18 DriveNotificationManager*
19 DriveNotificationManagerFactory::FindForBrowserContext(
20 content::BrowserContext* context) {
21 return static_cast<DriveNotificationManager*>(
22 GetInstance()->GetServiceForBrowserContext(context, false));
25 // static
26 DriveNotificationManager*
27 DriveNotificationManagerFactory::GetForBrowserContext(
28 content::BrowserContext* context) {
29 if (!ProfileSyncService::IsSyncEnabled())
30 return NULL;
31 if (!invalidation::InvalidationServiceFactory::GetForProfile(
32 Profile::FromBrowserContext(context))) {
33 // Do not create a DriveNotificationManager for |context|s that do not
34 // support invalidation.
35 return NULL;
38 return static_cast<DriveNotificationManager*>(
39 GetInstance()->GetServiceForBrowserContext(context, true));
42 // static
43 DriveNotificationManagerFactory*
44 DriveNotificationManagerFactory::GetInstance() {
45 return Singleton<DriveNotificationManagerFactory>::get();
48 DriveNotificationManagerFactory::DriveNotificationManagerFactory()
49 : BrowserContextKeyedServiceFactory(
50 "DriveNotificationManager",
51 BrowserContextDependencyManager::GetInstance()) {
52 DependsOn(ProfileSyncServiceFactory::GetInstance());
53 DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
56 DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
58 KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
59 content::BrowserContext* context) const {
60 invalidation::InvalidationService* invalidation_service =
61 invalidation::InvalidationServiceFactory::GetForProfile(
62 Profile::FromBrowserContext(context));
63 DCHECK(invalidation_service);
64 return new DriveNotificationManager(invalidation_service);
67 } // namespace drive