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

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

Issue 2845113005: Replace base::SharedMemory read-only methods with GetReadOnlyHandle. (Closed)
Patch Set: Comments from thakis. Created 3 years, 7 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
« no previous file with comments | « base/memory/shared_memory_android.cc ('k') | base/memory/shared_memory_mac.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_helper.h" 5 #include "base/memory/shared_memory_helper.h"
6 6
7 #include "base/threading/thread_restrictions.h" 7 #include "base/threading/thread_restrictions.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 30 matching lines...) Expand all
41 41
42 if (!*fp) 42 if (!*fp)
43 return false; 43 return false;
44 44
45 // Deleting the file prevents anyone else from mapping it in (making it 45 // Deleting the file prevents anyone else from mapping it in (making it
46 // private), and prevents the need for cleanup (once the last fd is 46 // private), and prevents the need for cleanup (once the last fd is
47 // closed, it is truly freed). 47 // closed, it is truly freed).
48 path_unlinker.reset(path); 48 path_unlinker.reset(path);
49 49
50 if (options.share_read_only) { 50 if (options.share_read_only) {
51 // Also open as readonly so that we can ShareReadOnlyToProcess. 51 // Also open as readonly so that we can GetReadOnlyHandle.
52 readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY))); 52 readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY)));
53 if (!readonly_fd->is_valid()) { 53 if (!readonly_fd->is_valid()) {
54 DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed"; 54 DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed";
55 fp->reset(); 55 fp->reset();
56 return false; 56 return false;
57 } 57 }
58 } 58 }
59 return true; 59 return true;
60 } 60 }
61 61
(...skipping 27 matching lines...) Expand all
89 if (*mapped_file == -1) { 89 if (*mapped_file == -1) {
90 NOTREACHED() << "Call to dup failed, errno=" << errno; 90 NOTREACHED() << "Call to dup failed, errno=" << errno;
91 } 91 }
92 *readonly_mapped_file = readonly_fd.release(); 92 *readonly_mapped_file = readonly_fd.release();
93 93
94 return true; 94 return true;
95 } 95 }
96 #endif // !defined(OS_ANDROID) 96 #endif // !defined(OS_ANDROID)
97 97
98 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_android.cc ('k') | base/memory/shared_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698