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

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: 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/message_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..69c23ef776cbebe7f980445712ca0ec7e691674c 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,15 @@ 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();
+
+ // Convenience method to get the MessageService for a profile.
+ static MessageService* Get(Profile* profile);
+
// 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 +153,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 +211,12 @@ class MessageService : public content::NotificationObserver,
PostMessage(port_id, message);
}
+ // ProfileKeyedAPI implementation.
+ static const char* service_name() {
+ return "MessageService";
+ }
+ static const bool kServiceRedirectedInIncognito = true;
+
content::NotificationRegistrar registrar_;
MessageChannelMap channels_;
PendingChannelMap pending_channels_;
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/message_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698