OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/files/files_impl.h" | 5 #include "services/files/files_impl.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 base::ScopedFD CreateAndOpenTemporaryDirectory( | 26 base::ScopedFD CreateAndOpenTemporaryDirectory( |
27 scoped_ptr<base::ScopedTempDir>* temp_dir) { | 27 scoped_ptr<base::ScopedTempDir>* temp_dir) { |
28 (*temp_dir).reset(new base::ScopedTempDir()); | 28 (*temp_dir).reset(new base::ScopedTempDir()); |
29 CHECK((*temp_dir)->CreateUniqueTempDir()); | 29 CHECK((*temp_dir)->CreateUniqueTempDir()); |
30 | 30 |
31 base::ScopedFD temp_dir_fd(HANDLE_EINTR( | 31 base::ScopedFD temp_dir_fd(HANDLE_EINTR( |
32 open((*temp_dir)->path().value().c_str(), O_RDONLY | O_DIRECTORY, 0))); | 32 open((*temp_dir)->path().value().c_str(), O_RDONLY | O_DIRECTORY, 0))); |
33 PCHECK(temp_dir_fd.is_valid()); | 33 PCHECK(temp_dir_fd.is_valid()); |
34 DVLOG(1) << "Made a temporary directory: " << (*temp_dir)->path().value(); | 34 DVLOG(1) << "Made a temporary directory: " << (*temp_dir)->path().value(); |
35 return temp_dir_fd.Pass(); | 35 return temp_dir_fd; |
36 } | 36 } |
37 | 37 |
38 #ifndef NDEBUG | 38 #ifndef NDEBUG |
39 base::ScopedFD OpenMojoDebugDirectory() { | 39 base::ScopedFD OpenMojoDebugDirectory() { |
40 const char* home_dir_name = getenv("HOME"); | 40 const char* home_dir_name = getenv("HOME"); |
41 if (!home_dir_name || !home_dir_name[0]) { | 41 if (!home_dir_name || !home_dir_name[0]) { |
42 LOG(ERROR) << "HOME not set"; | 42 LOG(ERROR) << "HOME not set"; |
43 return base::ScopedFD(); | 43 return base::ScopedFD(); |
44 } | 44 } |
45 base::FilePath mojo_debug_dir_name = | 45 base::FilePath mojo_debug_dir_name = |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 callback.Run(Error::UNIMPLEMENTED); | 87 callback.Run(Error::UNIMPLEMENTED); |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 new DirectoryImpl(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); | 91 new DirectoryImpl(directory.Pass(), dir_fd.Pass(), temp_dir.Pass()); |
92 callback.Run(Error::OK); | 92 callback.Run(Error::OK); |
93 } | 93 } |
94 | 94 |
95 } // namespace files | 95 } // namespace files |
96 } // namespace mojo | 96 } // namespace mojo |
OLD | NEW |