refactor: fix deprecated base::Base64Encode() API calls (#40962)
* refactor: replace deprecated Base64Encode() usage in IWC::NetworkResourceLoader::OnDataReceived() * refactor: replace deprecated Base64Encode() usage EncodeToken(const base::UnguessableToken& token)
This commit is contained in:
parent
80b220d214
commit
b3e01220cb
2 changed files with 6 additions and 20 deletions
|
@ -38,11 +38,8 @@ const char kUsbDriverKey[] = "usb_driver";
|
||||||
std::string EncodeToken(const base::UnguessableToken& token) {
|
std::string EncodeToken(const base::UnguessableToken& token) {
|
||||||
const uint64_t data[2] = {token.GetHighForSerialization(),
|
const uint64_t data[2] = {token.GetHighForSerialization(),
|
||||||
token.GetLowForSerialization()};
|
token.GetLowForSerialization()};
|
||||||
std::string buffer;
|
return base::Base64Encode(
|
||||||
base::Base64Encode(
|
base::StringPiece(reinterpret_cast<const char*>(&data[0]), sizeof(data)));
|
||||||
base::StringPiece(reinterpret_cast<const char*>(&data[0]), sizeof(data)),
|
|
||||||
&buffer);
|
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) {
|
base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) {
|
||||||
|
|
|
@ -258,22 +258,11 @@ class InspectableWebContents::NetworkResourceLoader
|
||||||
|
|
||||||
void OnDataReceived(base::StringPiece chunk,
|
void OnDataReceived(base::StringPiece chunk,
|
||||||
base::OnceClosure resume) override {
|
base::OnceClosure resume) override {
|
||||||
base::Value chunkValue;
|
|
||||||
|
|
||||||
bool encoded = !base::IsStringUTF8(chunk);
|
bool encoded = !base::IsStringUTF8(chunk);
|
||||||
if (encoded) {
|
bindings_->CallClientFunction(
|
||||||
std::string encoded_string;
|
"DevToolsAPI", "streamWrite", base::Value{stream_id_},
|
||||||
base::Base64Encode(chunk, &encoded_string);
|
base::Value{encoded ? base::Base64Encode(chunk) : chunk},
|
||||||
chunkValue = base::Value(std::move(encoded_string));
|
base::Value{encoded});
|
||||||
} else {
|
|
||||||
chunkValue = base::Value(chunk);
|
|
||||||
}
|
|
||||||
base::Value id(stream_id_);
|
|
||||||
base::Value encodedValue(encoded);
|
|
||||||
|
|
||||||
bindings_->CallClientFunction("DevToolsAPI", "streamWrite", std::move(id),
|
|
||||||
std::move(chunkValue),
|
|
||||||
std::move(encodedValue));
|
|
||||||
std::move(resume).Run();
|
std::move(resume).Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue