diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 384a16e1b3a7..70215fb7650b 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "base/files/file_util.h" @@ -20,6 +21,7 @@ #include "shell/common/node_includes.h" using content::TracingController; +using namespace std::literals; namespace gin { @@ -69,9 +71,9 @@ void StopTracing(gin_helper::Promise promise, std::optional file_path) { auto resolve_or_reject = base::BindOnce( [](gin_helper::Promise promise, - const base::FilePath& path, std::optional error) { - if (error) { - promise.RejectWithErrorMessage(error.value()); + const base::FilePath& path, const std::string_view error) { + if (!std::empty(error)) { + promise.RejectWithErrorMessage(error); } else { promise.Resolve(path); } @@ -81,21 +83,17 @@ void StopTracing(gin_helper::Promise promise, auto* instance = TracingController::GetInstance(); if (!instance->IsTracing()) { std::move(resolve_or_reject) - .Run(std::make_optional( - "Failed to stop tracing - no trace in progress")); + .Run("Failed to stop tracing - no trace in progress"sv); } else if (file_path) { auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject)); auto endpoint = TracingController::CreateFileEndpoint( - *file_path, - base::BindOnce(std::move(split_callback.first), std::nullopt)); + *file_path, base::BindOnce(std::move(split_callback.first), ""sv)); if (!instance->StopTracing(endpoint)) { - std::move(split_callback.second) - .Run(std::make_optional("Failed to stop tracing")); + std::move(split_callback.second).Run("Failed to stop tracing"sv); } } else { std::move(resolve_or_reject) - .Run(std::make_optional( - "Failed to create temporary file for trace data")); + .Run("Failed to create temporary file for trace data"sv); } }