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

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: Rebase (scoped_ptr->std::unique_ptr) Created 4 years, 7 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const IPC::ChannelHandle& channel_handle, 159 const IPC::ChannelHandle& channel_handle,
160 Listener* listener); 160 Listener* listener);
161 161
162 ~Channel() override; 162 ~Channel() override;
163 163
164 // Connect the pipe. On the server side, this will initiate 164 // Connect the pipe. On the server side, this will initiate
165 // waiting for connections. On the client, it attempts to 165 // waiting for connections. On the client, it attempts to
166 // connect to a pre-existing pipe. Note, calling Connect() 166 // connect to a pre-existing pipe. Note, calling Connect()
167 // will not block the calling thread and may complete 167 // will not block the calling thread and may complete
168 // asynchronously. 168 // asynchronously.
169 //
170 // The subclass implementation must call WillConnect() at the beginning of its
171 // implementation.
169 virtual bool Connect() WARN_UNUSED_RESULT = 0; 172 virtual bool Connect() WARN_UNUSED_RESULT = 0;
170 173
171 // Close this Channel explicitly. May be called multiple times. 174 // Close this Channel explicitly. May be called multiple times.
172 // On POSIX calling close on an IPC channel that listens for connections will 175 // On POSIX calling close on an IPC channel that listens for connections will
173 // cause it to close any accepted connections, and it will stop listening for 176 // cause it to close any accepted connections, and it will stop listening for
174 // new connections. If you just want to close the currently accepted 177 // new connections. If you just want to close the currently accepted
175 // connection and listen for new ones, use ResetToAcceptingConnectionState. 178 // connection and listen for new ones, use ResetToAcceptingConnectionState.
176 virtual void Close() = 0; 179 virtual void Close() = 0;
177 180
178 // Get its own process id. This value is told to the peer. 181 // Get its own process id. This value is told to the peer.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ~OutputElement(); 252 ~OutputElement();
250 size_t size() const { return message_ ? message_->size() : length_; } 253 size_t size() const { return message_ ? message_->size() : length_; }
251 const void* data() const { return message_ ? message_->data() : buffer_; } 254 const void* data() const { return message_ ? message_->data() : buffer_; }
252 Message* get_message() const { return message_.get(); } 255 Message* get_message() const { return message_.get(); }
253 256
254 private: 257 private:
255 std::unique_ptr<Message> message_; 258 std::unique_ptr<Message> message_;
256 void* buffer_; 259 void* buffer_;
257 size_t length_; 260 size_t length_;
258 }; 261 };
262
263 // Endpoint overrides.
264 void OnSetAttachmentBrokerEndpoint() override;
265
266 // Subclasses must call this method at the beginning of their implementation
267 // of Connect().
268 void WillConnect();
269
270 private:
271 bool did_start_connect_ = false;
259 }; 272 };
260 273
261 #if defined(OS_POSIX) 274 #if defined(OS_POSIX)
262 // SocketPair() creates a pair of socket FDs suitable for using with 275 // SocketPair() creates a pair of socket FDs suitable for using with
263 // IPC::Channel. 276 // IPC::Channel.
264 IPC_EXPORT bool SocketPair(int* fd1, int* fd2); 277 IPC_EXPORT bool SocketPair(int* fd1, int* fd2);
265 #endif 278 #endif
266 279
267 } // namespace IPC 280 } // namespace IPC
268 281
269 #endif // IPC_IPC_CHANNEL_H_ 282 #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