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

Side by Side Diff: ipc/ipc_channel_proxy.h

Issue 1270683002: ipc: Make a common subclass for Channel and ProxyChannel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase errors. Created 5 years, 4 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.h ('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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
14 #include "ipc/ipc_channel.h" 14 #include "ipc/ipc_channel.h"
15 #include "ipc/ipc_channel_handle.h" 15 #include "ipc/ipc_channel_handle.h"
16 #include "ipc/ipc_endpoint.h"
16 #include "ipc/ipc_listener.h" 17 #include "ipc/ipc_listener.h"
17 #include "ipc/ipc_sender.h" 18 #include "ipc/ipc_sender.h"
18 19
19 namespace base { 20 namespace base {
20 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
21 } 22 }
22 23
23 namespace IPC { 24 namespace IPC {
24 25
25 class ChannelFactory; 26 class ChannelFactory;
(...skipping 30 matching lines...) Expand all
56 // instance where the IPC::Channel will be created and operated. 57 // instance where the IPC::Channel will be created and operated.
57 // 58 //
58 // Thread-safe send 59 // Thread-safe send
59 // 60 //
60 // If a particular |Channel| implementation has a thread-safe |Send()| operation 61 // If a particular |Channel| implementation has a thread-safe |Send()| operation
61 // then ChannelProxy skips the inter-thread hop and calls |Send()| directly. In 62 // then ChannelProxy skips the inter-thread hop and calls |Send()| directly. In
62 // this case the |channel_| variable is touched by multiple threads so 63 // this case the |channel_| variable is touched by multiple threads so
63 // |channel_lifetime_lock_| is used to protect it. The locking overhead is only 64 // |channel_lifetime_lock_| is used to protect it. The locking overhead is only
64 // paid if the underlying channel supports thread-safe |Send|. 65 // paid if the underlying channel supports thread-safe |Send|.
65 // 66 //
66 class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe { 67 class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
67 public: 68 public:
68 #if defined(ENABLE_IPC_FUZZER) 69 #if defined(ENABLE_IPC_FUZZER)
69 // Interface for a filter to be imposed on outgoing messages which can 70 // Interface for a filter to be imposed on outgoing messages which can
70 // re-write the message. Used for testing. 71 // re-write the message. Used for testing.
71 class OutgoingMessageFilter { 72 class OutgoingMessageFilter {
72 public: 73 public:
73 virtual Message* Rewrite(Message* message) = 0; 74 virtual Message* Rewrite(Message* message) = 0;
74 }; 75 };
75 #endif 76 #endif
76 77
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 #if defined(ENABLE_IPC_FUZZER) 142 #if defined(ENABLE_IPC_FUZZER)
142 void set_outgoing_message_filter(OutgoingMessageFilter* filter) { 143 void set_outgoing_message_filter(OutgoingMessageFilter* filter) {
143 outgoing_message_filter_ = filter; 144 outgoing_message_filter_ = filter;
144 } 145 }
145 #endif 146 #endif
146 147
147 // Called to clear the pointer to the IPC task runner when it's going away. 148 // Called to clear the pointer to the IPC task runner when it's going away.
148 void ClearIPCTaskRunner(); 149 void ClearIPCTaskRunner();
149 150
150 // Get the process ID for the connected peer. 151 // Endpoint overrides.
151 // Returns base::kNullProcessId if the peer is not connected yet. 152 base::ProcessId GetPeerPID() const override;
152 base::ProcessId GetPeerPID() const { return context_->peer_pid_; } 153 void OnSetAttachmentBrokerEndpoint() override;
153 154
154 #if defined(OS_POSIX) && !defined(OS_NACL_SFI) 155 #if defined(OS_POSIX) && !defined(OS_NACL_SFI)
155 // Calls through to the underlying channel's methods. 156 // Calls through to the underlying channel's methods.
156 int GetClientFileDescriptor(); 157 int GetClientFileDescriptor();
157 base::ScopedFD TakeClientFileDescriptor(); 158 base::ScopedFD TakeClientFileDescriptor();
158 #endif 159 #endif
159 160
160 void SetAttachmentBrokerEndpoint(bool is_endpoint);
161
162 protected: 161 protected:
163 class Context; 162 class Context;
164 // A subclass uses this constructor if it needs to add more information 163 // A subclass uses this constructor if it needs to add more information
165 // to the internal state. 164 // to the internal state.
166 ChannelProxy(Context* context); 165 ChannelProxy(Context* context);
167 166
168 ChannelProxy( 167 ChannelProxy(
169 Listener* listener, 168 Listener* listener,
170 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); 169 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
171 170
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 bool did_init_; 306 bool did_init_;
308 307
309 #if defined(ENABLE_IPC_FUZZER) 308 #if defined(ENABLE_IPC_FUZZER)
310 OutgoingMessageFilter* outgoing_message_filter_; 309 OutgoingMessageFilter* outgoing_message_filter_;
311 #endif 310 #endif
312 }; 311 };
313 312
314 } // namespace IPC 313 } // namespace IPC
315 314
316 #endif // IPC_IPC_CHANNEL_PROXY_H_ 315 #endif // IPC_IPC_CHANNEL_PROXY_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698