WireServer: Don't allow freeing the Device

BUG=chromium:907278
BUG=chromium:911155

Change-Id: I6ec721b34b214bb242ac0d217e6ab12832c7323a
Reviewed-on: https://dawn-review.googlesource.com/c/2842
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/generator/templates/dawn_wire/WireServer.cpp b/generator/templates/dawn_wire/WireServer.cpp
index af34f6e..34a2daa 100644
--- a/generator/templates/dawn_wire/WireServer.cpp
+++ b/generator/templates/dawn_wire/WireServer.cpp
@@ -625,6 +625,12 @@
                     //* reference / release and only send destroy on refcount = 0.
                     {% set Suffix = as_MethodSuffix(type.name, Name("destroy")) %}
                     bool Handle{{Suffix}}(const char** commands, size_t* size) {
+
+                        //* Freeing the device has to be done out of band.
+                        {% if type.name.canonical_case() == "device" %}
+                            return false;
+                        {% endif %}
+
                         const auto* cmd = GetCommand<{{Suffix}}Cmd>(commands, size);
                         if (cmd == nullptr) {
                             return false;