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

Unified Diff: base/memory/shared_memory_win.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_unittest.cc ('k') | base/metrics/field_trial.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_win.cc
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc
index f88f6cd9299131cf3ed0c79d7394cfb44d136163..3839f447abb3f98f4b6347ee32ba35f601d29604 100644
--- a/base/memory/shared_memory_win.cc
+++ b/base/memory/shared_memory_win.cc
@@ -227,7 +227,7 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
DCHECK(!name_.empty());
shm_ = SharedMemoryHandle(
CreateFileMappingWithReducedPermissions(&sa, rounded_size, name_.c_str()),
- UnguessableToken::Create());
+ rounded_size, UnguessableToken::Create());
if (!shm_.IsValid()) {
// The error is logged within CreateFileMappingWithReducedPermissions().
return false;
@@ -274,9 +274,11 @@ 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.
+ // We pass the size |0|, which is a dummy size and wrong, but otherwise
+ // harmless.
shm_ = SharedMemoryHandle(
OpenFileMapping(access, false, name_.empty() ? nullptr : name_.c_str()),
- UnguessableToken::Create());
+ 0u, UnguessableToken::Create());
if (!shm_.IsValid())
return false;
// If a name specified assume it's an external section.
@@ -328,7 +330,8 @@ SharedMemoryHandle SharedMemory::GetReadOnlyHandle() {
FILE_MAP_READ | SECTION_QUERY, FALSE, 0)) {
return SharedMemoryHandle();
}
- SharedMemoryHandle handle = SharedMemoryHandle(result, shm_.GetGUID());
+ SharedMemoryHandle handle =
+ SharedMemoryHandle(result, shm_.GetSize(), shm_.GetGUID());
handle.SetOwnershipPassesToIPC(true);
return handle;
}
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | base/metrics/field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698