diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index a27463594bcd06..0d9d5c204ecf6b 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -982,6 +982,8 @@ struct ParamTraits> { } }; +// absl types ParamTraits + template struct ParamTraits> { typedef absl::optional

param_type; @@ -1013,6 +1015,18 @@ struct ParamTraits> { } }; +template <> +struct ParamTraits { + typedef absl::monostate param_type; + static void Write(base::Pickle* m, const param_type& p) {} + static bool Read(const base::Pickle* m, + base::PickleIterator* iter, + param_type* r) { + return true; + } + static void Log(const param_type& p, std::string* l) { l->append("()"); } +}; + // base/util types ParamTraits template diff --git a/remoting/base/result.h b/remoting/base/result.h index 6775e0dd143997..ce6a842d33c332 100644 --- a/remoting/base/result.h +++ b/remoting/base/result.h @@ -10,6 +10,7 @@ #include "base/check.h" #include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/abseil-cpp/absl/types/variant.h" // Result represents the success or failure of an // operation, along with either the success value or error details. @@ -127,18 +128,16 @@ namespace remoting { // state or error state, respectively. class SuccessTag {}; class ErrorTag {}; -// Monostate can be used for SuccessType or ErrorType to indicate that there is -// no data for that state. Thus, Result is somewhat -// analogous to absl::optional, and Result is -// effectively a (2-byte) boolean. Result can be useful -// for cases where an operation can fail, but there is no return value in the -// success case. -// TODO(rkjnsn): Replace with std::monostate once C++17 is allowed. -class Monostate {}; +// absl::Monostate can be used for SuccessType or ErrorType to indicate that +// there is no data for that state. Thus, Result is +// somewhat analogous to absl::optional, and Result is effectively a (2-byte) boolean. Result +// can be useful for cases where an operation can fail, but there is no return +// value in the success case. constexpr SuccessTag kSuccessTag = SuccessTag(); constexpr ErrorTag kErrorTag = ErrorTag(); -constexpr Monostate kMonostate = Monostate(); +constexpr absl::monostate kMonostate = absl::monostate(); namespace internal { diff --git a/remoting/host/chromoting_messages.h b/remoting/host/chromoting_messages.h index e9c72f4c267dab..44b71f718e5c74 100644 --- a/remoting/host/chromoting_messages.h +++ b/remoting/host/chromoting_messages.h @@ -49,7 +49,7 @@ IPC_MESSAGE_CONTROL(ChromotingDesktopNetworkMsg_KeyboardChanged, IPC_MESSAGE_CONTROL( ChromotingDesktopNetworkMsg_FileResult, uint64_t /* file_id */, - remoting::protocol::FileTransferResult /* result */) + remoting::protocol::FileTransferResult /* result */) // Carries the result of a read-file operation on the file identified by // |file_id|. |result| is the filename and size of the selected file. If diff --git a/remoting/host/chromoting_param_traits.cc b/remoting/host/chromoting_param_traits.cc index a86b9b5b58d5eb..56aec35e61525a 100644 --- a/remoting/host/chromoting_param_traits.cc +++ b/remoting/host/chromoting_param_traits.cc @@ -79,22 +79,4 @@ void ParamTraits::Log( base::StringPrintf("FileTransfer Error: %s", formatted.str().c_str())); } -// remoting::Monostate - -// static -void IPC::ParamTraits::Write(base::Pickle*, - const param_type&) {} - -// static -bool ParamTraits::Read(const base::Pickle*, - base::PickleIterator*, - param_type*) { - return true; -} - -// static -void ParamTraits::Log(const param_type&, std::string* l) { - l->append("()"); -} - } // namespace IPC diff --git a/remoting/host/chromoting_param_traits.h b/remoting/host/chromoting_param_traits.h index ffe533435ddcef..b85c58728b3509 100644 --- a/remoting/host/chromoting_param_traits.h +++ b/remoting/host/chromoting_param_traits.h @@ -33,16 +33,6 @@ struct ParamTraits { static void Log(const param_type& p, std::string* l); }; -template <> -struct ParamTraits { - typedef remoting::Monostate param_type; - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p); - static void Log(const param_type& p, std::string* l); -}; - template struct ParamTraits> { typedef remoting::Result param_type; diff --git a/remoting/host/file_transfer/ensure_user.h b/remoting/host/file_transfer/ensure_user.h index f358e81344f3b9..561d329871e434 100644 --- a/remoting/host/file_transfer/ensure_user.h +++ b/remoting/host/file_transfer/ensure_user.h @@ -17,7 +17,7 @@ namespace remoting { // user is on the log-in screen, an error of type NOT_LOGGED_IN will be // returned. If something else goes wrong, the error type will be // UNEXPECTED_ERROR. -protocol::FileTransferResult EnsureUserContext(); +protocol::FileTransferResult EnsureUserContext(); } // namespace remoting diff --git a/remoting/host/file_transfer/ensure_user_mac.cc b/remoting/host/file_transfer/ensure_user_mac.cc index da6c4b82ecd04e..6109d0da762344 100644 --- a/remoting/host/file_transfer/ensure_user_mac.cc +++ b/remoting/host/file_transfer/ensure_user_mac.cc @@ -10,7 +10,7 @@ namespace remoting { -protocol::FileTransferResult EnsureUserContext() { +protocol::FileTransferResult EnsureUserContext() { // Make sure we're not on the log-in screen. if (getuid() == 0) { LOG(ERROR) << "Cannot transfer files on log-in screen."; diff --git a/remoting/host/file_transfer/ensure_user_no_op.cc b/remoting/host/file_transfer/ensure_user_no_op.cc index 4905b97cc220a6..f04c8b5acb9ccb 100644 --- a/remoting/host/file_transfer/ensure_user_no_op.cc +++ b/remoting/host/file_transfer/ensure_user_no_op.cc @@ -6,7 +6,7 @@ namespace remoting { -protocol::FileTransferResult EnsureUserContext() { +protocol::FileTransferResult EnsureUserContext() { return kSuccessTag; } diff --git a/remoting/host/file_transfer/ensure_user_win.cc b/remoting/host/file_transfer/ensure_user_win.cc index 3ecfe197899132..74270beaacd8e6 100644 --- a/remoting/host/file_transfer/ensure_user_win.cc +++ b/remoting/host/file_transfer/ensure_user_win.cc @@ -12,7 +12,7 @@ namespace remoting { -protocol::FileTransferResult EnsureUserContext() { +protocol::FileTransferResult EnsureUserContext() { // Impersonate the currently logged-in user, or fail if there is none. HANDLE user_token = nullptr; if (!WTSQueryUserToken(WTS_CURRENT_SESSION, &user_token)) { diff --git a/remoting/host/file_transfer/file_chooser_win.cc b/remoting/host/file_transfer/file_chooser_win.cc index 9ae968700e0359..b1c2b1312d6607 100644 --- a/remoting/host/file_transfer/file_chooser_win.cc +++ b/remoting/host/file_transfer/file_chooser_win.cc @@ -112,7 +112,7 @@ class FileChooserWindows : public FileChooser, void OnObjectSignaled(HANDLE object) override; private: - FileTransferResult LaunchChooserProcess(); + FileTransferResult LaunchChooserProcess(); ResultCallback callback_; base::Process process_; @@ -126,7 +126,7 @@ FileChooserWindows::FileChooserWindows( : callback_(std::move(callback)) {} void FileChooserWindows::Show() { - FileTransferResult result = LaunchChooserProcess(); + FileTransferResult result = LaunchChooserProcess(); if (!result) { base::SequencedTaskRunnerHandle::Get()->PostTask( @@ -180,7 +180,7 @@ void FileChooserWindows::OnObjectSignaled(HANDLE object) { std::move(callback_).Run(std::move(result)); } -FileTransferResult FileChooserWindows::LaunchChooserProcess() { +FileTransferResult FileChooserWindows::LaunchChooserProcess() { base::LaunchOptions launch_options; FileTransferResult current_user = diff --git a/remoting/host/file_transfer/file_operations.h b/remoting/host/file_transfer/file_operations.h index 32b4b1745a1114..6b9e94ec155665 100644 --- a/remoting/host/file_transfer/file_operations.h +++ b/remoting/host/file_transfer/file_operations.h @@ -45,7 +45,7 @@ class FileOperations { class Reader { public: - using OpenResult = protocol::FileTransferResult; + using OpenResult = protocol::FileTransferResult; using OpenCallback = base::OnceCallback; // On success, |result| will contain the read data, or an empty vector on @@ -71,7 +71,7 @@ class FileOperations { class Writer { public: - using Result = protocol::FileTransferResult; + using Result = protocol::FileTransferResult; using Callback = base::OnceCallback; // Destructing before the file is completely written and closed will diff --git a/remoting/host/file_transfer/ipc_file_operations.h b/remoting/host/file_transfer/ipc_file_operations.h index 07fae0a284fa4b..09d848c8773dc4 100644 --- a/remoting/host/file_transfer/ipc_file_operations.h +++ b/remoting/host/file_transfer/ipc_file_operations.h @@ -43,7 +43,7 @@ class IpcFileOperations : public FileOperations { // Handles responses to file operations requests. class ResultHandler { public: - using Result = protocol::FileTransferResult; + using Result = protocol::FileTransferResult; using InfoResult = protocol::FileTransferResult>; using DataResult = diff --git a/remoting/host/file_transfer/local_file_operations.cc b/remoting/host/file_transfer/local_file_operations.cc index dff9c4622c4156..c3059fb9007c34 100644 --- a/remoting/host/file_transfer/local_file_operations.cc +++ b/remoting/host/file_transfer/local_file_operations.cc @@ -77,7 +77,7 @@ class LocalFileReader : public FileOperations::Reader { private: void OnEnsureUserResult(OpenCallback callback, - protocol::FileTransferResult result); + protocol::FileTransferResult result); void OnFileChooserResult(OpenCallback callback, FileChooser::Result result); void OnOpenResult(OpenCallback callback, base::File::Error error); void OnGetInfoResult(OpenCallback callback, @@ -196,7 +196,7 @@ FileOperations::State LocalFileReader::state() const { void LocalFileReader::OnEnsureUserResult( FileOperations::Reader::OpenCallback callback, - protocol::FileTransferResult result) { + protocol::FileTransferResult result) { if (!result) { SetState(FileOperations::kFailed); std::move(callback).Run(std::move(result.error())); @@ -313,7 +313,7 @@ void LocalFileWriter::Open(const base::FilePath& filename, Callback callback) { base::PostTaskAndReplyWithResult( file_task_runner_.get(), FROM_HERE, base::BindOnce([] { return EnsureUserContext().AndThen( - [](Monostate) { return GetDesktopDirectory(); }); + [](absl::monostate) { return GetDesktopDirectory(); }); }), base::BindOnce(&LocalFileWriter::OnGetTargetDirectoryResult, weak_ptr_factory_.GetWeakPtr(), filename, diff --git a/ui/accessibility/platform/inspect/ax_call_statement_invoker_auralinux.h b/ui/accessibility/platform/inspect/ax_call_statement_invoker_auralinux.h index 56c2d4b4772357..823bd271f05afe 100644 --- a/ui/accessibility/platform/inspect/ax_call_statement_invoker_auralinux.h +++ b/ui/accessibility/platform/inspect/ax_call_statement_invoker_auralinux.h @@ -6,7 +6,6 @@ #define UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_CALL_STATEMENT_INVOKER_AURALINUX_H_ #include -#include #include "base/memory/raw_ptr.h" #include "third_party/abseil-cpp/absl/types/variant.h" @@ -19,7 +18,7 @@ namespace ui { class AXPropertyNode; using Target = - absl::variant; + absl::variant; // Optional tri-state object. using AXOptionalObject = ui::AXOptional;