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

Unified Diff: base/shared_memory_posix.cc

Issue 11876037: Added SharedMemory::MapFrom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/shared_memory_nacl.cc ('k') | base/shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory_posix.cc
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 7862f42c194fe2701293673efb6417bf2d7140a6..dcd55756f98257d57cdee2f135097d20bbfcefef 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -16,6 +16,7 @@
#include "base/threading/platform_thread.h"
#include "base/safe_strerror_posix.h"
#include "base/synchronization/lock.h"
+#include "base/sys_info.h"
#include "base/threading/thread_restrictions.h"
#include "base/utf_string_conversions.h"
@@ -219,7 +220,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) {
#endif // !defined(OS_ANDROID)
-bool SharedMemory::Map(size_t bytes) {
+bool SharedMemory::MapAt(off_t offset, size_t bytes) {
if (mapped_file_ == -1)
return false;
@@ -242,8 +243,10 @@ bool SharedMemory::Map(size_t bytes) {
}
#endif
+ DCHECK_EQ(static_cast<size_t>(0),
jar (doing other things) 2013/01/15 22:20:29 I assume this call is not made that often... so ho
Vitaly Buka (NO REVIEWS) 2013/01/15 22:58:54 it will return false because memory_ will be inval
+ offset & (SysInfo::VMAllocationGranularity() - 1));
Mark Mentovai 2013/01/15 22:26:02 My point was that this is sort of an implementatio
Vitaly Buka (NO REVIEWS) 2013/01/15 22:58:54 I don't believe we want crash on mmap returns null
memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE),
- MAP_SHARED, mapped_file_, 0);
+ MAP_SHARED, mapped_file_, offset);
bool mmap_succeeded = memory_ != (void*)-1 && memory_ != NULL;
if (mmap_succeeded) {
« no previous file with comments | « base/shared_memory_nacl.cc ('k') | base/shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698