Define OutOfMemory error

Used to replace CONTEXT_LOST when allocation fails.

BUG=dawn:152

Change-Id: I1b8d0061f2915df71f263e0712dba3d47d08e2b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10060
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn_native/Error.h b/src/dawn_native/Error.h
index 9e073c2..50ff9f0 100644
--- a/src/dawn_native/Error.h
+++ b/src/dawn_native/Error.h
@@ -25,7 +25,7 @@
     // file to avoid having all files including headers like <string> and <vector>
     class ErrorData;
 
-    enum class ErrorType : uint32_t { Validation, ContextLost, Unimplemented };
+    enum class ErrorType : uint32_t { Validation, ContextLost, Unimplemented, OutOfMemory };
 
     // MaybeError and ResultOrError are meant to be used as return value for function that are not
     // expected to, but might fail. The handling of error is potentially much slower than successes.
@@ -48,6 +48,7 @@
 #define DAWN_VALIDATION_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::Validation, MESSAGE)
 #define DAWN_CONTEXT_LOST_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::ContextLost, MESSAGE)
 #define DAWN_UNIMPLEMENTED_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::Unimplemented, MESSAGE)
+#define DAWN_OUT_OF_MEMORY_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::OutOfMemory, MESSAGE)
 
 #define DAWN_CONCAT1(x, y) x##y
 #define DAWN_CONCAT2(x, y) DAWN_CONCAT1(x, y)
diff --git a/src/dawn_native/metal/StagingBufferMTL.mm b/src/dawn_native/metal/StagingBufferMTL.mm
index 286a719..114b01d 100644
--- a/src/dawn_native/metal/StagingBufferMTL.mm
+++ b/src/dawn_native/metal/StagingBufferMTL.mm
@@ -27,7 +27,7 @@
                                                        options:MTLResourceStorageModeShared];
 
         if (mBuffer == nil) {
-            return DAWN_CONTEXT_LOST_ERROR("Unable to allocate buffer.");
+            return DAWN_OUT_OF_MEMORY_ERROR("Unable to allocate buffer.");
         }
 
         mMappedPointer = [mBuffer contents];