Add new Pickle factory functions with explicit ownership

Add new factory functions to provide Pickles that make it explicit
when it owns the memory and when it doesn't.

Bug: 330028190, 40284755
Change-Id: I3329cdff0d7166d4167e82982e8692e5bf7a6d6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5383927
Commit-Queue: Avi Drissman <[email protected]>
Reviewed-by: danakj <[email protected]>
Auto-Submit: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1276364}
diff --git a/base/pickle_fuzzer.cc b/base/pickle_fuzzer.cc
index 4a7afebc..26008c1 100644
--- a/base/pickle_fuzzer.cc
+++ b/base/pickle_fuzzer.cc
@@ -6,6 +6,7 @@
 
 #include <tuple>
 
+#include "base/containers/span.h"
 #include "base/pickle.h"
 
 namespace {
@@ -26,7 +27,8 @@
   data += kReadControlBytes;
   size -= kReadControlBytes;
 
-  base::Pickle pickle(reinterpret_cast<const char*>(data), size);
+  base::Pickle pickle =
+      base::Pickle::WithUnownedBuffer(UNSAFE_BUFFERS(base::span(data, size)));
   base::PickleIterator iter(pickle);
   for (int i = 0; i < kIterations; i++) {
     uint8_t read_type = data_provider.ConsumeIntegral<uint8_t>();