chore: replace absl::optional<T> with std::optional<T> (#41074)

chore: replace absl::optional<T> with std::optional<T> (#40928)
This commit is contained in:
Milan Burda
2024-01-24 03:43:22 +01:00
committed by GitHub
parent 95e3df589f
commit 0df4312ded
129 changed files with 413 additions and 394 deletions

View File

@@ -5,6 +5,7 @@
#include "shell/browser/api/electron_api_app.h"
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
@@ -76,7 +77,6 @@
#include "shell/common/platform_util.h"
#include "shell/common/thread_restrictions.h"
#include "shell/common/v8_value_serializer.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/image/image.h"
#if BUILDFLAG(IS_WIN)
@@ -928,7 +928,7 @@ void App::SetAppPath(const base::FilePath& app_path) {
#if !BUILDFLAG(IS_MAC)
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path) {
std::optional<base::FilePath> custom_path) {
if (custom_path.has_value()) {
if (!custom_path->IsAbsolute()) {
thrower.ThrowError("Path must be absolute");
@@ -1605,7 +1605,7 @@ void ConfigureHostResolver(v8::Isolate* isolate,
// doh_config.
std::vector<net::DnsOverHttpsServerConfig> servers;
for (const std::string& server_template : secure_dns_server_strings) {
absl::optional<net::DnsOverHttpsServerConfig> server_config =
std::optional<net::DnsOverHttpsServerConfig> server_config =
net::DnsOverHttpsServerConfig::FromString(server_template);
if (!server_config.has_value()) {
thrower.ThrowTypeError(std::string("not a valid DoH template: ") +

View File

@@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -180,7 +181,7 @@ class App : public ElectronBrowserClient::Delegate,
void ChildProcessDisconnected(int pid);
void SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path);
std::optional<base::FilePath> custom_path);
// Get/Set the pre-defined path in PathService.
base::FilePath GetPath(gin_helper::ErrorThrower thrower,

View File

@@ -17,7 +17,7 @@
namespace electron::api {
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
absl::optional<base::FilePath> custom_path) {
std::optional<base::FilePath> custom_path) {
if (custom_path.has_value()) {
if (!custom_path->IsAbsolute()) {
thrower.ThrowError("Path must be absolute");

View File

@@ -750,7 +750,7 @@ void BaseWindow::SetParentWindow(v8::Local<v8::Value> value,
}
void BaseWindow::SetBrowserView(
absl::optional<gin::Handle<BrowserView>> browser_view) {
std::optional<gin::Handle<BrowserView>> browser_view) {
ResetBrowserViews();
if (browser_view)
AddBrowserView(*browser_view);
@@ -891,11 +891,11 @@ bool BaseWindow::GetWindowButtonVisibility() const {
return window_->GetWindowButtonVisibility();
}
void BaseWindow::SetWindowButtonPosition(absl::optional<gfx::Point> position) {
void BaseWindow::SetWindowButtonPosition(std::optional<gfx::Point> position) {
window_->SetWindowButtonPosition(std::move(position));
}
absl::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
std::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
return window_->GetWindowButtonPosition();
}
#endif

View File

@@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
@@ -175,7 +176,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
void RemoveMenu();
void SetParentWindow(v8::Local<v8::Value> value, gin_helper::Arguments* args);
virtual void SetBrowserView(
absl::optional<gin::Handle<BrowserView>> browser_view);
std::optional<gin::Handle<BrowserView>> browser_view);
virtual void AddBrowserView(gin::Handle<BrowserView> browser_view);
virtual void RemoveBrowserView(gin::Handle<BrowserView> browser_view);
virtual void SetTopBrowserView(gin::Handle<BrowserView> browser_view,
@@ -197,8 +198,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
std::string GetAlwaysOnTopLevel() const;
void SetWindowButtonVisibility(bool visible);
bool GetWindowButtonVisibility() const;
void SetWindowButtonPosition(absl::optional<gfx::Point> position);
absl::optional<gfx::Point> GetWindowButtonPosition() const;
void SetWindowButtonPosition(std::optional<gfx::Point> position);
std::optional<gfx::Point> GetWindowButtonPosition() const;
bool IsHiddenInMissionControl();
void SetHiddenInMissionControl(bool hidden);

View File

@@ -307,7 +307,7 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
}
void BrowserWindow::SetBrowserView(
absl::optional<gin::Handle<BrowserView>> browser_view) {
std::optional<gin::Handle<BrowserView>> browser_view) {
BaseWindow::ResetBrowserViews();
if (browser_view)
BaseWindow::AddBrowserView(*browser_view);

View File

@@ -70,7 +70,7 @@ class BrowserWindow : public BaseWindow,
void Blur() override;
void SetBackgroundColor(const std::string& color_name) override;
void SetBrowserView(
absl::optional<gin::Handle<BrowserView>> browser_view) override;
std::optional<gin::Handle<BrowserView>> browser_view) override;
void OnWindowShow() override;
void OnWindowHide() override;

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -17,7 +18,6 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
using content::TracingController;
@@ -58,18 +58,18 @@ namespace {
using CompletionCallback = base::OnceCallback<void(const base::FilePath&)>;
absl::optional<base::FilePath> CreateTemporaryFileOnIO() {
std::optional<base::FilePath> CreateTemporaryFileOnIO() {
base::FilePath temp_file_path;
if (!base::CreateTemporaryFile(&temp_file_path))
return absl::nullopt;
return absl::make_optional(std::move(temp_file_path));
return std::nullopt;
return std::make_optional(std::move(temp_file_path));
}
void StopTracing(gin_helper::Promise<base::FilePath> promise,
absl::optional<base::FilePath> file_path) {
std::optional<base::FilePath> file_path) {
auto resolve_or_reject = base::BindOnce(
[](gin_helper::Promise<base::FilePath> promise,
const base::FilePath& path, absl::optional<std::string> error) {
const base::FilePath& path, std::optional<std::string> error) {
if (error) {
promise.RejectWithErrorMessage(error.value());
} else {
@@ -81,20 +81,20 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise,
auto* instance = TracingController::GetInstance();
if (!instance->IsTracing()) {
std::move(resolve_or_reject)
.Run(absl::make_optional(
.Run(std::make_optional(
"Failed to stop tracing - no trace in progress"));
} 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), absl::nullopt));
base::BindOnce(std::move(split_callback.first), std::nullopt));
if (!instance->StopTracing(endpoint)) {
std::move(split_callback.second)
.Run(absl::make_optional("Failed to stop tracing"));
.Run(std::make_optional("Failed to stop tracing"));
}
} else {
std::move(resolve_or_reject)
.Run(absl::make_optional(
.Run(std::make_optional(
"Failed to create temporary file for trace data"));
}
}
@@ -105,7 +105,7 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
base::FilePath path;
if (args->GetNext(&path) && !path.empty()) {
StopTracing(std::move(promise), absl::make_optional(path));
StopTracing(std::move(promise), std::make_optional(path));
} else {
// use a temporary file.
base::ThreadPool::PostTaskAndReplyWithResult(

View File

@@ -129,13 +129,13 @@ bool MatchesCookie(const base::Value::Dict& filter,
if ((str = filter.FindString("domain")) &&
!MatchesDomain(*str, cookie.Domain()))
return false;
absl::optional<bool> secure_filter = filter.FindBool("secure");
std::optional<bool> secure_filter = filter.FindBool("secure");
if (secure_filter && *secure_filter != cookie.IsSecure())
return false;
absl::optional<bool> session_filter = filter.FindBool("session");
std::optional<bool> session_filter = filter.FindBool("session");
if (session_filter && *session_filter == cookie.IsPersistent())
return false;
absl::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
std::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
if (httpOnly_filter && *httpOnly_filter != cookie.IsHttpOnly())
return false;
return true;
@@ -163,7 +163,7 @@ void FilterCookieWithStatuses(
}
// Parse dictionary property to CanonicalCookie time correctly.
base::Time ParseTimeProperty(const absl::optional<double>& value) {
base::Time ParseTimeProperty(const std::optional<double>& value) {
if (!value) // empty time means ignoring the parameter
return base::Time();
if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time
@@ -323,7 +323,7 @@ v8::Local<v8::Promise> Cookies::Set(v8::Isolate* isolate,
path ? *path : "", ParseTimeProperty(details.FindDouble("creationDate")),
ParseTimeProperty(details.FindDouble("expirationDate")),
ParseTimeProperty(details.FindDouble("lastAccessDate")), secure,
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, absl::nullopt,
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, std::nullopt,
&status);
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {

View File

@@ -44,12 +44,12 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
message.size());
absl::optional<base::Value> parsed_message = base::JSONReader::Read(
std::optional<base::Value> parsed_message = base::JSONReader::Read(
message_str, base::JSON_REPLACE_INVALID_CHARACTERS);
if (!parsed_message || !parsed_message->is_dict())
return;
base::Value::Dict& dict = parsed_message->GetDict();
absl::optional<int> id = dict.FindInt("id");
std::optional<int> id = dict.FindInt("id");
if (!id) {
std::string* method = dict.FindString("method");
if (!method)

View File

@@ -25,7 +25,7 @@ static NSMenu* __strong applicationMenu_;
ui::Accelerator GetAcceleratorFromKeyEquivalentAndModifierMask(
NSString* key_equivalent,
NSUInteger modifier_mask) {
absl::optional<char16_t> shifted_char;
std::optional<char16_t> shifted_char;
ui::KeyboardCode code = electron::KeyboardCodeFromStr(
base::SysNSStringToUTF8(key_equivalent), &shifted_char);
int modifiers = 0;

View File

@@ -125,7 +125,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
}
pending_start_promise_ =
absl::make_optional<gin_helper::Promise<void>>(args->isolate());
std::make_optional<gin_helper::Promise<void>>(args->isolate());
v8::Local<v8::Promise> handle = pending_start_promise_->GetHandle();
auto command_line_string =

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
#include <optional>
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
@@ -16,7 +18,6 @@
#include "net/log/net_log_capture_mode.h"
#include "services/network/public/mojom/net_log.mojom.h"
#include "shell/common/gin_helper/promise.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace gin {
class Arguments;
@@ -67,7 +68,7 @@ class NetLog : public gin::Wrappable<NetLog> {
mojo::Remote<network::mojom::NetLogExporter> net_log_exporter_;
absl::optional<gin_helper::Promise<void>> pending_start_promise_;
std::optional<gin_helper::Promise<void>> pending_start_promise_;
scoped_refptr<base::TaskRunner> file_task_runner_;

View File

@@ -281,7 +281,7 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
url_chain, GURL(),
content::StoragePartitionConfig::CreateDefault(
download_manager->GetBrowserContext()),
GURL(), GURL(), absl::nullopt, mime_type, mime_type, start_time,
GURL(), GURL(), std::nullopt, mime_type, mime_type, start_time,
base::Time(), etag, last_modified, offset, length, std::string(),
download::DownloadItem::INTERRUPTED,
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
@@ -432,7 +432,7 @@ v8::Local<v8::Promise> Session::ResolveProxy(gin::Arguments* args) {
v8::Local<v8::Promise> Session::ResolveHost(
std::string host,
absl::optional<network::mojom::ResolveHostParametersPtr> params) {
std::optional<network::mojom::ResolveHostParametersPtr> params) {
gin_helper::Promise<gin_helper::Dictionary> promise(isolate_);
v8::Local<v8::Promise> handle = promise.GetHandle();
@@ -441,7 +441,7 @@ v8::Local<v8::Promise> Session::ResolveHost(
params ? std::move(params.value()) : nullptr,
base::BindOnce(
[](gin_helper::Promise<gin_helper::Dictionary> promise,
int64_t net_error, const absl::optional<net::AddressList>& addrs) {
int64_t net_error, const std::optional<net::AddressList>& addrs) {
if (net_error < 0) {
promise.RejectWithErrorMessage(net::ErrorToString(net_error));
} else {
@@ -1271,7 +1271,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
}
// static
absl::optional<gin::Handle<Session>> Session::FromPath(
std::optional<gin::Handle<Session>> Session::FromPath(
v8::Isolate* isolate,
const base::FilePath& path,
base::Value::Dict options) {
@@ -1280,12 +1280,12 @@ absl::optional<gin::Handle<Session>> Session::FromPath(
if (path.empty()) {
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
promise.RejectWithErrorMessage("An empty path was specified");
return absl::nullopt;
return std::nullopt;
}
if (!path.IsAbsolute()) {
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
promise.RejectWithErrorMessage("An absolute path was not provided");
return absl::nullopt;
return std::nullopt;
}
browser_context =
@@ -1410,7 +1410,7 @@ v8::Local<v8::Value> FromPath(const base::FilePath& path,
}
base::Value::Dict options;
args->GetNext(&options);
absl::optional<gin::Handle<Session>> session_handle =
std::optional<gin::Handle<Session>> session_handle =
Session::FromPath(args->isolate(), path, std::move(options));
if (session_handle)

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
#include <optional>
#include <string>
#include <vector>
@@ -85,7 +86,7 @@ class Session : public gin::Wrappable<Session>,
base::Value::Dict options = {});
// Gets the Session based on |path|.
static absl::optional<gin::Handle<Session>> FromPath(
static std::optional<gin::Handle<Session>> FromPath(
v8::Isolate* isolate,
const base::FilePath& path,
base::Value::Dict options = {});
@@ -101,7 +102,7 @@ class Session : public gin::Wrappable<Session>,
// Methods.
v8::Local<v8::Promise> ResolveHost(
std::string host,
absl::optional<network::mojom::ResolveHostParametersPtr> params);
std::optional<network::mojom::ResolveHostParametersPtr> params);
v8::Local<v8::Promise> ResolveProxy(gin::Arguments* args);
v8::Local<v8::Promise> GetCacheSize();
v8::Local<v8::Promise> ClearCache();

View File

@@ -52,7 +52,7 @@ gin::WrapperInfo Tray::kWrapperInfo = {gin::kEmbedderNativeGin};
Tray::Tray(v8::Isolate* isolate,
v8::Local<v8::Value> image,
absl::optional<UUID> guid)
std::optional<UUID> guid)
: tray_icon_(TrayIcon::Create(guid)) {
SetImage(isolate, image);
tray_icon_->AddObserver(this);
@@ -63,7 +63,7 @@ Tray::~Tray() = default;
// static
gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image,
absl::optional<UUID> guid,
std::optional<UUID> guid,
gin::Arguments* args) {
if (!Browser::Get()->is_ready()) {
thrower.ThrowError("Cannot create Tray before app is ready");
@@ -233,7 +233,7 @@ void Tray::SetToolTip(const std::string& tool_tip) {
}
void Tray::SetTitle(const std::string& title,
const absl::optional<gin_helper::Dictionary>& options,
const std::optional<gin_helper::Dictionary>& options,
gin::Arguments* args) {
if (!CheckAlive())
return;

View File

@@ -6,6 +6,7 @@
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_TRAY_H_
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -43,7 +44,7 @@ class Tray : public gin::Wrappable<Tray>,
// gin_helper::Constructible
static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> image,
absl::optional<UUID> guid,
std::optional<UUID> guid,
gin::Arguments* args);
static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
@@ -60,7 +61,7 @@ class Tray : public gin::Wrappable<Tray>,
private:
Tray(v8::Isolate* isolate,
v8::Local<v8::Value> image,
absl::optional<UUID> guid);
std::optional<UUID> guid);
~Tray() override;
// TrayIconObserver:
@@ -92,7 +93,7 @@ class Tray : public gin::Wrappable<Tray>,
void SetPressedImage(v8::Isolate* isolate, v8::Local<v8::Value> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title,
const absl::optional<gin_helper::Dictionary>& options,
const std::optional<gin_helper::Dictionary>& options,
gin::Arguments* args);
std::string GetTitle();
void SetIgnoreDoubleClickEvents(bool ignore);

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "gin/handle.h"
#include "shell/common/gin_helper/wrappable.h"

View File

@@ -6,6 +6,7 @@
#include <limits>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <string_view>
@@ -129,7 +130,6 @@
#include "shell/common/thread_restrictions.h"
#include "shell/common/v8_value_serializer.h"
#include "storage/browser/file_system/isolated_context.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
@@ -497,9 +497,9 @@ void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
capture_handle.RunAndReset();
}
absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
std::optional<base::TimeDelta> GetCursorBlinkInterval() {
#if BUILDFLAG(IS_MAC)
absl::optional<base::TimeDelta> system_value(
std::optional<base::TimeDelta> system_value(
ui::TextInsertionCaretBlinkPeriodFromDefaults());
if (system_value)
return *system_value;
@@ -513,7 +513,7 @@ absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
: base::Milliseconds(system_msec);
}
#endif
return absl::nullopt;
return std::nullopt;
}
#if BUILDFLAG(ENABLE_PRINTING)
@@ -1112,7 +1112,7 @@ void WebContents::Destroy() {
}
}
void WebContents::Close(absl::optional<gin_helper::Dictionary> options) {
void WebContents::Close(std::optional<gin_helper::Dictionary> options) {
bool dispatch_beforeunload = false;
if (options)
options->Get("waitForBeforeUnload", &dispatch_beforeunload);
@@ -1655,7 +1655,7 @@ void WebContents::HandleNewRenderFrame(
}
void WebContents::OnBackgroundColorChanged() {
absl::optional<SkColor> color = web_contents()->GetBackgroundColor();
std::optional<SkColor> color = web_contents()->GetBackgroundColor();
if (color.has_value()) {
auto* const view = web_contents()->GetRenderWidgetHostView();
static_cast<content::RenderWidgetHostViewBase*>(view)
@@ -3144,8 +3144,8 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) {
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
landscape, display_header_footer, print_background, scale,
paper_width, paper_height, margin_top, margin_bottom, margin_left,
margin_right, absl::make_optional(header_template),
absl::make_optional(footer_template), prefer_css_page_size,
margin_right, std::make_optional(header_template),
std::make_optional(footer_template), prefer_css_page_size,
generate_tagged_pdf, generate_document_outline);
if (absl::holds_alternative<std::string>(print_pages_params)) {
@@ -4081,7 +4081,7 @@ void WebContents::DevToolsIndexPath(
if (devtools_indexing_jobs_.count(request_id) != 0)
return;
std::vector<std::string> excluded_folders;
absl::optional<base::Value> parsed_excluded_folders =
std::optional<base::Value> parsed_excluded_folders =
base::JSONReader::Read(excluded_folders_message);
if (parsed_excluded_folders && parsed_excluded_folders->is_list()) {
for (const base::Value& folder_path : parsed_excluded_folders->GetList()) {
@@ -4498,8 +4498,7 @@ gin::Handle<WebContents> WebContents::CreateFromWebPreferences(
if (gin::ConvertFromV8(isolate, web_preferences.GetHandle(),
&web_preferences_dict)) {
existing_preferences->SetFromDictionary(web_preferences_dict);
absl::optional<SkColor> color =
existing_preferences->GetBackgroundColor();
std::optional<SkColor> color = existing_preferences->GetBackgroundColor();
web_contents->web_contents()->SetPageBaseBackgroundColor(color);
// Because web preferences don't recognize transparency,
// only set rwhv background color if a color exists

View File

@@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
@@ -161,7 +162,7 @@ class WebContents : public ExclusiveAccessContext,
const char* GetTypeName() override;
void Destroy();
void Close(absl::optional<gin_helper::Dictionary> options);
void Close(std::optional<gin_helper::Dictionary> options);
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
bool GetBackgroundThrottling() const override;

View File

@@ -5,6 +5,8 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
#include <optional>
#include "base/memory/raw_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "shell/browser/api/electron_api_view.h"

View File

@@ -229,7 +229,7 @@ void WebFrameMain::OnRendererConnectionError() {
void WebFrameMain::PostMessage(v8::Isolate* isolate,
const std::string& channel,
v8::Local<v8::Value> message_value,
absl::optional<v8::Local<v8::Value>> transfer) {
std::optional<v8::Local<v8::Value>> transfer) {
blink::TransferableMessage transferable_message;
if (!electron::SerializeV8Value(isolate, message_value,
&transferable_message)) {

View File

@@ -5,6 +5,7 @@
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#include <optional>
#include <string>
#include <vector>
@@ -103,7 +104,7 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
void PostMessage(v8::Isolate* isolate,
const std::string& channel,
v8::Local<v8::Value> message_value,
absl::optional<v8::Local<v8::Value>> transfer);
std::optional<v8::Local<v8::Value>> transfer);
int FrameTreeNodeID() const;
std::string Name() const;

View File

@@ -5,10 +5,9 @@
#include "shell/browser/api/process_metric.h"
#include <memory>
#include <optional>
#include <utility>
#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -34,14 +33,14 @@ mach_port_t TaskForPid(pid_t pid) {
return task;
}
absl::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
std::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
if (task == MACH_PORT_NULL)
return absl::nullopt;
return std::nullopt;
mach_task_basic_info_data_t info = {};
mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT;
kern_return_t kr = task_info(task, MACH_TASK_BASIC_INFO,
reinterpret_cast<task_info_t>(&info), &count);
return (kr == KERN_SUCCESS) ? absl::make_optional(info) : absl::nullopt;
return (kr == KERN_SUCCESS) ? std::make_optional(info) : std::nullopt;
}
} // namespace