fix: -Wunsafe-buffer-usage warning in ChunkedDataPipeReadableStream (#44211)

* chore: rename v8_value_serializer.cc,h to v8_util.cc,h

* feat: add electron::util::as_byte_span(v8::Local<v8::ArrayBuffer>)

* fix: -Wunsafe-buffer-usage warnings in ChunkedDataPipeReadableStream::ReadInternal()

Xref: 5619253

* refactor: restore node buffer span util

* refactor: remove redundant span wrapper
This commit is contained in:
Charles Kerr 2024-10-14 03:46:24 -05:00 committed by GitHub
parent 8b3d70a2a3
commit 566c72cd46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 41 additions and 17 deletions

41
shell/common/v8_util.h Normal file
View file

@ -0,0 +1,41 @@
// Copyright (c) 2020 Slack Technologies, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_V8_VALUE_SERIALIZER_H_
#define ELECTRON_SHELL_COMMON_V8_VALUE_SERIALIZER_H_
#include "base/containers/span.h"
#include "ui/gfx/image/image_skia_rep.h"
namespace v8 {
class ArrayBufferView;
class Isolate;
template <class T>
class Local;
class Value;
} // namespace v8
namespace blink {
struct CloneableMessage;
}
namespace electron {
bool SerializeV8Value(v8::Isolate* isolate,
v8::Local<v8::Value> value,
blink::CloneableMessage* out);
v8::Local<v8::Value> DeserializeV8Value(v8::Isolate* isolate,
const blink::CloneableMessage& in);
v8::Local<v8::Value> DeserializeV8Value(v8::Isolate* isolate,
base::span<const uint8_t> data);
namespace util {
[[nodiscard]] base::span<uint8_t> as_byte_span(
v8::Local<v8::ArrayBufferView> abv);
} // namespace util
} // namespace electron
#endif // ELECTRON_SHELL_COMMON_V8_VALUE_SERIALIZER_H_