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

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

Issue 348803003: Refactor tcp socket and unix domain socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix net_unittests for iOS 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_
6 #define NET_SOCKET_UNIX_DOMAIN_SERVER_SOCKET_POSIX_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
mmenke 2014/06/26 15:36:12 nit: include macros.h instead, to make sure we ge
byungchul 2014/06/26 18:09:24 Done.
11 #include "net/base/net_export.h"
12 #include "net/socket/server_socket.h"
13 #include "net/socket/socket_descriptor.h"
14
15 namespace net {
16
17 class SocketLibevent;
18
19 // Unix Domain Server Socket Implementation. Supports abstract namespaces on
20 // Linux.
21 class NET_EXPORT UnixDomainServerSocket : public ServerSocket {
22 public:
23 // Callback that returns whether the already connected client, identified by
24 // its process |user_id| and |group_id|, is allowed to keep the connection
25 // open. Note that the socket is closed immediately in case the callback
26 // returns false.
27 typedef base::Callback<bool (uid_t user_id, gid_t group_id)> AuthCallback;
mmenke 2014/06/26 15:36:12 Should include callback.h or callback_forward.h.
byungchul 2014/06/26 18:09:24 Done.
28
29 UnixDomainServerSocket(const AuthCallback& auth_callack,
30 bool use_abstract_namespace);
31 virtual ~UnixDomainServerSocket();
32
33 // Gets UID and GID of peer to check permissions.
34 static bool GetPeerIds(SocketDescriptor socket_fd,
35 uid_t* user_id,
36 gid_t* group_id);
mmenke 2014/06/26 15:36:12 You should include the headers for uid_t and git_t
byungchul 2014/06/26 18:09:24 Done.
37
38 // ServerSocket implementation.
39 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE;
40 virtual int ListenWithAddressAndPort(const std::string& unix_domain_path,
41 int port_unused,
42 int backlog) OVERRIDE;
43 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
44 virtual int Accept(scoped_ptr<StreamSocket>* socket,
45 const CompletionCallback& callback) OVERRIDE;
46 private:
mmenke 2014/06/26 15:36:12 nit: Blank line before private.
byungchul 2014/06/26 18:09:24 Done.
47 void AcceptCompleted(scoped_ptr<StreamSocket>* socket,
48 const CompletionCallback& callback,
49 int rv);
50 bool AuthenticateAndGetStreamSocket(scoped_ptr<StreamSocket>* socket);
51
52 scoped_ptr<SocketLibevent> listen_socket_;
53 const AuthCallback auth_callback_;
54 const bool use_abstract_namespace_;
55
56 scoped_ptr<SocketLibevent> accept_socket_;
mmenke 2014/06/26 15:36:12 nit: Include base/memory/scoped_ptr.h (Parent int
byungchul 2014/06/26 18:09:24 Done.
57
58 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocket);
59 };
60
61 } // namespace net
62
63 #endif // NET_SOCKET_UNIX_DOMAIN_SOCKET_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698