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

Side by Side Diff: base/memory/shared_memory_posix.cc

Issue 99923002: Move temp file 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 | « base/files/scoped_temp_dir_unittest.cc ('k') | base/test/launcher/test_launcher.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 bool fix_size = true; 134 bool fix_size = true;
135 int readonly_fd_storage = -1; 135 int readonly_fd_storage = -1;
136 ScopedFD readonly_fd(&readonly_fd_storage); 136 ScopedFD readonly_fd(&readonly_fd_storage);
137 137
138 FilePath path; 138 FilePath path;
139 if (options.name == NULL || options.name->empty()) { 139 if (options.name == NULL || options.name->empty()) {
140 // It doesn't make sense to have a open-existing private piece of shmem 140 // It doesn't make sense to have a open-existing private piece of shmem
141 DCHECK(!options.open_existing); 141 DCHECK(!options.open_existing);
142 // Q: Why not use the shm_open() etc. APIs? 142 // Q: Why not use the shm_open() etc. APIs?
143 // A: Because they're limited to 4mb on OS X. FFFFFFFUUUUUUUUUUU 143 // A: Because they're limited to 4mb on OS X. FFFFFFFUUUUUUUUUUU
144 fp.reset( 144 fp.reset(base::CreateAndOpenTemporaryShmemFile(&path, options.executable));
145 file_util::CreateAndOpenTemporaryShmemFile(&path, options.executable));
146 145
147 if (fp) { 146 if (fp) {
148 // Also open as readonly so that we can ShareReadOnlyToProcess. 147 // Also open as readonly so that we can ShareReadOnlyToProcess.
149 *readonly_fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)); 148 *readonly_fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY));
150 if (*readonly_fd < 0) { 149 if (*readonly_fd < 0) {
151 DPLOG(ERROR) << "open(\"" << path.value() << "\", O_RDONLY) failed"; 150 DPLOG(ERROR) << "open(\"" << path.value() << "\", O_RDONLY) failed";
152 fp.reset(); 151 fp.reset();
153 } 152 }
154 // Deleting the file prevents anyone else from mapping it in (making it 153 // Deleting the file prevents anyone else from mapping it in (making it
155 // private), and prevents the need for cleanup (once the last fd is 154 // private), and prevents the need for cleanup (once the last fd is
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 new_handle->fd = new_fd; 459 new_handle->fd = new_fd;
461 new_handle->auto_close = true; 460 new_handle->auto_close = true;
462 461
463 if (close_self) 462 if (close_self)
464 Close(); 463 Close();
465 464
466 return true; 465 return true;
467 } 466 }
468 467
469 } // namespace base 468 } // namespace base
OLDNEW
« no previous file with comments | « base/files/scoped_temp_dir_unittest.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698