Migrate ignore_result to std::ignore (see issue #3234)

See https://crbug.com/1285085 for background.
This commit is contained in:
Marshall Greenblatt 2022-01-25 14:40:24 -05:00
parent ebde595370
commit c32f366dfa
12 changed files with 32 additions and 40 deletions

View File

@ -156,7 +156,7 @@
// Annotate a function indicating the caller must examine the return value.
// Use like:
// int foo() WARN_UNUSED_RESULT;
// To explicitly ignore a result, see |ignore_result()| in base/macros.h.
// To explicitly ignore a result, use std::ignore from <tuple>.
#undef WARN_UNUSED_RESULT
#if defined(COMPILER_GCC) || defined(__clang__)
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))

View File

@ -32,11 +32,7 @@
#define CEF_INCLUDE_BASE_CEF_MACROS_H_
#pragma once
#if defined(USING_CHROMIUM_INCLUDES)
// When building CEF include the Chromium header directly.
#include "base/ignore_result.h"
#else // !USING_CHROMIUM_INCLUDES
#if !defined(USING_CHROMIUM_INCLUDES)
// The following is substantially similar to the Chromium implementation.
// If the Chromium implementation diverges the below implementation should be
// updated to match.
@ -62,17 +58,6 @@
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)
// Used to explicitly mark the return value of a function as unused. If you are
// really sure you don't want to do anything with the return value of a function
// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
//
// std::unique_ptr<MyType> my_var = ...;
// if (TakeOwnership(my_var.get()) == SUCCESS)
// ignore_result(my_var.release());
//
template <typename T>
inline void ignore_result(const T&) {}
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_

View File

@ -5,6 +5,7 @@
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include <algorithm>
#include <tuple>
#include <utility>
#include "include/cef_version.h"
@ -46,7 +47,6 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/ignore_result.h"
#include "base/json/json_reader.h"
#include "base/path_service.h"
#include "base/stl_util.h"
@ -846,7 +846,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
std::ignore = commandLinePtr->Detach(nullptr);
}
}
}

View File

@ -4,6 +4,8 @@
#include "libcef/browser/browser_host_base.h"
#include <tuple>
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/context.h"
@ -13,7 +15,6 @@
#include "libcef/common/frame_util.h"
#include "libcef/common/net/url_util.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
@ -346,7 +347,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(current));
visitor->Visit(entry.get(), true, current, total);
ignore_result(entry->Detach(nullptr));
std::ignore = entry->Detach(nullptr);
} else {
// Visit all entries.
bool cont = true;
@ -354,7 +355,7 @@ void CefBrowserHostBase::GetNavigationEntries(
CefRefPtr<CefNavigationEntryImpl> entry =
new CefNavigationEntryImpl(controller.GetEntryAtIndex(i));
cont = visitor->Visit(entry.get(), (i == current), i, total);
ignore_result(entry->Detach(nullptr));
std::ignore = entry->Detach(nullptr);
}
}
}

View File

@ -5,6 +5,8 @@
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include <tuple>
#include "libcef/browser/browser_frame.h"
#include "libcef/browser/browser_info_manager.h"
#include "libcef/browser/browser_manager.h"
@ -24,7 +26,6 @@
#include "libcef/common/command_line_impl.h"
#include "base/command_line.h"
#include "base/ignore_result.h"
#include "base/path_service.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/net/system_network_context_manager.h"
@ -137,7 +138,7 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
CefRefPtr<CefCommandLineImpl> commandLinePtr(
new CefCommandLineImpl(command_line, false, false));
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
std::ignore = commandLinePtr->Detach(nullptr);
}
}
}

View File

@ -4,6 +4,8 @@
#include "libcef/browser/download_manager_delegate.h"
#include <tuple>
#include "include/cef_download_handler.h"
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
#include "libcef/browser/context.h"
@ -12,7 +14,6 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
@ -296,7 +297,7 @@ void CefDownloadManagerDelegate::OnDownloadUpdated(DownloadItem* download) {
handler->OnDownloadUpdated(browser.get(), download_item.get(), callback);
ignore_result(download_item->Detach(nullptr));
std::ignore = download_item->Detach(nullptr);
}
}
@ -391,7 +392,7 @@ bool CefDownloadManagerDelegate::DetermineDownloadTarget(
handler->OnBeforeDownload(browser.get(), download_item.get(),
suggested_name.value(), callbackObj);
ignore_result(download_item->Detach(nullptr));
std::ignore = download_item->Detach(nullptr);
}
return true;

View File

