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

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

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.h
diff --git a/chrome/browser/extensions/api/messaging/message_service.h b/chrome/browser/extensions/api/messaging/message_service.h
index adeb060f9198b1a375ab46a00553288e1aadff99..a3be6574ea3ba26bfbffe39a77d22fd996590488 100644
--- a/chrome/browser/extensions/api/messaging/message_service.h
+++ b/chrome/browser/extensions/api/messaging/message_service.h
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
+#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -54,7 +55,8 @@ class LazyBackgroundTaskQueue;
// port: an IPC::Message::Process interface and an optional routing_id (in the
// case that the port is a tab). The Process is usually either a
// RenderProcessHost or a RenderViewHost.
-class MessageService : public content::NotificationObserver,
+class MessageService : public ProfileKeyedAPI,
+ public content::NotificationObserver,
public NativeMessageProcessHost::Client {
public:
// A messaging channel. Note that the opening port can be the same as the
@@ -102,9 +104,12 @@ class MessageService : public content::NotificationObserver,
// NOTE: this can be called from any thread.
static void AllocatePortIdPair(int* port1, int* port2);
- explicit MessageService(LazyBackgroundTaskQueue* queue);
+ explicit MessageService(Profile* profile);
virtual ~MessageService();
+ // ProfileKeyedAPI implementation.
+ static ProfileKeyedAPIFactory<MessageService>* GetFactoryInstance();
+
// Given an extension's ID, opens a channel between the given renderer "port"
// and every listening context owned by that extension. |channel_name| is
// an optional identifier for use by extension developers.
@@ -145,6 +150,7 @@ class MessageService : public content::NotificationObserver,
private:
friend class MockMessageService;
+ friend class ProfileKeyedAPIFactory<MessageService>;
struct OpenChannelParams;
// A map of channel ID to its channel object.
@@ -202,6 +208,13 @@ class MessageService : public content::NotificationObserver,
PostMessage(port_id, message);
}
+ Profile* profile_;
+
+ // ProfileKeyedAPI implementation.
+ static const char* service_name() {
+ return "MessageService";
+ }
+
content::NotificationRegistrar registrar_;
MessageChannelMap channels_;
PendingChannelMap pending_channels_;

Powered by Google App Engine
This is Rietveld 408576698