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

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: inner class 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..a554329933fdb9df32d9bde0a870e5a4ec2e57ba
--- /dev/null
+++ b/content/child/child_message_filter.h
@@ -0,0 +1,62 @@
+// 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,
jam 2013/09/26 18:09:37 While it's nice to reuse the method definitions fr
scherkus (not reviewing) 2013/09/26 19:33:48 Yeah I realized this after I sent this out ... it'
scherkus (not reviewing) 2013/11/07 21:24:23 Updated to no longer implement IPC::ChannelProxy::
+ public IPC::Sender {
+ public:
+ ChildMessageFilter();
+
+ // IPC::Sender implementation.
+ //
+ // Can be called on any thread.
+ virtual bool Send(IPC::Message* message) OVERRIDE;
+
+ // Override to have OnMessageReceived() run on a TaskRunner of your choosing.
+ // Returns NULL by default, which runs OnMessageReceived() on the child
+ // thread.
+ virtual base::TaskRunner* OverrideTaskRunnerForMessage(
+ const IPC::Message& message);
+
+ protected:
+ friend class base::RefCountedThreadSafe<ChildMessageFilter>;
+ virtual ~ChildMessageFilter();
+
+ private:
+ class Internal : public IPC::ChannelProxy::MessageFilter {
jam 2013/09/26 18:09:37 nit: you could just hide this whole class in the c
scherkus (not reviewing) 2013/11/07 21:24:23 Done.
+ public:
+ explicit Internal(ChildMessageFilter* filter);
+
+ // IPC::ChannelProxy::MessageFilter overrides.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ protected:
+ friend class base::RefCountedThreadSafe<Internal>;
+ virtual ~Internal();
+
+ private:
+ ChildMessageFilter* filter_; // Avoid circular references.
+
+ DISALLOW_COPY_AND_ASSIGN(Internal);
+ };
+
+ scoped_refptr<Internal> internal_;
+ 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