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

Unified Diff: base/memory/shared_memory.h

Issue 2872503003: Add crash keys about field trial shared memory errors. (Closed)
Patch Set: Add TODOs about cleaning up the code. 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 | « no previous file | base/memory/shared_memory_helper.h » ('j') | base/memory/shared_memory_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory.h
diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h
index 35067e6aaeab848080c681fa729f7853df720f3c..52303d800d83bead006cd3d18e81388eb928959f 100644
--- a/base/memory/shared_memory.h
+++ b/base/memory/shared_memory.h
@@ -63,6 +63,22 @@ struct BASE_EXPORT SharedMemoryCreateOptions {
bool share_read_only = false;
};
+// Enumeration of different shared memory error types. Note: Currently only
+// errors from Mac POSIX shared memory implementation are fully instrumented.
+// TODO(asvitkine): Evaluate whether we want to keep this ability after
+// crbug.com/703649 is fixed and expand to all platforms or remove.
+enum class SharedMemoryError {
+ NO_ERRORS,
+ NO_FILE,
+ BAD_PARAMS,
+ STAT_FAILED,
+ TRUNCATE_FAILED,
+ NO_TEMP_DIR,
+ MAKE_READONLY_FAILED,
+ INODE_MISMATCH,
+ MMAP_FAILED,
+};
+
// Platform abstraction for shared memory.
// SharedMemory consumes a SharedMemoryHandle [potentially one that it created]
// to map a shared memory OS resource into the virtual address space of the
@@ -232,6 +248,13 @@ class BASE_EXPORT SharedMemory {
bool GetUniqueId(UniqueId* id) const;
#endif
+ // Returns the last error encountered as a result of a call to Create() or
+ // Map(). Note: Currently only errors from Mac POSIX shared memory
+ // implementation are fully instrumented.
+ // TODO(asvitkine): Evaluate whether we want to keep this ability after
+ // crbug.com/703649 is fixed and expand to all platforms or remove.
+ SharedMemoryError get_last_error() const { return last_error_; }
+
private:
#if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
(!defined(OS_MACOSX) || defined(OS_IOS))
@@ -263,6 +286,7 @@ class BASE_EXPORT SharedMemory {
void* memory_;
bool read_only_;
size_t requested_size_;
+ SharedMemoryError last_error_ = SharedMemoryError::NO_ERRORS;
Nico 2017/05/10 15:12:22 nit: please init in ctor, like for all other membe
Alexei Svitkine (slow) 2017/05/10 15:22:39 Unfortunately, it's not a single ctor - it's 7 dif
DISALLOW_COPY_AND_ASSIGN(SharedMemory);
};
« no previous file with comments | « no previous file | base/memory/shared_memory_helper.h » ('j') | base/memory/shared_memory_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698