@ -4,6 +4,7 @@
#include "libcef/browser/menu_manager.h"
#include <tuple>
#include <utility>
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
@ -13,7 +14,6 @@
#include "libcef/common/app_manager.h"
#include "base/compiler_specific.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "cef/grit/cef_strings.h"
#include "chrome/grit/generated_resources.h"
@ -177,7 +177,7 @@ bool CefMenuManager::CreateContextMenu(
}
// Do not keep references to the parameters in the callback.
ignore_result(paramsPtr->Detach(nullptr));
std::ignore = paramsPtr->Detach(nullptr);
DCHECK(paramsPtr->HasOneRef());
DCHECK(model_->VerifyRefCount());
@ -219,7 +219,7 @@ void CefMenuManager::ExecuteCommand(CefRefPtr<CefMenuModelImpl> source,
event_flags);
// Do not keep references to the parameters in the callback.
ignore_result(paramsPtr->Detach(nullptr));
std::ignore = paramsPtr->Detach(nullptr);
DCHECK(paramsPtr->HasOneRef());
if (handled)

View File

@ -5,6 +5,8 @@
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
#include <tuple>
#include "libcef/browser/context.h"
#include "libcef/browser/origin_whitelist_impl.h"
#include "libcef/browser/thread_util.h"
@ -14,7 +16,6 @@
#include "base/barrier_closure.h"
#include "base/command_line.h"
#include "base/ignore_result.h"
#include "base/strings/string_number_conversions.h"
#include "components/safe_browsing/core/common/safebrowsing_constants.h"
#include "content/public/browser/browser_context.h"
@ -440,7 +441,7 @@ void InterceptedRequest::Restart() {
}
if (header_client_receiver_.is_bound())
ignore_result(header_client_receiver_.Unbind());
std::ignore = header_client_receiver_.Unbind();
current_request_uses_header_client_ =
factory_->url_loader_header_client_receiver_.is_bound();

View File

@ -4,6 +4,8 @@
#include "libcef/common/alloy/alloy_main_delegate.h"
#include <tuple>
#include "libcef/browser/alloy/alloy_browser_context.h"
#include "libcef/browser/alloy/alloy_content_browser_client.h"
#include "libcef/common/cef_switches.h"
@ -17,7 +19,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@ -280,7 +281,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
new CefCommandLineImpl(command_line, false, false));
application_->OnBeforeCommandLineProcessing(CefString(process_type),
commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
std::ignore = commandLinePtr->Detach(nullptr);
}
// Initialize logging.

View File

@ -5,6 +5,8 @@
#include "libcef/common/chrome/chrome_main_delegate_cef.h"
#include <tuple>
#include "libcef/browser/chrome/chrome_browser_context.h"
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
#include "libcef/common/cef_switches.h"
@ -14,7 +16,6 @@
#include "libcef/renderer/chrome/chrome_content_renderer_client_cef.h"
#include "base/command_line.h"
#include "base/ignore_result.h"
#include "base/lazy_instance.h"
#include "chrome/common/chrome_switches.h"
#include "components/embedder_support/switches.h"
@ -126,7 +127,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
new CefCommandLineImpl(command_line, false, false));
application_->OnBeforeCommandLineProcessing(process_type,
commandLinePtr.get());
ignore_result(commandLinePtr->Detach(nullptr));
std::ignore = commandLinePtr->Detach(nullptr);
}
#if BUILDFLAG(IS_MAC)

View File

@ -4,7 +4,7 @@
#include "libcef/common/time_util.h"
#include "base/ignore_result.h"
#include <tuple>
#if BUILDFLAG(IS_WIN)
#include <limits>
@ -33,7 +33,7 @@ void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
exploded.minute = cef_time.minute;
exploded.second = cef_time.second;
exploded.millisecond = cef_time.millisecond;
ignore_result(base::Time::FromUTCExploded(exploded, &time));
std::ignore = base::Time::FromUTCExploded(exploded, &time);
}
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {

View File

@ -4,6 +4,8 @@
#include "libcef/renderer/render_manager.h"
#include <tuple>
#include "base/compiler_specific.h"
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
@ -28,7 +30,6 @@
#include "libcef/renderer/v8_impl.h"
#include "base/command_line.h"
#include "base/ignore_result.h"
#include "base/strings/string_number_conversions.h"
#include "cef/libcef/common/mojom/cef.mojom.h"
#include "content/public/common/content_switches.h"
@ -353,7 +354,7 @@ CefRefPtr<CefBrowserImpl> CefRenderManager::MaybeCreateBrowser(
}
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
if (dictValuePtr)
ignore_result(dictValuePtr->Detach(nullptr));
std::ignore = dictValuePtr->Detach(nullptr);
}
}