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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 24514003: Make BrowserMessageFilter not derive from IPC::ChannelProxy::MessageFilter. This allows us to hide … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync 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 | « content/test/webrtc_audio_device_test.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IPC_IPC_CHANNEL_PROXY_H_ 5 #ifndef IPC_IPC_CHANNEL_PROXY_H_
6 #define IPC_IPC_CHANNEL_PROXY_H_ 6 #define IPC_IPC_CHANNEL_PROXY_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // the consumer of IPC::ChannelProxy the ability to respond to incoming 47 // the consumer of IPC::ChannelProxy the ability to respond to incoming
48 // messages on this background thread instead of on their own thread, which may 48 // messages on this background thread instead of on their own thread, which may
49 // be bogged down with other processing. The result can be greatly improved 49 // be bogged down with other processing. The result can be greatly improved
50 // latency for messages that can be handled on a background thread. 50 // latency for messages that can be handled on a background thread.
51 // 51 //
52 // The consumer of IPC::ChannelProxy is responsible for allocating the Thread 52 // The consumer of IPC::ChannelProxy is responsible for allocating the Thread
53 // instance where the IPC::Channel will be created and operated. 53 // instance where the IPC::Channel will be created and operated.
54 // 54 //
55 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { 55 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
56 public: 56 public:
57 struct MessageFilterTraits;
58 57
59 // A class that receives messages on the thread where the IPC channel is 58 // A class that receives messages on the thread where the IPC channel is
60 // running. It can choose to prevent the default action for an IPC message. 59 // running. It can choose to prevent the default action for an IPC message.
61 class IPC_EXPORT MessageFilter 60 class IPC_EXPORT MessageFilter
62 : public base::RefCountedThreadSafe<MessageFilter, MessageFilterTraits> { 61 : public base::RefCountedThreadSafe<MessageFilter> {
63 public: 62 public:
64 MessageFilter(); 63 MessageFilter();
65 64
66 // Called on the background thread to provide the filter with access to the 65 // Called on the background thread to provide the filter with access to the
67 // channel. Called when the IPC channel is initialized or when AddFilter 66 // channel. Called when the IPC channel is initialized or when AddFilter
68 // is called if the channel is already initialized. 67 // is called if the channel is already initialized.
69 virtual void OnFilterAdded(Channel* channel); 68 virtual void OnFilterAdded(Channel* channel);
70 69
71 // Called on the background thread when the filter has been removed from 70 // Called on the background thread when the filter has been removed from
72 // the ChannelProxy and when the Channel is closing. After a filter is 71 // the ChannelProxy and when the Channel is closing. After a filter is
73 // removed, it will not be called again. 72 // removed, it will not be called again.
74 virtual void OnFilterRemoved(); 73 virtual void OnFilterRemoved();
75 74
76 // Called to inform the filter that the IPC channel is connected and we 75 // Called to inform the filter that the IPC channel is connected and we
77 // have received the internal Hello message from the peer. 76 // have received the internal Hello message from the peer.
78 virtual void OnChannelConnected(int32 peer_pid); 77 virtual void OnChannelConnected(int32 peer_pid);
79 78
80 // Called when there is an error on the channel, typically that the channel 79 // Called when there is an error on the channel, typically that the channel
81 // has been closed. 80 // has been closed.
82 virtual void OnChannelError(); 81 virtual void OnChannelError();
83 82
84 // Called to inform the filter that the IPC channel will be destroyed. 83 // Called to inform the filter that the IPC channel will be destroyed.
85 // OnFilterRemoved is called immediately after this. 84 // OnFilterRemoved is called immediately after this.
86 virtual void OnChannelClosing(); 85 virtual void OnChannelClosing();
87 86
88 // Return true to indicate that the message was handled, or false to let 87 // Return true to indicate that the message was handled, or false to let
89 // the message be handled in the default way. 88 // the message be handled in the default way.
90 virtual bool OnMessageReceived(const Message& message); 89 virtual bool OnMessageReceived(const Message& message);
91 90
92 // Called when the message filter is about to be deleted. This gives
93 // derived classes the option of controlling which thread they're deleted
94 // on etc.
95 virtual void OnDestruct() const;
96
97 protected: 91 protected:
98 virtual ~MessageFilter(); 92 virtual ~MessageFilter();
99 93
100 private: 94 private:
101 friend class base::RefCountedThreadSafe<MessageFilter, 95 friend class base::RefCountedThreadSafe<MessageFilter>;
102 MessageFilterTraits>;
103 }; 96 };
104 97
105 struct MessageFilterTraits {
106 static void Destruct(const MessageFilter* filter) {
107 filter->OnDestruct();
108 }
109 };
110
111
112 // Interface for a filter to be imposed on outgoing messages which can 98 // Interface for a filter to be imposed on outgoing messages which can
113 // re-write the message. Used mainly for testing. 99 // re-write the message. Used mainly for testing.
114 class OutgoingMessageFilter { 100 class OutgoingMessageFilter {
115 public: 101 public:
116 // Returns a re-written message, freeing the original, or simply the 102 // Returns a re-written message, freeing the original, or simply the
117 // original unchanged if no rewrite indicated. 103 // original unchanged if no rewrite indicated.
118 virtual Message *Rewrite(Message *message) = 0; 104 virtual Message *Rewrite(Message *message) = 0;
119 }; 105 };
120 106
121 // Initializes a channel proxy. The channel_handle and mode parameters are 107 // Initializes a channel proxy. The channel_handle and mode parameters are
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 270
285 OutgoingMessageFilter* outgoing_message_filter_; 271 OutgoingMessageFilter* outgoing_message_filter_;
286 272
287 // Whether the channel has been initialized. 273 // Whether the channel has been initialized.
288 bool did_init_; 274 bool did_init_;
289 }; 275 };
290 276
291 } // namespace IPC 277 } // namespace IPC
292 278
293 #endif // IPC_IPC_CHANNEL_PROXY_H_ 279 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « content/test/webrtc_audio_device_test.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698