summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_proxy.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 06:10:30 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 06:10:30 +0000
commitf671062f8c572d6729173c4ac7f058a1a89b5a1d (patch)
tree3eebe393f6f20310ba812662d092c3ca3c3c4d9e /ipc/ipc_channel_proxy.h
parent6fad26338ed6119903826156f307e20fe6657c31 (diff)
downloadchromium_src-f671062f8c572d6729173c4ac7f058a1a89b5a1d.zip
chromium_src-f671062f8c572d6729173c4ac7f058a1a89b5a1d.tar.gz
chromium_src-f671062f8c572d6729173c4ac7f058a1a89b5a1d.tar.bz2
Add the ability for objects which derive from RefCountedThreadSafe to specify a destructor trait. This allows browser objects to specify which thread they're terminated on. The benefit is we avoid the need to do manual ref counting when an object posts tasks to itself on different threads, if an object must be destructed on a specific thread.
This patch adds initial support and only shows one example with ResourceMessageFilter. I will do the rest in a follow-up patch to keep things small. BUG=25354 TEST=added unit tests Review URL: http://codereview.chromium.org/338065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_proxy.h')
-rw-r--r--ipc/ipc_channel_proxy.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index a2d55be..3369f50 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -46,9 +46,16 @@ class SendTask;
//
class ChannelProxy : public Message::Sender {
public:
+
+ class MessageFilter;
+ struct MessageFilterTraits {
+ static void Destruct(MessageFilter* filter);
+ };
+
// A class that receives messages on the thread where the IPC channel is
// running. It can choose to prevent the default action for an IPC message.
- class MessageFilter : public base::RefCountedThreadSafe<MessageFilter> {
+ class MessageFilter
+ : public base::RefCountedThreadSafe<MessageFilter, MessageFilterTraits> {
public:
virtual ~MessageFilter() {}
@@ -79,6 +86,13 @@ class ChannelProxy : public Message::Sender {
virtual bool OnMessageReceived(const Message& message) {
return false;
}
+
+ // Called when the message filter is about to be deleted. This gives
+ // derived classes the option of controlling which thread they're deleted
+ // on etc.
+ virtual void OnDestruct() {
+ delete this;
+ }
};
// Initializes a channel proxy. The channel_id and mode parameters are