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

Side by Side Diff: ipc/unix_domain_socket_util.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | mojo/shell/storage.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ipc/unix_domain_socket_util.h" 5 #include "ipc/unix_domain_socket_util.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 base::FilePath socket_dir = socket_path.DirName(); 77 base::FilePath socket_dir = socket_path.DirName();
78 78
79 struct sockaddr_un unix_addr; 79 struct sockaddr_un unix_addr;
80 size_t unix_addr_len; 80 size_t unix_addr_len;
81 int fd = MakeUnixAddrForPath(socket_name, &unix_addr, &unix_addr_len); 81 int fd = MakeUnixAddrForPath(socket_name, &unix_addr, &unix_addr_len);
82 if (fd < 0) 82 if (fd < 0)
83 return false; 83 return false;
84 file_util::ScopedFD scoped_fd(&fd); 84 file_util::ScopedFD scoped_fd(&fd);
85 85
86 // Make sure the path we need exists. 86 // Make sure the path we need exists.
87 if (!file_util::CreateDirectory(socket_dir)) { 87 if (!base::CreateDirectory(socket_dir)) {
88 LOG(ERROR) << "Couldn't create directory: " << socket_dir.value(); 88 LOG(ERROR) << "Couldn't create directory: " << socket_dir.value();
89 return false; 89 return false;
90 } 90 }
91 91
92 // Delete any old FS instances. 92 // Delete any old FS instances.
93 if (unlink(socket_name.c_str()) < 0 && errno != ENOENT) { 93 if (unlink(socket_name.c_str()) < 0 && errno != ENOENT) {
94 PLOG(ERROR) << "unlink " << socket_name; 94 PLOG(ERROR) << "unlink " << socket_name;
95 return false; 95 return false;
96 } 96 }
97 97
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // It's safe to keep listening on |server_listen_fd| even if the attempt to 193 // It's safe to keep listening on |server_listen_fd| even if the attempt to
194 // set O_NONBLOCK failed on the client fd. 194 // set O_NONBLOCK failed on the client fd.
195 return true; 195 return true;
196 } 196 }
197 197
198 *server_socket = *scoped_fd.release(); 198 *server_socket = *scoped_fd.release();
199 return true; 199 return true;
200 } 200 }
201 201
202 } // namespace IPC 202 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix_unittest.cc ('k') | mojo/shell/storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698