Stop trying to find an aliased session for WS/H2

SpdySessionPool::OnHostResolutionComplete() tries to find an aliased
session that supports WebSocket over HTTP2 if the available session
doesn't. However, there's no way to add multiple sessions to the
available session map, resulting in a crash.

Stop trying to find aliased sessions if the available session doesn't
support WS/H2. It's not worth the extra complexity to support this rare
case.

BUG=1220771

Change-Id: Ic89c82e16f6f2e9b1c4c49c0823414c848c31099
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2994087
Commit-Queue: Adam Rice <[email protected]>
Reviewed-by: Bence Béky <[email protected]>
Cr-Commit-Position: refs/heads/master@{#897588}
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index 0829665..a759788 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -276,17 +276,14 @@
   // nothing, but inform the caller to wait for such a task to run.
   auto existing_session_it = LookupAvailableSessionByKey(key);
   if (existing_session_it != available_sessions_.end()) {
-    // If this is an alias, the host resolution is for a websocket
-    // connection, and the aliased session doesn't support websockets,
-    // continue looking for an aliased session that does.  Unlikely there
-    // is one, but can't hurt to check.
-    bool continue_searching_for_websockets =
-        is_websocket && !existing_session_it->second->support_websocket();
+    if (is_websocket && !existing_session_it->second->support_websocket()) {
+      // We don't look for aliased sessions because it would not be possible to
+      // add them to the available_sessions_ map. See https://crbug.com/1220771.
+      return OnHostResolutionCallbackResult::kContinue;
+    }
 
-    if (!continue_searching_for_websockets)
-      return OnHostResolutionCallbackResult::kMayBeDeletedAsync;
+    return OnHostResolutionCallbackResult::kMayBeDeletedAsync;
   }
-
   for (const auto& address : addresses) {
     auto range = aliases_.equal_range(address);
     for (auto alias_it = range.first; alias_it != range.second; ++alias_it) {