Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/drive/drive_notification_manager_factory.cc

Issue 327243003: Introduce ProfileInvalidationProvider wrapper for InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang compilation. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/drive/drive_notification_manager_factory.h" 5 #include "chrome/browser/drive/drive_notification_manager_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/drive/drive_notification_manager.h" 8 #include "chrome/browser/drive/drive_notification_manager.h"
9 #include "chrome/browser/invalidation/invalidation_service_factory.h" 9 #include "chrome/browser/invalidation/profile_invalidation_provider.h"
10 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h" 13 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" 14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 15
15 namespace drive { 16 namespace drive {
16 17
17 // static 18 // static
18 DriveNotificationManager* 19 DriveNotificationManager*
19 DriveNotificationManagerFactory::FindForBrowserContext( 20 DriveNotificationManagerFactory::FindForBrowserContext(
20 content::BrowserContext* context) { 21 content::BrowserContext* context) {
21 return static_cast<DriveNotificationManager*>( 22 return static_cast<DriveNotificationManager*>(
22 GetInstance()->GetServiceForBrowserContext(context, false)); 23 GetInstance()->GetServiceForBrowserContext(context, false));
23 } 24 }
24 25
25 // static 26 // static
26 DriveNotificationManager* 27 DriveNotificationManager*
27 DriveNotificationManagerFactory::GetForBrowserContext( 28 DriveNotificationManagerFactory::GetForBrowserContext(
28 content::BrowserContext* context) { 29 content::BrowserContext* context) {
29 if (!ProfileSyncService::IsSyncEnabled()) 30 if (!ProfileSyncService::IsSyncEnabled())
30 return NULL; 31 return NULL;
31 if (!invalidation::InvalidationServiceFactory::GetForProfile( 32 if (!invalidation::ProfileInvalidationProviderFactory::GetForProfile(
32 Profile::FromBrowserContext(context))) { 33 Profile::FromBrowserContext(context))) {
33 // Do not create a DriveNotificationManager for |context|s that do not 34 // Do not create a DriveNotificationManager for |context|s that do not
34 // support invalidation. 35 // support invalidation.
35 return NULL; 36 return NULL;
36 } 37 }
37 38
38 return static_cast<DriveNotificationManager*>( 39 return static_cast<DriveNotificationManager*>(
39 GetInstance()->GetServiceForBrowserContext(context, true)); 40 GetInstance()->GetServiceForBrowserContext(context, true));
40 } 41 }
41 42
42 // static 43 // static
43 DriveNotificationManagerFactory* 44 DriveNotificationManagerFactory*
44 DriveNotificationManagerFactory::GetInstance() { 45 DriveNotificationManagerFactory::GetInstance() {
45 return Singleton<DriveNotificationManagerFactory>::get(); 46 return Singleton<DriveNotificationManagerFactory>::get();
46 } 47 }
47 48
48 DriveNotificationManagerFactory::DriveNotificationManagerFactory() 49 DriveNotificationManagerFactory::DriveNotificationManagerFactory()
49 : BrowserContextKeyedServiceFactory( 50 : BrowserContextKeyedServiceFactory(
50 "DriveNotificationManager", 51 "DriveNotificationManager",
51 BrowserContextDependencyManager::GetInstance()) { 52 BrowserContextDependencyManager::GetInstance()) {
52 DependsOn(ProfileSyncServiceFactory::GetInstance()); 53 DependsOn(ProfileSyncServiceFactory::GetInstance());
53 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); 54 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
54 } 55 }
55 56
56 DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {} 57 DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
57 58
58 KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor( 59 KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
59 content::BrowserContext* context) const { 60 content::BrowserContext* context) const {
60 invalidation::InvalidationService* invalidation_service = 61
hashimoto 2014/06/12 02:20:46 nit: Unneeded blank line.
bartfab (slow) 2014/06/12 09:21:14 Done.
61 invalidation::InvalidationServiceFactory::GetForProfile( 62 invalidation::ProfileInvalidationProvider* invalidation_provider =
63 invalidation::ProfileInvalidationProviderFactory::GetForProfile(
62 Profile::FromBrowserContext(context)); 64 Profile::FromBrowserContext(context));
63 DCHECK(invalidation_service); 65 DCHECK(invalidation_provider);
64 return new DriveNotificationManager(invalidation_service); 66 DCHECK(invalidation_provider->GetInvalidationService());
67 return new DriveNotificationManager(
68 invalidation_provider->GetInvalidationService());
65 } 69 }
66 70
67 } // namespace drive 71 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698