| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/push_messaging/push_messaging_api.h" | 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 content::Source<Profile>(profile_->GetOriginalProfile())); | 289 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 290 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 290 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 291 content::Source<Profile>(profile_->GetOriginalProfile())); | 291 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 292 } | 292 } |
| 293 | 293 |
| 294 PushMessagingAPI::~PushMessagingAPI() { | 294 PushMessagingAPI::~PushMessagingAPI() { |
| 295 } | 295 } |
| 296 | 296 |
| 297 // static | 297 // static |
| 298 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { | 298 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { |
| 299 return ProfileKeyedAPIFactory<PushMessagingAPI>::GetForProfile(context); | 299 return BrowserContextKeyedAPIFactory<PushMessagingAPI>::Get(context); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void PushMessagingAPI::Shutdown() { | 302 void PushMessagingAPI::Shutdown() { |
| 303 event_router_.reset(); | 303 event_router_.reset(); |
| 304 handler_.reset(); | 304 handler_.reset(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 static base::LazyInstance<ProfileKeyedAPIFactory<PushMessagingAPI> > | 307 static base::LazyInstance<BrowserContextKeyedAPIFactory<PushMessagingAPI> > |
| 308 g_factory = LAZY_INSTANCE_INITIALIZER; | 308 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 309 | 309 |
| 310 // static | 310 // static |
| 311 ProfileKeyedAPIFactory<PushMessagingAPI>* | 311 BrowserContextKeyedAPIFactory<PushMessagingAPI>* |
| 312 PushMessagingAPI::GetFactoryInstance() { | 312 PushMessagingAPI::GetFactoryInstance() { |
| 313 return g_factory.Pointer(); | 313 return g_factory.Pointer(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void PushMessagingAPI::Observe(int type, | 316 void PushMessagingAPI::Observe(int type, |
| 317 const content::NotificationSource& source, | 317 const content::NotificationSource& source, |
| 318 const content::NotificationDetails& details) { | 318 const content::NotificationDetails& details) { |
| 319 invalidation::InvalidationService* invalidation_service = | 319 invalidation::InvalidationService* invalidation_service = |
| 320 invalidation::InvalidationServiceFactory::GetForProfile(profile_); | 320 invalidation::InvalidationServiceFactory::GetForProfile(profile_); |
| 321 // This may be NULL; for example, for the ChromeOS guest user. In these cases, | 321 // This may be NULL; for example, for the ChromeOS guest user. In these cases, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 NOTREACHED(); | 357 NOTREACHED(); |
| 358 } | 358 } |
| 359 } | 359 } |
| 360 | 360 |
| 361 void PushMessagingAPI::SetMapperForTest( | 361 void PushMessagingAPI::SetMapperForTest( |
| 362 scoped_ptr<PushMessagingInvalidationMapper> mapper) { | 362 scoped_ptr<PushMessagingInvalidationMapper> mapper) { |
| 363 handler_ = mapper.Pass(); | 363 handler_ = mapper.Pass(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 template <> | 366 template <> |
| 367 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { | 367 void |
| 368 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { |
| 368 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 369 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 369 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | 370 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); |
| 370 } | 371 } |
| 371 | 372 |
| 372 } // namespace extensions | 373 } // namespace extensions |
| OLD | NEW |