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

Side by Side Diff: net/socket/unix_domain_server_socket_posix.h

Issue 1892323002: Change scoped_ptr to std::unique_ptr in //net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ 5 #ifndef NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_
6 #define NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ 6 #define NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 #include "net/socket/server_socket.h" 17 #include "net/socket/server_socket.h"
18 #include "net/socket/socket_descriptor.h" 18 #include "net/socket/socket_descriptor.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 class SocketPosix; 22 class SocketPosix;
23 23
24 // Unix Domain Server Socket Implementation. Supports abstract namespaces on 24 // Unix Domain Server Socket Implementation. Supports abstract namespaces on
25 // Linux and Android. 25 // Linux and Android.
(...skipping 23 matching lines...) Expand all
49 // Gets credentials of peer to check permissions. 49 // Gets credentials of peer to check permissions.
50 static bool GetPeerCredentials(SocketDescriptor socket_fd, 50 static bool GetPeerCredentials(SocketDescriptor socket_fd,
51 Credentials* credentials); 51 Credentials* credentials);
52 52
53 // ServerSocket implementation. 53 // ServerSocket implementation.
54 int Listen(const IPEndPoint& address, int backlog) override; 54 int Listen(const IPEndPoint& address, int backlog) override;
55 int ListenWithAddressAndPort(const std::string& address_string, 55 int ListenWithAddressAndPort(const std::string& address_string,
56 uint16_t port, 56 uint16_t port,
57 int backlog) override; 57 int backlog) override;
58 int GetLocalAddress(IPEndPoint* address) const override; 58 int GetLocalAddress(IPEndPoint* address) const override;
59 int Accept(scoped_ptr<StreamSocket>* socket, 59 int Accept(std::unique_ptr<StreamSocket>* socket,
60 const CompletionCallback& callback) override; 60 const CompletionCallback& callback) override;
61 61
62 // Creates a server socket, binds it to the specified |socket_path| and 62 // Creates a server socket, binds it to the specified |socket_path| and
63 // starts listening for incoming connections with the specified |backlog|. 63 // starts listening for incoming connections with the specified |backlog|.
64 int BindAndListen(const std::string& socket_path, int backlog); 64 int BindAndListen(const std::string& socket_path, int backlog);
65 65
66 // Accepts an incoming connection on |listen_socket_|, but passes back 66 // Accepts an incoming connection on |listen_socket_|, but passes back
67 // a raw SocketDescriptor instead of a StreamSocket. 67 // a raw SocketDescriptor instead of a StreamSocket.
68 int AcceptSocketDescriptor(SocketDescriptor* socket_descriptor, 68 int AcceptSocketDescriptor(SocketDescriptor* socket_descriptor,
69 const CompletionCallback& callback); 69 const CompletionCallback& callback);
70 70
71 private: 71 private:
72 // A callback to wrap the setting of the out-parameter to Accept(). 72 // A callback to wrap the setting of the out-parameter to Accept().
73 // This allows the internal machinery of that call to be implemented in 73 // This allows the internal machinery of that call to be implemented in
74 // a manner that's agnostic to the caller's desired output. 74 // a manner that's agnostic to the caller's desired output.
75 typedef base::Callback<void(scoped_ptr<SocketPosix>)> SetterCallback; 75 typedef base::Callback<void(std::unique_ptr<SocketPosix>)> SetterCallback;
76 76
77 int DoAccept(const SetterCallback& setter_callback, 77 int DoAccept(const SetterCallback& setter_callback,
78 const CompletionCallback& callback); 78 const CompletionCallback& callback);
79 void AcceptCompleted(const SetterCallback& setter_callback, 79 void AcceptCompleted(const SetterCallback& setter_callback,
80 const CompletionCallback& callback, 80 const CompletionCallback& callback,
81 int rv); 81 int rv);
82 bool AuthenticateAndGetStreamSocket(const SetterCallback& setter_callback); 82 bool AuthenticateAndGetStreamSocket(const SetterCallback& setter_callback);
83 83
84 scoped_ptr<SocketPosix> listen_socket_; 84 std::unique_ptr<SocketPosix> listen_socket_;
85 const AuthCallback auth_callback_; 85 const AuthCallback auth_callback_;
86 const bool use_abstract_namespace_; 86 const bool use_abstract_namespace_;
87 87
88 scoped_ptr<SocketPosix> accept_socket_; 88 std::unique_ptr<SocketPosix> accept_socket_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocket); 90 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocket);
91 }; 91 };
92 92
93 } // namespace net 93 } // namespace net
94 94
95 #endif // NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_ 95 #endif // NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_
OLDNEW
« no previous file with comments | « net/socket/unix_domain_client_socket_posix_unittest.cc ('k') | net/socket/unix_domain_server_socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698