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

Unified Diff: base/memory/shared_memory_helper.cc

Issue 2872503003: Add crash keys about field trial shared memory errors. (Closed)
Patch Set: Rebased 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_helper.h ('k') | base/memory/shared_memory_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_helper.cc
diff --git a/base/memory/shared_memory_helper.cc b/base/memory/shared_memory_helper.cc
index f13e3fb052690c112df3fd3af76ea7f6c7a2d049..87c3d3670845a6f47bb47dddbebd91ef9f646b62 100644
--- a/base/memory/shared_memory_helper.cc
+++ b/base/memory/shared_memory_helper.cc
@@ -25,7 +25,8 @@ using ScopedPathUnlinker =
bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
ScopedFILE* fp,
ScopedFD* readonly_fd,
- FilePath* path) {
+ FilePath* path,
+ SharedMemoryError* error) {
#if !(defined(OS_MACOSX) && !defined(OS_IOS))
// It doesn't make sense to have a open-existing private piece of shmem
DCHECK(!options.open_existing_deprecated);
@@ -34,13 +35,16 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
// A: Because they're limited to 4mb on OS X. FFFFFFFUUUUUUUUUUU
FilePath directory;
ScopedPathUnlinker path_unlinker;
- if (!GetShmemTempDir(options.executable, &directory))
+ if (!GetShmemTempDir(options.executable, &directory)) {
+ *error = SharedMemoryError::NO_TEMP_DIR;
return false;
+ }
fp->reset(base::CreateAndOpenTemporaryFileInDir(directory, path));
-
- if (!*fp)
+ if (!*fp) {
+ *error = SharedMemoryError::NO_FILE;
return false;
+ }
// Deleting the file prevents anyone else from mapping it in (making it
// private), and prevents the need for cleanup (once the last fd is
@@ -53,18 +57,24 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
if (!readonly_fd->is_valid()) {
DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed";
fp->reset();
+ *error = SharedMemoryError::MAKE_READONLY_FAILED;
return false;
}
}
return true;
}
-bool PrepareMapFile(ScopedFILE fp, ScopedFD readonly_fd, int* mapped_file,
- int* readonly_mapped_file) {
+bool PrepareMapFile(ScopedFILE fp,
+ ScopedFD readonly_fd,
+ int* mapped_file,
+ int* readonly_mapped_file,
+ SharedMemoryError* error) {
DCHECK_EQ(-1, *mapped_file);
DCHECK_EQ(-1, *readonly_mapped_file);
- if (fp == NULL)
+ if (!fp) {
+ *error = SharedMemoryError::NO_FILE;
return false;
+ }
// This function theoretically can block on the disk, but realistically
// the temporary files we create will just go into the buffer cache
@@ -81,6 +91,7 @@ bool PrepareMapFile(ScopedFILE fp, ScopedFD readonly_fd, int* mapped_file,
NOTREACHED();
if (st.st_dev != readonly_st.st_dev || st.st_ino != readonly_st.st_ino) {
LOG(ERROR) << "writable and read-only inodes don't match; bailing";
+ *error = SharedMemoryError::INODE_MISMATCH;
return false;
}
}
« no previous file with comments | « base/memory/shared_memory_helper.h ('k') | base/memory/shared_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698