refactor: use base::as_string_view() (#45745)
Use `base::as_string_view()` as a safer alternative to `reinterpret_cast`
in a couple of places.
Xref: 5472408
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
02b85f1e6d
commit
8934eb1af5
2 changed files with 4 additions and 4 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/strings/pattern.h"
|
||||
|
@ -903,8 +904,7 @@ void InspectableWebContents::DispatchProtocolMessage(
|
|||
if (!frontend_loaded_)
|
||||
return;
|
||||
|
||||
const std::string_view str_message{
|
||||
reinterpret_cast<const char*>(message.data()), message.size()};
|
||||
const std::string_view str_message = base::as_string_view(message);
|
||||
if (str_message.length() < kMaxMessageChunkSize) {
|
||||
CallClientFunction("DevToolsAPI", "dispatchMessage",
|
||||
base::Value(std::string(str_message)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue