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..efc56bc68eb2ff29746fd00bcfbd41fb00e9f72d 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,9 +143,10 @@ 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), |
|
Yoyo Zhou
2013/04/30 22:33:04
Note you don't actually use profile_ anywhere so y
Patrick Riordan
2013/05/01 01:54:44
Done.
|
| + lazy_background_task_queue_( |
| + ExtensionSystem::Get(profile_)->lazy_background_task_queue()), |
| weak_factory_(this) { |
| registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| content::NotificationService::AllBrowserContextsAndSources()); |
| @@ -157,6 +159,19 @@ MessageService::~MessageService() { |
| channels_.clear(); |
| } |
| +static base::LazyInstance<ProfileKeyedAPIFactory<MessageService> > |
| +g_factory = LAZY_INSTANCE_INITIALIZER; |
| + |
| +// static |
| +ProfileKeyedAPIFactory<MessageService>* MessageService::GetFactoryInstance() { |
| + return &g_factory.Get(); |
| +} |
| + |
| +// static |
| +MessageService* MessageService::Get(Profile* profile) { |
| + return ProfileKeyedAPIFactory<MessageService>::GetForProfile(profile); |
| +} |
| + |
| void MessageService::OpenChannelToExtension( |
| int source_process_id, int source_routing_id, int receiver_port_id, |
| const std::string& source_extension_id, |