sql: Change the Statement::ColumnBlob() return type to base::span.

ColumnBlob() currently returns a pointer to a data buffer, which must be
paired with the return result of ColumnByteLength(). This made sense
when the code was written, but we have safer and more ergonomic
alternatives now.

This CL switches the return type to base::span<const uint8_t>, which is
the closest reflection of the fact that BLOBs are arrays of bytes.
sql::Statement still has helpers for retrieving BLOB data as std::string
and std::vector<char> / std::vector<uint8_t>.

Bug: 1229451
Change-Id: I8f02335e3d3972269162a1aaeaa988c195ce5acd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3029249
Commit-Queue: Victor Costan <[email protected]>
Reviewed-by: Mohamed Amir Yosef <[email protected]>
Reviewed-by: Alex Ilin <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/master@{#902483}
diff --git a/components/sqlite_proto/key_value_table.h b/components/sqlite_proto/key_value_table.h
index 946386e..b84bb7d 100644
--- a/components/sqlite_proto/key_value_table.h
+++ b/components/sqlite_proto/key_value_table.h
@@ -85,12 +85,8 @@
       ::sqlite_proto::internal::GetSelectAllSql(table_name_).c_str()));
   while (reader.Step()) {
     auto it = data_map->emplace(reader.ColumnString(0), T()).first;
-    int size = reader.ColumnByteLength(1);
-    const void* blob = reader.ColumnBlob(1);
-    // Annoyingly, a nullptr result means either that an error occurred or that
-    // the blob was empty; partially disambiguate based on the length.
-    DCHECK(size && blob || !size && !blob) << !!size << !!blob;
-    it->second.ParseFromArray(blob, size);
+    base::span<const uint8_t> blob = reader.ColumnBlob(1);
+    it->second.ParseFromArray(blob.data(), blob.size());
   }
 }