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

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: Typo fix Created 7 years, 7 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..169e1b5096d77db22049b9280999d039f45ae008 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,9 @@ void MessageService::AllocatePortIdPair(int* port1, int* port2) {
*port2 = port2_id;
}
-MessageService::MessageService(
- LazyBackgroundTaskQueue* queue)
- : lazy_background_task_queue_(queue),
+MessageService::MessageService(Profile* profile)
+ : 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 +158,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,
« no previous file with comments | « chrome/browser/extensions/api/messaging/message_service.h ('k') | chrome/browser/extensions/extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698