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

Unified Diff: courgette/memory_allocator.h

Issue 6716006: Identifying call sites that need to handle out of memory situations in Courgette. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « courgette/ensemble_apply.cc ('k') | courgette/streams.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/memory_allocator.h
===================================================================
--- courgette/memory_allocator.h (revision 78901)
+++ courgette/memory_allocator.h (working copy)
@@ -12,6 +12,47 @@
#include "base/logging.h"
#include "base/platform_file.h"
+#ifndef NDEBUG
+
+// A helper class to track down call sites that are not handling error cases.
+template<class T>
+class CheckReturnValue {
+ public:
+ // Not marked explicit on purpose.
+ CheckReturnValue(T value) : value_(value), checked_(false) { // NOLINT
+ }
+ CheckReturnValue(const CheckReturnValue& other)
+ : value_(other.value_), checked_(other.checked_) {
+ other.checked_ = true;
+ }
+
+ CheckReturnValue& operator=(const CheckReturnValue& other) {
+ if (this != &other) {
+ DCHECK(checked_);
+ value_ = other.value_;
+ checked_ = other.checked_;
+ other.checked_ = true;
+ }
+ }
+
+ ~CheckReturnValue() {
+ DCHECK(checked_);
+ }
+
+ operator const T&() const {
+ checked_ = true;
+ return value_;
+ }
+
+ private:
+ T value_;
+ mutable bool checked_;
+};
+typedef CheckReturnValue<bool> CheckBool;
+#else
+typedef bool CheckBool;
+#endif
+
namespace courgette {
#ifdef OS_WIN
« no previous file with comments | « courgette/ensemble_apply.cc ('k') | courgette/streams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698