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

Unified Diff: ipc/unix_domain_socket_util.h

Issue 12386010: Implement IPC::ChannelFactory, a class that accept()s on a UNIX socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use base::FilePath instead of std::string in ChannelFactory's constructor. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ipc/unix_domain_socket_util.h
diff --git a/ipc/unix_domain_socket_util.h b/ipc/unix_domain_socket_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a31846aeb4cbda9bbc84805b8c7239d154cbe25
--- /dev/null
+++ b/ipc/unix_domain_socket_util.h
@@ -0,0 +1,47 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_UNIX_DOMAIN_SOCKET_UTIL_H_
+#define IPC_UNIX_DOMAIN_SOCKET_UTIL_H_
+
+#include <string>
+#include <sys/types.h>
+
+namespace base {
+class FilePath;
+}
Mark Mentovai 2013/02/28 04:57:56 } // namespace base
jeremya 2013/02/28 05:58:18 I thought we only put the closing comment in when
+
+namespace IPC {
+
+// Creates a UNIX-domain socket at |pipe_name| and bind()s it, then listen()s
+// on it. If successful, |server_listen_fd| will be set to the new file
+// descriptor, and the function will return true. Otherwise returns false.
+bool CreateServerUnixDomainSocket(const base::FilePath& pipe_name,
+ int* server_listen_fd);
+
+// Creates a UNIX-domain socket at |pipe_name| and connect()s to it. If
+// successful, |client_socket| will be set to the new file descriptor, and
+// the function will return true. Otherwise returns false.
+bool CreateClientUnixDomainSocket(const base::FilePath& pipe_name,
+ int* client_socket);
+
+// Gets the effective user ID of the other end of the UNIX-domain socket
+// specified by |fd|. If successful, sets |client_euid| to the uid, and returns
+// true. Otherwise returns false.
+bool GetPeerEuid(int fd, uid_t* client_euid);
+
+// Accepts a client attempting to connect to |server_listen_fd|, storing the
+// new file descriptor for the connection in |server_socket| and returning true
+// if successful.
+bool ServerAcceptConnection(int server_listen_fd, int* server_socket);
+
+// The maximum length of the name of a pipe for MODE_NAMED_SERVER or
+// MODE_NAMED_CLIENT if you want to pass in your own socket.
+// The standard size on linux is 108, mac is 104. To maintain consistency
+// across platforms we standardize on the smaller value.
+static const size_t kMaxPipeNameLength = 104;
+
+}
Mark Mentovai 2013/02/28 04:57:56 } // namespace IPC
jeremya 2013/02/28 05:58:18 Done.
+
+#endif // IPC_UNIX_DOMAIN_SOCKET_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698