Chromium Code Reviews| Index: chrome/browser/extensions/api/messaging/message_service.cc |
| diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc |
| index 22915cb5060ff1b177862cadbbaae3ff7d5e0c62..1ec497418085107e8a6ff3afd108d08748e0868c 100644 |
| --- a/chrome/browser/extensions/api/messaging/message_service.cc |
| +++ b/chrome/browser/extensions/api/messaging/message_service.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/bind.h" |
| #include "base/callback.h" |
| #include "base/json/json_writer.h" |
| +#include "base/lazy_instance.h" |
| #include "base/stl_util.h" |
| #include "base/values.h" |
| #include "chrome/browser/extensions/api/messaging/extension_message_port.h" |
| @@ -142,14 +143,15 @@ void MessageService::AllocatePortIdPair(int* port1, int* port2) { |
| *port2 = port2_id; |
| } |
| -MessageService::MessageService( |
| - LazyBackgroundTaskQueue* queue) |
| - : lazy_background_task_queue_(queue), |
| +MessageService::MessageService(Profile* profile) |
| + : profile_(profile), |
| weak_factory_(this) { |
| registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| content::NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| content::NotificationService::AllBrowserContextsAndSources()); |
| + lazy_background_task_queue_ = |
|
Devlin
2013/04/26 01:21:25
nit: You could initialize this right below profile
Patrick Riordan
2013/04/26 02:18:45
Done.
|
| + ExtensionSystem::Get(profile_)->lazy_background_task_queue(); |
| } |
| MessageService::~MessageService() { |
| @@ -157,6 +159,14 @@ MessageService::~MessageService() { |
| channels_.clear(); |
| } |
| +static base::LazyInstance<ProfileKeyedAPIFactory<MessageService> > |
| +g_factory = LAZY_INSTANCE_INITIALIZER; |
| + |
| +// static |
| +ProfileKeyedAPIFactory<MessageService>* MessageService::GetFactoryInstance() { |
| + return &g_factory.Get(); |
| +} |
| + |
| void MessageService::OpenChannelToExtension( |
| int source_process_id, int source_routing_id, int receiver_port_id, |
| const std::string& source_extension_id, |