gpu: Invalidate channel map first to fix reentracy issues

Clearing the channel map in DestroyAllChannels can re-enter into
GpuChannelManager via LoseAllContexts from ~GpuChannel causing a
use-after-free crash.

Bug: 942954
Change-Id: Iaf5f64ec3f96f2b5948cd6080c701c1107bd5b2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529342
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642138}
diff --git a/gpu/ipc/service/gpu_channel_manager.cc b/gpu/ipc/service/gpu_channel_manager.cc
index c185b57..b9a99c0 100644
--- a/gpu/ipc/service/gpu_channel_manager.cc
+++ b/gpu/ipc/service/gpu_channel_manager.cc
@@ -209,7 +209,11 @@
 }
 
 void GpuChannelManager::DestroyAllChannels() {
+  // Clear |gpu_channels_| first to prevent reentrancy problems from GpuChannel
+  // destructor.
+  auto gpu_channels = std::move(gpu_channels_);
   gpu_channels_.clear();
+  gpu_channels.clear();
 }
 
 void GpuChannelManager::GetVideoMemoryUsageStats(