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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 165333004: Revert "Allow MessageFilters to restrict listening to specific message classes" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
« no previous file with comments | « ipc/ipc.gyp ('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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 virtual void OnChannelError(); 81 virtual void OnChannelError();
82 82
83 // 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.
84 // OnFilterRemoved is called immediately after this. 84 // OnFilterRemoved is called immediately after this.
85 virtual void OnChannelClosing(); 85 virtual void OnChannelClosing();
86 86
87 // 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
88 // the message be handled in the default way. 88 // the message be handled in the default way.
89 virtual bool OnMessageReceived(const Message& message); 89 virtual bool OnMessageReceived(const Message& message);
90 90
91 // Called to query the Message classes supported by the filter. Return
92 // false to indicate that all message types should reach the filter, or true
93 // if the resulting contents of |supported_message_classes| may be used to
94 // selectively offer messages of a particular class to the filter.
95 virtual bool GetSupportedMessageClasses(
96 std::vector<uint32>* supported_message_classes) const;
97
98 protected: 91 protected:
99 virtual ~MessageFilter(); 92 virtual ~MessageFilter();
100 93
101 private: 94 private:
102 friend class base::RefCountedThreadSafe<MessageFilter>; 95 friend class base::RefCountedThreadSafe<MessageFilter>;
103 }; 96 };
104 97
105 // Initializes a channel proxy. The channel_handle and mode parameters are 98 // Initializes a channel proxy. The channel_handle and mode parameters are
106 // passed directly to the underlying IPC::Channel. The listener is called on 99 // passed directly to the underlying IPC::Channel. The listener is called on
107 // the thread that creates the ChannelProxy. The filter's OnMessageReceived 100 // the thread that creates the ChannelProxy. The filter's OnMessageReceived
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; 223 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_;
231 Listener* listener_; 224 Listener* listener_;
232 225
233 // List of filters. This is only accessed on the IPC thread. 226 // List of filters. This is only accessed on the IPC thread.
234 std::vector<scoped_refptr<MessageFilter> > filters_; 227 std::vector<scoped_refptr<MessageFilter> > filters_;
235 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 228 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
236 scoped_ptr<Channel> channel_; 229 scoped_ptr<Channel> channel_;
237 std::string channel_id_; 230 std::string channel_id_;
238 bool channel_connected_called_; 231 bool channel_connected_called_;
239 232
240 // Routes a given message to a proper subset of |filters_|, depending
241 // on which message classes a filter might support.
242 class MessageFilterRouter;
243 scoped_ptr<MessageFilterRouter> message_filter_router_;
244
245 // Holds filters between the AddFilter call on the listerner thread and the 233 // Holds filters between the AddFilter call on the listerner thread and the
246 // IPC thread when they're added to filters_. 234 // IPC thread when they're added to filters_.
247 std::vector<scoped_refptr<MessageFilter> > pending_filters_; 235 std::vector<scoped_refptr<MessageFilter> > pending_filters_;
248 // Lock for pending_filters_. 236 // Lock for pending_filters_.
249 base::Lock pending_filters_lock_; 237 base::Lock pending_filters_lock_;
250 238
251 // Cached copy of the peer process ID. Set on IPC but read on both IPC and 239 // Cached copy of the peer process ID. Set on IPC but read on both IPC and
252 // listener threads. 240 // listener threads.
253 base::ProcessId peer_pid_; 241 base::ProcessId peer_pid_;
254 }; 242 };
255 243
256 Context* context() { return context_.get(); } 244 Context* context() { return context_.get(); }
257 245
258 private: 246 private:
259 friend class SendCallbackHelper; 247 friend class SendCallbackHelper;
260 248
261 // By maintaining this indirection (ref-counted) to our internal state, we 249 // By maintaining this indirection (ref-counted) to our internal state, we
262 // can safely be destroyed while the background thread continues to do stuff 250 // can safely be destroyed while the background thread continues to do stuff
263 // that involves this data. 251 // that involves this data.
264 scoped_refptr<Context> context_; 252 scoped_refptr<Context> context_;
265 253
266 // Whether the channel has been initialized. 254 // Whether the channel has been initialized.
267 bool did_init_; 255 bool did_init_;
268 }; 256 };
269 257
270 } // namespace IPC 258 } // namespace IPC
271 259
272 #endif // IPC_IPC_CHANNEL_PROXY_H_ 260 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « ipc/ipc.gyp ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698