Reland "[WebSocket] Reduce memcpy at websocket_frame_parser.cc"

This is a reland of 67e6ba1caf6da062c409c7234da7c467bedc37f4

The original change was authored by [email protected]. This CL adds
an initialization code of WebSocketFrame::data.

Original change's description:
> [WebSocket] Reduce memcpy at websocket_frame_parser.cc
>
> This patch removes memcpy at WebSocketFrameParser::Decode to
> WebSocketFrameChunk.
> To share memory, this changes WebSocketFrame and WebSocketFrameChunk
> member type from `scoped_refptr<IOBuffer>` to `char*` referencing
> WebSocketStream memory in most cases.
> That change needs all users of the classes taking care of reference
> life cycle.
> WebSocketBasicStream and WebSocketDeflateStream keeps the memory
> until next ReadFrames().
> Most tests just copy and hold the memory.
>
> ToT:   196 MB/s
> Patch: 212 MB/s (+8%)
> Also this work is accelerated upon more memory consuming flag.
> See comments for detail.
>
> Bug: 865001
> Change-Id: If97651eb61e44805f413fdb7469a5dead5300d21
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774420
> Reviewed-by: Yutaka Hirano <[email protected]>
> Reviewed-by: Adam Rice <[email protected]>
> Reviewed-by: John Chen <[email protected]>
> Commit-Queue: Yoichi Osato <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#693542}

CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_chromium_msan_rel_ng
[email protected]

Bug: 865001
Change-Id: Iaf44e620b8ac8f5c7c8b7a6a78f38d461936d079
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787799
Commit-Queue: Yutaka Hirano <[email protected]>
Commit-Queue: Adam Rice <[email protected]>
Reviewed-by: John Chen <[email protected]>
Reviewed-by: Adam Rice <[email protected]>
Auto-Submit: Yutaka Hirano <[email protected]>
Cr-Commit-Position: refs/heads/master@{#693780}
diff --git a/net/websockets/websocket_event_interface.h b/net/websockets/websocket_event_interface.h
index d25b049..39f60c82 100644
--- a/net/websockets/websocket_event_interface.h
+++ b/net/websockets/websocket_event_interface.h
@@ -13,6 +13,7 @@
 
 #include "base/callback_forward.h"
 #include "base/compiler_specific.h"  // for WARN_UNUSED_RESULT
+#include "base/containers/span.h"
 #include "base/macros.h"
 #include "base/memory/scoped_refptr.h"
 #include "base/optional.h"
@@ -26,7 +27,6 @@
 class AuthCredentials;
 class IPEndPoint;
 class HttpResponseHeaders;
-class IOBuffer;
 class SSLInfo;
 class URLRequest;
 struct WebSocketHandshakeRequestInfo;
@@ -50,10 +50,12 @@
 
   // Called when a data frame has been received from the remote host and needs
   // to be forwarded to the renderer process.
+  // |payload| stays valid as long as both
+  // - the associated WebSocketChannel is valid.
+  // - no further ReadFrames() is called on the associated WebSocketChannel.
   virtual void OnDataFrame(bool fin,
                            WebSocketMessageType type,
-                           scoped_refptr<IOBuffer> buffer,
-                           size_t buffer_size) = 0;
+                           base::span<const char> payload) = 0;
 
   // Returns true if data pipe is full and waiting the renderer process read
   // out. The network service should not read more from network until that.