Chromium Code Reviews| Index: chrome/browser/extensions/message_service.h |
| diff --git a/chrome/browser/extensions/message_service.h b/chrome/browser/extensions/message_service.h |
| index 47a3116dc315a519fd6acbca3872caf75cd06dc4..3834e2ece87d17a9b714bf6a28f602e938f20770 100644 |
| --- a/chrome/browser/extensions/message_service.h |
| +++ b/chrome/browser/extensions/message_service.h |
| @@ -10,7 +10,8 @@ |
| #include <string> |
| #include "base/compiler_specific.h" |
| -#include "base/memory/linked_ptr.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| @@ -24,6 +25,7 @@ class WebContents; |
| namespace extensions { |
| class ExtensionHost; |
| class LazyBackgroundTaskQueue; |
| +class NativeMessageProcess; |
| // This class manages message and event passing between renderer processes. |
| // It maintains a list of processes that are listening to events and a set of |
| @@ -52,7 +54,6 @@ class MessageService : public content::NotificationObserver { |
| // receiver, if an extension background page wants to talk to its tab (for |
| // example). |
| struct MessageChannel; |
| - struct MessagePort; |
| // Allocates a pair of port ids. |
| // NOTE: this can be called from any thread. |
| @@ -78,6 +79,20 @@ class MessageService : public content::NotificationObserver { |
| int tab_id, const std::string& extension_id, |
| const std::string& channel_name); |
| + void OpenChannelToNativeApp( |
| + int source_process_id, int source_routing_id, int receiver_port_id, |
|
Aaron Boodman
2012/08/15 03:39:21
Nit: Some of these lines could be combined. Either
Matt Perry
2012/08/16 00:01:36
Chromium style is actually to put each arg on its
eaugusti
2012/08/21 23:08:34
Done.
|
| + const std::string& source_extension_id, |
| + const std::string& native_app_name, |
| + const std::string& channel_name, |
| + const std::string& connect_message); |
| + // Should be called on the UI thread. |
|
Aaron Boodman
2012/08/15 03:39:21
Nit: insert blank line
eaugusti
2012/08/21 23:08:34
Done.
|
| + void FinalizeOpenChannelToNativeApp( |
| + int receiver_port_id, |
| + const std::string& channel_name, |
| + scoped_ptr<MessageChannel> channel, |
| + const std::string& tab_json, |
| + NativeMessageProcess* native_process); |
| + |
| // Closes the message channel associated with the given port, and notifies |
| // the other side. |
| void CloseChannel(int port_id, bool connection_error); |
| @@ -99,12 +114,16 @@ class MessageService : public content::NotificationObserver { |
| typedef std::map<int, PendingChannel> PendingChannelMap; |
| // Common among OpenChannel* variants. |
| - bool OpenChannelImpl(const OpenChannelParams& params); |
| + bool OpenChannelImpl(scoped_ptr<OpenChannelParams> params); |
| void CloseChannelImpl(MessageChannelMap::iterator channel_iter, |
| int port_id, bool connection_error, |
| bool notify_other_port); |
| + // Have MessageService take ownership of |channel|, and remove any pending |
| + // channels with the same id. |
| + void AddChannel(MessageChannel* channel, int receiver_port_id); |
| + |
| // content::NotificationObserver interface. |
| virtual void Observe(int type, |
| const content::NotificationSource& source, |
| @@ -115,13 +134,14 @@ class MessageService : public content::NotificationObserver { |
| // Potentially registers a pending task with the LazyBackgroundTaskQueue |
| // to open a channel. Returns true if a task was queued. |
| + // Takes ownership of |params| if true is returned. |
| bool MaybeAddPendingOpenChannelTask(Profile* profile, |
| - const OpenChannelParams& params); |
| + OpenChannelParams* params); |
| // Callbacks for LazyBackgroundTaskQueue tasks. The queue passes in an |
| // ExtensionHost to its task callbacks, though some of our callbacks don't |
| // use that argument. |
| - void PendingOpenChannel(const OpenChannelParams& params, |
| + void PendingOpenChannel(scoped_ptr<OpenChannelParams> params, |
| int source_process_id, |
| extensions::ExtensionHost* host); |
| void PendingCloseChannel(int port_id, |
| @@ -144,6 +164,8 @@ class MessageService : public content::NotificationObserver { |
| // Weak pointer. Guaranteed to outlive this class. |
| LazyBackgroundTaskQueue* lazy_background_task_queue_; |
| + base::WeakPtrFactory<MessageService> weak_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MessageService); |
| }; |