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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
6 #define CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
7
8 #include "ipc/ipc_channel_proxy.h"
9
10 namespace content {
11
12 class ThreadSafeSender;
13
14 // Convenience base class for implementing IPC MessageFilters that run on the
15 // child thread and can dispatch messages to arbitrary task runners.
16 class ChildMessageFilter
17 : public base::RefCountedThreadSafe<ChildMessageFilter>,
18 public IPC::Sender {
19 public:
20 ChildMessageFilter();
21
22 // IPC::Sender implementation.
23 //
24 // Can be called on any thread.
25 virtual bool Send(IPC::Message* message) OVERRIDE;
26
27 // Override to have OnMessageReceived() run on a TaskRunner of your choosing.
28 // Returns NULL by default, which runs OnMessageReceived() on the child
29 // thread.
30 virtual base::TaskRunner* OverrideTaskRunnerForMessage(
31 const IPC::Message& message);
32
33 virtual bool OnMessageReceived(const IPC::Message& message) = 0;
scherkus (not reviewing) 2013/11/07 21:24:23 reminder to self: needs docs
34
35 protected:
36 friend class base::RefCountedThreadSafe<ChildMessageFilter>;
37 virtual ~ChildMessageFilter();
38
39 private:
40 class Internal;
41 friend class RenderThreadImpl;
42
43 // Returns private IPC::ChannelProxy::MessageFilter implementation. Intended
44 // for use by friend classes listed above.
45 scoped_refptr<IPC::ChannelProxy::MessageFilter> get_internal() {
46 return internal_;
47 }
48
49 // Private implementation of IPC::ChannelProxy::MessageFilter hidden from
50 // child classes. An equivalent API is provided to child classes.
51 scoped_refptr<IPC::ChannelProxy::MessageFilter> internal_;
52
53 // Used to implement a thread-safe IPC::Sender implementation for child
54 // classes.
55 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
56
57 DISALLOW_COPY_AND_ASSIGN(ChildMessageFilter);
58 };
59
60 } // namespace content
61
62 #endif // CONTENT_CHILD_CHILD_MESSAGE_FILTER_H_
OLDNEW
« 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