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

Side by Side Diff: ipc/ipc_channel.h

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: runtime error Created 4 years, 8 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/attachment_broker_privileged_win_unittest.cc ('k') | ipc/ipc_channel_common.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_H_ 5 #ifndef IPC_IPC_CHANNEL_H_
6 #define IPC_IPC_CHANNEL_H_ 6 #define IPC_IPC_CHANNEL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const IPC::ChannelHandle& channel_handle, 158 const IPC::ChannelHandle& channel_handle,
159 Listener* listener); 159 Listener* listener);
160 160
161 ~Channel() override; 161 ~Channel() override;
162 162
163 // Connect the pipe. On the server side, this will initiate 163 // Connect the pipe. On the server side, this will initiate
164 // waiting for connections. On the client, it attempts to 164 // waiting for connections. On the client, it attempts to
165 // connect to a pre-existing pipe. Note, calling Connect() 165 // connect to a pre-existing pipe. Note, calling Connect()
166 // will not block the calling thread and may complete 166 // will not block the calling thread and may complete
167 // asynchronously. 167 // asynchronously.
168 //
169 // The subclass implementation must call OnConnect().
Tom Sepez 2016/04/22 00:33:22 nit: when? "when the connection is completed"? or
erikchen 2016/04/22 01:42:18 I renamed the method to WillConnect() and updated
168 virtual bool Connect() WARN_UNUSED_RESULT = 0; 170 virtual bool Connect() WARN_UNUSED_RESULT = 0;
169 171
170 // Close this Channel explicitly. May be called multiple times. 172 // Close this Channel explicitly. May be called multiple times.
171 // On POSIX calling close on an IPC channel that listens for connections will 173 // On POSIX calling close on an IPC channel that listens for connections will
172 // cause it to close any accepted connections, and it will stop listening for 174 // cause it to close any accepted connections, and it will stop listening for
173 // new connections. If you just want to close the currently accepted 175 // new connections. If you just want to close the currently accepted
174 // connection and listen for new ones, use ResetToAcceptingConnectionState. 176 // connection and listen for new ones, use ResetToAcceptingConnectionState.
175 virtual void Close() = 0; 177 virtual void Close() = 0;
176 178
177 // Get its own process id. This value is told to the peer. 179 // Get its own process id. This value is told to the peer.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ~OutputElement(); 250 ~OutputElement();
249 size_t size() const { return message_ ? message_->size() : length_; } 251 size_t size() const { return message_ ? message_->size() : length_; }
250 const void* data() const { return message_ ? message_->data() : buffer_; } 252 const void* data() const { return message_ ? message_->data() : buffer_; }
251 Message* get_message() const { return message_.get(); } 253 Message* get_message() const { return message_.get(); }
252 254
253 private: 255 private:
254 scoped_ptr<Message> message_; 256 scoped_ptr<Message> message_;
255 void* buffer_; 257 void* buffer_;
256 size_t length_; 258 size_t length_;
257 }; 259 };
260
261 // Endpoint overrides.
262 void OnSetAttachmentBrokerEndpoint() override;
263
264 // Subclasses should call this method after connecting.
Tom Sepez 2016/04/22 00:33:22 should vs. must?
erikchen 2016/04/22 01:42:18 Updated the comment to use MUST.
265 void OnConnect();
266
267 private:
268 bool did_connect_ = false;
258 }; 269 };
259 270
260 #if defined(OS_POSIX) 271 #if defined(OS_POSIX)
261 // SocketPair() creates a pair of socket FDs suitable for using with 272 // SocketPair() creates a pair of socket FDs suitable for using with
262 // IPC::Channel. 273 // IPC::Channel.
263 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); 274 IPC_EXPORT bool SocketPair(int* fd1, int* fd2);
264 #endif 275 #endif
265 276
266 } // namespace IPC 277 } // namespace IPC
267 278
268 #endif // IPC_IPC_CHANNEL_H_ 279 #endif // IPC_IPC_CHANNEL_H_
OLDNEW
« no previous file with comments | « ipc/attachment_broker_privileged_win_unittest.cc ('k') | ipc/ipc_channel_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698