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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 310853003: Add IPC::ChannelProxy::Create() and IPC::SyncChannel::Create() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landing Created 6 years, 6 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/common/gpu/gpu_channel.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { 57 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
58 public: 58 public:
59 // Initializes a channel proxy. The channel_handle and mode parameters are 59 // Initializes a channel proxy. The channel_handle and mode parameters are
60 // passed directly to the underlying IPC::Channel. The listener is called on 60 // passed directly to the underlying IPC::Channel. The listener is called on
61 // the thread that creates the ChannelProxy. The filter's OnMessageReceived 61 // the thread that creates the ChannelProxy. The filter's OnMessageReceived
62 // method is called on the thread where the IPC::Channel is running. The 62 // method is called on the thread where the IPC::Channel is running. The
63 // filter may be null if the consumer is not interested in handling messages 63 // filter may be null if the consumer is not interested in handling messages
64 // on the background thread. Any message not handled by the filter will be 64 // on the background thread. Any message not handled by the filter will be
65 // dispatched to the listener. The given task runner correspond to a thread 65 // dispatched to the listener. The given task runner correspond to a thread
66 // on which IPC::Channel is created and used (e.g. IO thread). 66 // on which IPC::Channel is created and used (e.g. IO thread).
67 ChannelProxy(const IPC::ChannelHandle& channel_handle, 67 static scoped_ptr<ChannelProxy> Create(
68 Channel::Mode mode, 68 const IPC::ChannelHandle& channel_handle,
69 Listener* listener, 69 Channel::Mode mode,
70 base::SingleThreadTaskRunner* ipc_task_runner); 70 Listener* listener,
71 base::SingleThreadTaskRunner* ipc_task_runner);
71 72
72 virtual ~ChannelProxy(); 73 virtual ~ChannelProxy();
73 74
74 // Initializes the channel proxy. Only call this once to initialize a channel 75 // Initializes the channel proxy. Only call this once to initialize a channel
75 // proxy that was not initialized in its constructor. If create_pipe_now is 76 // proxy that was not initialized in its constructor. If create_pipe_now is
76 // true, the pipe is created synchronously. Otherwise it's created on the IO 77 // true, the pipe is created synchronously. Otherwise it's created on the IO
77 // thread. 78 // thread.
78 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, 79 void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode,
79 bool create_pipe_now); 80 bool create_pipe_now);
80 81
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int TakeClientFileDescriptor(); 118 int TakeClientFileDescriptor();
118 bool GetPeerEuid(uid_t* peer_euid) const; 119 bool GetPeerEuid(uid_t* peer_euid) const;
119 #endif // defined(OS_POSIX) 120 #endif // defined(OS_POSIX)
120 121
121 protected: 122 protected:
122 class Context; 123 class Context;
123 // A subclass uses this constructor if it needs to add more information 124 // A subclass uses this constructor if it needs to add more information
124 // to the internal state. 125 // to the internal state.
125 ChannelProxy(Context* context); 126 ChannelProxy(Context* context);
126 127
128 ChannelProxy(Listener* listener,
129 base::SingleThreadTaskRunner* ipc_task_runner);
130
127 // Used internally to hold state that is referenced on the IPC thread. 131 // Used internally to hold state that is referenced on the IPC thread.
128 class Context : public base::RefCountedThreadSafe<Context>, 132 class Context : public base::RefCountedThreadSafe<Context>,
129 public Listener { 133 public Listener {
130 public: 134 public:
131 Context(Listener* listener, base::SingleThreadTaskRunner* ipc_thread); 135 Context(Listener* listener, base::SingleThreadTaskRunner* ipc_thread);
132 void ClearIPCTaskRunner(); 136 void ClearIPCTaskRunner();
133 base::SingleThreadTaskRunner* ipc_task_runner() const { 137 base::SingleThreadTaskRunner* ipc_task_runner() const {
134 return ipc_task_runner_.get(); 138 return ipc_task_runner_.get();
135 } 139 }
136 const std::string& channel_id() const { return channel_id_; } 140 const std::string& channel_id() const { return channel_id_; }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // that involves this data. 225 // that involves this data.
222 scoped_refptr<Context> context_; 226 scoped_refptr<Context> context_;
223 227
224 // Whether the channel has been initialized. 228 // Whether the channel has been initialized.
225 bool did_init_; 229 bool did_init_;
226 }; 230 };
227 231
228 } // namespace IPC 232 } // namespace IPC
229 233
230 #endif // IPC_IPC_CHANNEL_PROXY_H_ 234 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698