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

Unified Diff: content/child/child_message_filter.h

Issue 24636002: Introduce content::ChildMessageFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | content/child/child_message_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_message_filter.h
diff --git a/content/child/child_message_filter.h b/content/child/child_message_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1086d05e5d2c40f4bd16774c4971d058cba73fd6
--- /dev/null
+++ b/content/child/child_message_filter.h
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
+#define CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
+
+#include "ipc/ipc_channel_proxy.h"
+
+namespace content {
+
+class ThreadSafeSender;
+
+// Convenience base class for implementing IPC MessageFilters that run on the
+// child thread and can dispatch messages to arbitrary task runners.
+class ChildMessageFilter : public IPC::ChannelProxy::MessageFilter,
+ public IPC::Sender {
+ public:
+ ChildMessageFilter();
+
+ // IPC::ChannelProxy::MessageFilter overrides.
+ //
+ // DON'T OVERRIDE THIS! Implement HandleMessage() instead.
jam 2013/09/25 20:58:58 in retrospect, I should have made BrowserMessageFi
scherkus (not reviewing) 2013/09/25 23:07:15 Done. I find it ends up being a biiiittt confusin
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // IPC::Sender implementation.
+ //
+ // Can be called on any thread.
+ virtual bool Send(IPC::Message* message) OVERRIDE;
+
+ // Override to have HandleMessage() run on a TaskRunner of your choosing.
+ // Returns NULL by default, which runs HandleMessage() on the child thread.
+ virtual base::TaskRunner* OverrideTaskRunnerForMessage(
+ const IPC::Message& message);
+
+ // Subclasses implement to handle IPC messages returning true if the message
+ // was handled, false otherwise.
+ //
+ // XXX naming is hard ... unlike in BrowserMessageFilter we don't
+ // have |message_is_ok| to differentiate the OnMessageReceived() methods.
+ virtual bool HandleMessage(const IPC::Message& message) = 0;
+
+ protected:
+ friend class base::RefCountedThreadSafe<ChildMessageFilter>;
+ virtual ~ChildMessageFilter();
+
+ private:
+ scoped_refptr<ThreadSafeSender> thread_safe_sender_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChildMessageFilter);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
« no previous file with comments | « no previous file | content/child/child_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698