refactor: make node Buffers more friendly to base::span / std::span (#46724)

* refactor: add electron::Buffer namespace; move the Buffer as_byte_span() into it

* feat: add electron::Buffer::Copy()

a span-friendly version of node::Buffer::Copy()

* refactor: use electron::Buffer::Copy() in electron_api_base_window.cc

* refactor: use electron::Buffer::Copy() in electron_api_data_pipe_holder.cc

* refactor: use electron::Buffer::Copy() in electron_api_safe_storage.cc

* refactor: use electron::Buffer::Copy() in electron_api_clipboard.cc

* refactor: use electron::Buffer::Copy() in osr_converter.cc

* refactor: use electron::Buffer::Copy() in electron_api_native_image.cc

* refactor: use electron::Buffer::Copy() in net_converter.cc

* refactor: use electron::Buffer::Copy() in electron_api_web_contents.cc

* refactor: make NewEmptyBuffer() return a Local<Value>
This commit is contained in:
Charles Kerr 2025-04-25 08:00:09 -05:00 committed by GitHub
parent 1976e935e7
commit 06a99d6770
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 93 additions and 72 deletions

View file

@ -11,6 +11,7 @@
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
#include "shell/common/node_util.h"
namespace {
@ -72,8 +73,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
return {};
}
return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
.ToLocalChecked();
return electron::Buffer::Copy(isolate, ciphertext).ToLocalChecked();
}
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {