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

Unified Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 14208019: Change MessageService to use ProfileKeyedAPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698