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

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: fix impl Created 7 years, 1 month 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') | content/renderer/render_thread_impl.cc » ('J')
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..3486494975ed6f7dcc594a6097f928334cee81f2
--- /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 base::RefCountedThreadSafe<ChildMessageFilter>,
+ 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);
+
+ virtual bool OnMessageReceived(const IPC::Message& message) = 0;
scherkus (not reviewing) 2013/11/07 21:24:23 reminder to self: needs docs
+
+ protected:
+ friend class base::RefCountedThreadSafe<ChildMessageFilter>;
+ virtual ~ChildMessageFilter();
+
+ private:
+ class Internal;
+ friend class RenderThreadImpl;
+
+ // Returns private IPC::ChannelProxy::MessageFilter implementation. Intended
+ // for use by friend classes listed above.
+ scoped_refptr<IPC::ChannelProxy::MessageFilter> get_internal() {
+ return internal_;
+ }
+
+ // Private implementation of IPC::ChannelProxy::MessageFilter hidden from
+ // child classes. An equivalent API is provided to child classes.
+ scoped_refptr<IPC::ChannelProxy::MessageFilter> internal_;
+
+ // Used to implement a thread-safe IPC::Sender implementation for child
+ // classes.
+ 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') | content/renderer/render_thread_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698