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

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: inner class Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/child/child_message_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 : 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::
17 public IPC::Sender {
18 public:
19 ChildMessageFilter();
20
21 // IPC::Sender implementation.
22 //
23 // Can be called on any thread.
24 virtual bool Send(IPC::Message* message) OVERRIDE;
25
26 // Override to have OnMessageReceived() run on a TaskRunner of your choosing.
27 // Returns NULL by default, which runs OnMessageReceived() on the child
28 // thread.
29 virtual base::TaskRunner* OverrideTaskRunnerForMessage(
30 const IPC::Message& message);
31
32 protected:
33 friend class base::RefCountedThreadSafe<ChildMessageFilter>;
34 virtual ~ChildMessageFilter();
35
36 private:
37 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.
38 public:
39 explicit Internal(ChildMessageFilter* filter);
40
41 // IPC::ChannelProxy::MessageFilter overrides.
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
43
44 protected:
45 friend class base::RefCountedThreadSafe<Internal>;
46 virtual ~Internal();
47
48 private:
49 ChildMessageFilter* filter_; // Avoid circular references.
50
51 DISALLOW_COPY_AND_ASSIGN(Internal);
52 };
53
54 scoped_refptr<Internal> internal_;
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698