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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 2173753002: Revert of Support early associated interface binding on ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-channel-ipc-task-runner
Patch Set: Created 4 years, 5 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_channel_mojo_unittest.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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 template <typename Interface> 182 template <typename Interface>
183 void AddAssociatedInterface( 183 void AddAssociatedInterface(
184 const AssociatedInterfaceFactory<Interface>& factory) { 184 const AssociatedInterfaceFactory<Interface>& factory) {
185 AddGenericAssociatedInterface( 185 AddGenericAssociatedInterface(
186 Interface::Name_, 186 Interface::Name_,
187 base::Bind(&ChannelProxy::BindAssociatedInterfaceRequest<Interface>, 187 base::Bind(&ChannelProxy::BindAssociatedInterfaceRequest<Interface>,
188 factory)); 188 factory));
189 } 189 }
190 190
191 // Gets the AssociatedGroup used to create new associated endpoints on this 191 // Gets the AssociatedGroup used to create new associated endpoints on this
192 // ChannelProxy. 192 // ChannelProxy. This must only be called after the listener's
193 // OnChannelConnected is called.
193 mojo::AssociatedGroup* GetAssociatedGroup(); 194 mojo::AssociatedGroup* GetAssociatedGroup();
194 195
195 // Requests an associated interface from the remote endpoint. 196 // Requests an associated interface from the remote endpoint.
196 void GetGenericRemoteAssociatedInterface( 197 void GetGenericRemoteAssociatedInterface(
197 const std::string& name, 198 const std::string& name,
198 mojo::ScopedInterfaceEndpointHandle handle); 199 mojo::ScopedInterfaceEndpointHandle handle);
199 200
200 // Template helper to request associated interfaces from the remote endpoint. 201 // Template helper to request associated interfaces from the remote endpoint.
202 // Must only be called after the listener's OnChannelConnected is called.
201 template <typename Interface> 203 template <typename Interface>
202 void GetRemoteAssociatedInterface( 204 void GetRemoteAssociatedInterface(
203 mojo::AssociatedInterfacePtr<Interface>* proxy) { 205 mojo::AssociatedInterfacePtr<Interface>* proxy) {
204 mojo::AssociatedInterfaceRequest<Interface> request = 206 mojo::AssociatedInterfaceRequest<Interface> request =
205 mojo::GetProxy(proxy, GetAssociatedGroup()); 207 mojo::GetProxy(proxy, GetAssociatedGroup());
206 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle()); 208 GetGenericRemoteAssociatedInterface(Interface::Name_, request.PassHandle());
207 } 209 }
208 210
209 #if defined(ENABLE_IPC_FUZZER) 211 #if defined(ENABLE_IPC_FUZZER)
210 void set_outgoing_message_filter(OutgoingMessageFilter* filter) { 212 void set_outgoing_message_filter(OutgoingMessageFilter* filter) {
(...skipping 11 matching lines...) Expand all
222 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 224 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
223 // Calls through to the underlying channel's methods. 225 // Calls through to the underlying channel's methods.
224 int GetClientFileDescriptor(); 226 int GetClientFileDescriptor();
225 base::ScopedFD TakeClientFileDescriptor(); 227 base::ScopedFD TakeClientFileDescriptor();
226 #endif 228 #endif
227 229
228 protected: 230 protected:
229 class Context; 231 class Context;
230 // A subclass uses this constructor if it needs to add more information 232 // A subclass uses this constructor if it needs to add more information
231 // to the internal state. 233 // to the internal state.
232 explicit ChannelProxy(Context* context); 234 ChannelProxy(Context* context);
233 235
234 236
235 // Used internally to hold state that is referenced on the IPC thread. 237 // Used internally to hold state that is referenced on the IPC thread.
236 class Context : public base::RefCountedThreadSafe<Context>, 238 class Context : public base::RefCountedThreadSafe<Context>,
237 public Listener { 239 public Listener {
238 public: 240 public:
239 Context(Listener* listener, 241 Context(Listener* listener,
240 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread); 242 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_thread);
241 void ClearIPCTaskRunner(); 243 void ClearIPCTaskRunner();
242 base::SingleThreadTaskRunner* ipc_task_runner() const { 244 base::SingleThreadTaskRunner* ipc_task_runner() const {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 305
304 // Methods called on the listener thread. 306 // Methods called on the listener thread.
305 void AddFilter(MessageFilter* filter); 307 void AddFilter(MessageFilter* filter);
306 void OnDispatchConnected(); 308 void OnDispatchConnected();
307 void OnDispatchError(); 309 void OnDispatchError();
308 void OnDispatchBadMessage(const Message& message); 310 void OnDispatchBadMessage(const Message& message);
309 311
310 void SendFromThisThread(Message* message); 312 void SendFromThisThread(Message* message);
311 void ClearChannel(); 313 void ClearChannel();
312 314
313 mojo::AssociatedGroup* associated_group() { return &associated_group_; }
314
315 void AddGenericAssociatedInterface(
316 const std::string& name,
317 const GenericAssociatedInterfaceFactory& factory);
318 void AddGenericAssociatedInterfaceForIOThread(
319 const std::string& name,
320 const GenericAssociatedInterfaceFactory& factory);
321
322 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_; 315 scoped_refptr<base::SingleThreadTaskRunner> listener_task_runner_;
323 Listener* listener_; 316 Listener* listener_;
324 317
325 // List of filters. This is only accessed on the IPC thread. 318 // List of filters. This is only accessed on the IPC thread.
326 std::vector<scoped_refptr<MessageFilter> > filters_; 319 std::vector<scoped_refptr<MessageFilter> > filters_;
327 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; 320 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
328 321
329 // Note, channel_ may be set on the Listener thread or the IPC thread. 322 // Note, channel_ may be set on the Listener thread or the IPC thread.
330 // But once it has been set, it must only be read or cleared on the IPC 323 // But once it has been set, it must only be read or cleared on the IPC
331 // thread. 324 // thread.
(...skipping 21 matching lines...) Expand all
353 346
354 // Cached copy of the peer process ID. Set on IPC but read on both IPC and 347 // Cached copy of the peer process ID. Set on IPC but read on both IPC and
355 // listener threads. 348 // listener threads.
356 base::ProcessId peer_pid_; 349 base::ProcessId peer_pid_;
357 base::Lock peer_pid_lock_; 350 base::Lock peer_pid_lock_;
358 351
359 // Whether this channel is used as an endpoint for sending and receiving 352 // Whether this channel is used as an endpoint for sending and receiving
360 // brokerable attachment messages to/from the broker process. 353 // brokerable attachment messages to/from the broker process.
361 bool attachment_broker_endpoint_; 354 bool attachment_broker_endpoint_;
362 355
363 mojo::AssociatedGroup associated_group_; 356 // Modified only on the listener's thread before Init() is called.
357 std::map<std::string, GenericAssociatedInterfaceFactory>
358 io_thread_interfaces_;
359 std::map<std::string, GenericAssociatedInterfaceFactory>
360 proxy_thread_interfaces_;
364 361
365 // Holds associated interface binders added by AddGenericAssociatedInterface 362 // Valid and constant any time after the ChannelProxy's Listener receives
366 // or AddGenericAssociatedInterfaceForIOThread until the underlying channel 363 // OnChannelConnected on its own thread.
367 // has been initialized. 364 std::unique_ptr<mojo::AssociatedGroup> channel_associated_group_;
368 base::Lock pending_interfaces_lock_;
369 std::vector<std::pair<std::string, GenericAssociatedInterfaceFactory>>
370 pending_interfaces_;
371 }; 365 };
372 366
373 Context* context() { return context_.get(); } 367 Context* context() { return context_.get(); }
374 368
375 #if defined(ENABLE_IPC_FUZZER) 369 #if defined(ENABLE_IPC_FUZZER)
376 OutgoingMessageFilter* outgoing_message_filter() const { 370 OutgoingMessageFilter* outgoing_message_filter() const {
377 return outgoing_message_filter_; 371 return outgoing_message_filter_;
378 } 372 }
379 #endif 373 #endif
380 374
(...skipping 24 matching lines...) Expand all
405 bool did_init_; 399 bool did_init_;
406 400
407 #if defined(ENABLE_IPC_FUZZER) 401 #if defined(ENABLE_IPC_FUZZER)
408 OutgoingMessageFilter* outgoing_message_filter_; 402 OutgoingMessageFilter* outgoing_message_filter_;
409 #endif 403 #endif
410 }; 404 };
411 405
412 } // namespace IPC 406 } // namespace IPC
413 407
414 #endif // IPC_IPC_CHANNEL_PROXY_H_ 408 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_mojo_unittest.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698