KnownObject: Make it an error to request ID 0

WebGPU error handling assumes non-optional objects point to valid
objects. The wire code wasn't updated to produce an error when ID 0 is
requested in the non-optional case.

BUG=chromium:934360

Change-Id: I203d2ec864dabe0e76109e1932fc31cbf26291d7
Reviewed-on: https://dawn-review.googlesource.com/c/4980
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_wire/server/ObjectStorage.h b/src/dawn_wire/server/ObjectStorage.h
index 3405a88..0da9e7c 100644
--- a/src/dawn_wire/server/ObjectStorage.h
+++ b/src/dawn_wire/server/ObjectStorage.h
@@ -60,12 +60,14 @@
         using Data = ObjectData<T>;
 
         KnownObjects() {
-            // Pre-allocate ID 0 to refer to the null handle.
-            Data nullObject;
-            nullObject.handle = nullptr;
-            nullObject.valid = true;
-            nullObject.allocated = true;
-            mKnown.push_back(nullObject);
+            // Reserve ID 0 so that it can be used to represent nullptr for optional object values
+            // in the wire format. However don't tag it as allocated so that it is an error to ask
+            // KnownObjects for ID 0.
+            Data reservation;
+            reservation.handle = nullptr;
+            reservation.valid = false;
+            reservation.allocated = false;
+            mKnown.push_back(reservation);
         }
 
         // Get a backend objects for a given client ID.