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

Unified Diff: base/memory/shared_memory_posix.cc

Issue 2875453002: Add a size parameter to SharedMemoryHandle. (Closed)
Patch Set: Remove extraneous period. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | base/memory/shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_posix.cc
diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc
index 5d71c300ebe6379ad1839b3f7ddb94acd7a271ca..91fd3529e0f7dae080b558de42bee6de77193740 100644
--- a/base/memory/shared_memory_posix.cc
+++ b/base/memory/shared_memory_posix.cc
@@ -76,19 +76,6 @@ bool SharedMemory::CreateAndMapAnonymous(size_t size) {
}
#if !defined(OS_ANDROID)
-// static
-bool SharedMemory::GetSizeFromSharedMemoryHandle(
- const SharedMemoryHandle& handle,
- size_t* size) {
- struct stat st;
- if (fstat(handle.GetHandle(), &st) != 0)
- return false;
- if (st.st_size < 0)
- return false;
- *size = st.st_size;
- return true;
-}
-
// Chromium mostly only uses the unique/private shmem as specified by
// "name == L"". The exception is in the StatsTable.
// TODO(jrg): there is no way to "clean up" all unused named shmem if
@@ -209,9 +196,10 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
PrepareMapFile(std::move(fp), std::move(readonly_fd), &mapped_file,
&readonly_mapped_file, &last_error_);
shm_ = SharedMemoryHandle(base::FileDescriptor(mapped_file, false),
- UnguessableToken::Create());
- readonly_shm_ = SharedMemoryHandle(
- base::FileDescriptor(readonly_mapped_file, false), shm_.GetGUID());
+ options.size, UnguessableToken::Create());
+ readonly_shm_ =
+ SharedMemoryHandle(base::FileDescriptor(readonly_mapped_file, false),
+ options.size, shm_.GetGUID());
return result;
}
@@ -257,10 +245,12 @@ bool SharedMemory::Open(const std::string& name, bool read_only) {
// region. We don't do that - this means that we will overcount this memory,
// which thankfully isn't relevant since Chrome only communicates with a
// single version of the service process.
- shm_ = SharedMemoryHandle(base::FileDescriptor(mapped_file, false),
+ // We pass the size |0|, which is a dummy size and wrong, but otherwise
+ // harmless.
+ shm_ = SharedMemoryHandle(base::FileDescriptor(mapped_file, false), 0u,
UnguessableToken::Create());
readonly_shm_ = SharedMemoryHandle(
- base::FileDescriptor(readonly_mapped_file, false), shm_.GetGUID());
+ base::FileDescriptor(readonly_mapped_file, false), 0, shm_.GetGUID());
return result;
}
#endif // !defined(OS_ANDROID)
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | base/memory/shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698