Skip to content

Commit

Permalink
Use std::ignore rather than ignore_result in chrome/
Browse files Browse the repository at this point in the history
Bug: 1285085
Change-Id: I4e033ad799d5a1f7a6240643a7c27e474d72a30d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3370430
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956679}
  • Loading branch information
Avi Drissman authored and Chromium LUCI CQ committed Jan 7, 2022
1 parent d088678 commit 8eed2d7
Show file tree
Hide file tree
Showing 58 changed files with 180 additions and 161 deletions.
5 changes: 3 additions & 2 deletions chrome/browser/android/customtabs/custom_tabs_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/ignore_result.h"
#include <tuple>

#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -94,7 +95,7 @@ class CustomTabsHeader : public AndroidBrowserTest {
auto* web_contents = content::WebContents::FromRenderFrameHost(host);
ClientDataHeaderWebContentsObserver::FromWebContents(web_contents)
->SetHeader(kHeaderValue2);
ignore_result(ExecJs(host, "document.images[0].src = 'google3.jpg'"));
std::ignore = ExecJs(host, "document.images[0].src = 'google3.jpg'");
}

private:
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ash/app_mode/kiosk_profile_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "chrome/browser/ash/app_mode/kiosk_profile_loader.h"

#include <memory>
#include <tuple>

#include "ash/components/login/auth/auth_status_consumer.h"
#include "ash/components/login/auth/user_context.h"
#include "base/bind.h"
#include "base/ignore_result.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
Expand Down Expand Up @@ -179,7 +179,7 @@ void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) {
void KioskProfileLoader::OnAuthSuccess(const UserContext& user_context) {
// LoginPerformer will delete itself.
login_performer_->set_delegate(NULL);
ignore_result(login_performer_.release());
std::ignore = login_performer_.release();

failed_mount_attempts_ = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <algorithm>
#include <memory>
#include <string>
#include <tuple>
#include <utility>

#include "base/ignore_result.h"
#include "chrome/common/extensions/api/file_system_provider.h"
#include "chrome/common/extensions/api/file_system_provider_internal.h"

Expand Down Expand Up @@ -55,8 +55,8 @@ bool ConvertRequestValueToFileInfo(std::unique_ptr<RequestValue> value,
// Allow to pass invalid modification time, since there is no way to verify
// it easily on any earlier stage.
base::Time output_modification_time;
ignore_result(base::Time::FromString(input_modification_time.c_str(),
&output_modification_time));
std::ignore = base::Time::FromString(input_modification_time.c_str(),
&output_modification_time);
output->modification_time =
std::make_unique<base::Time>(output_modification_time);
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ash/login/existing_user_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chrome/browser/ash/login/existing_user_controller.h"

#include <memory>
#include <tuple>
#include <utility>
#include <vector>

Expand All @@ -23,7 +24,6 @@
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/scoped_observation.h"
Expand Down Expand Up @@ -911,7 +911,7 @@ void ExistingUserController::OnAuthSuccess(const UserContext& user_context) {

// LoginPerformer instance will delete itself in case of successful auth.
login_performer_->set_delegate(nullptr);
ignore_result(login_performer_.release());
std::ignore = login_performer_.release();

if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_OFFLINE) {
base::UmaHistogramCounts100("Login.OfflineSuccess.Attempts",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ash/login/users/chrome_user_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <memory>
#include <set>
#include <tuple>
#include <utility>
#include <vector>

Expand All @@ -25,7 +26,6 @@
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/ignore_result.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -162,7 +162,7 @@ void OnRemoveUserComplete(const AccountId& account_id,
// Runs on SequencedWorkerPool thread. Passes resolved locale to UI thread.
void ResolveLocale(const std::string& raw_locale,
std::string* resolved_locale) {
ignore_result(l10n_util::CheckAndResolveLocale(raw_locale, resolved_locale));
std::ignore = l10n_util::CheckAndResolveLocale(raw_locale, resolved_locale);
}

bool GetUserLockAttributes(const user_manager::User* user,
Expand Down
30 changes: 15 additions & 15 deletions chrome/browser/ash/smb_client/smb_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stddef.h>

#include <memory>
#include <tuple>
#include <utility>

#include "ash/components/disks/disk_mount_manager.h"
Expand All @@ -15,7 +16,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/json/json_reader.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
Expand Down Expand Up @@ -710,10 +710,10 @@ TEST_F(SmbServiceWithSmbfsTest, MountExcessiveShares) {
std::string(kSharePath) + base::NumberToString(i);
const std::string mount_path =
std::string(kMountPath) + base::NumberToString(i);
ignore_result(MountBasicShare(share_path, mount_path,
std::ignore = MountBasicShare(share_path, mount_path,
base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kSuccess, result);
})));
}));
}

// Check: After mounting the maximum number of shares, requesting to mount an
Expand All @@ -722,24 +722,24 @@ TEST_F(SmbServiceWithSmbfsTest, MountExcessiveShares) {
std::string(kSharePath) + base::NumberToString(kMaxSmbFsShares);
const std::string mount_path =
std::string(kMountPath) + base::NumberToString(kMaxSmbFsShares);
ignore_result(MountBasicShare(
std::ignore = MountBasicShare(
share_path, mount_path, base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kTooManyOpened, result);
})));
}));
}

TEST_F(SmbServiceWithSmbfsTest, GetSmbFsShareForPath) {
CreateService(profile_);
WaitForSetupComplete();

ignore_result(MountBasicShare(kSharePath, kMountPath,
std::ignore = MountBasicShare(kSharePath, kMountPath,
base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kSuccess, result);
})));
ignore_result(MountBasicShare(kSharePath2, kMountPath2,
}));
std::ignore = MountBasicShare(kSharePath2, kMountPath2,
base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kSuccess, result);
})));
}));

SmbFsShare* share =
smb_service_->GetSmbFsShareForPath(base::FilePath(kMountPath));
Expand All @@ -764,23 +764,23 @@ TEST_F(SmbServiceWithSmbfsTest, MountDuplicate) {
CreateService(profile_);
WaitForSetupComplete();

ignore_result(MountBasicShare(kSharePath, kMountPath,
std::ignore = MountBasicShare(kSharePath, kMountPath,
base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kSuccess, result);
})));
}));

// A second mount with the same share path should fail.
ignore_result(MountBasicShare(
std::ignore = MountBasicShare(
kSharePath, kMountPath2, base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kMountExists, result);
})));
}));

// Unmounting and mounting again should succeed.
smb_service_->UnmountSmbFs(base::FilePath(kMountPath));
ignore_result(MountBasicShare(kSharePath, kMountPath2,
std::ignore = MountBasicShare(kSharePath, kMountPath2,
base::BindOnce([](SmbMountResult result) {
EXPECT_EQ(SmbMountResult::kSuccess, result);
})));
}));
}

} // namespace smb_client
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/autofill/autofill_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#include <memory>
#include <string>
#include <tuple>

#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/rand_util.h"
Expand Down Expand Up @@ -872,9 +872,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderAutofillTest, DeferWhilePrerendering) {

int host_id = prerender_helper().AddPrerender(prerender_url);
auto* rfh = prerender_helper().GetPrerenderedMainFrameHost(host_id);
ignore_result(
std::ignore =
content::ExecJs(rfh, "document.querySelector('#NAME_FIRST').focus();",
content::EXECUTE_SCRIPT_NO_USER_GESTURE));
content::EXECUTE_SCRIPT_NO_USER_GESTURE);

// Since the initial prerender page load has finished at this point and we
// have issued our programmatic focus, we need to check that the expectations
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browsing_data/access_context_audit_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

#include "chrome/browser/browsing_data/access_context_audit_database.h"

#include <tuple>

#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
Expand Down Expand Up @@ -43,7 +44,7 @@ void DatabaseErrorCallback(sql::Database* db,
// or hardware issues, not coding errors at the client level, so displaying
// the error would probably lead to confusion. The ignored call signals the
// test-expectation framework that the error was handled.
ignore_result(sql::Database::IsExpectedSqliteError(extended_error));
std::ignore = sql::Database::IsExpectedSqliteError(extended_error);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/captive_portal/captive_portal_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Expand All @@ -18,7 +19,6 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
Expand Down Expand Up @@ -916,7 +916,7 @@ class CaptivePortalBrowserTest : public InProcessBrowserTest {
EXPECT_EQ(expected_num_jobs,
static_cast<int>(ongoing_mock_requests_.size()));
for (auto& job : ongoing_mock_requests_)
ignore_result(job.client.Unbind().PassPipe().release());
std::ignore = job.client.Unbind().PassPipe().release();
ongoing_mock_requests_.clear();
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <memory>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Expand All @@ -24,7 +25,6 @@
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
Expand Down Expand Up @@ -1867,7 +1867,7 @@ void ChromeBrowserMainParts::PostDestroyThreads() {
// The below call to browser_shutdown::ShutdownPostThreadsStop() deletes
// |browser_process_|. We release it so that we don't keep holding onto an
// invalid reference.
ignore_result(browser_process_.release());
std::ignore = browser_process_.release();

#if BUILDFLAG(ENABLE_DOWNGRADE_PROCESSING)
if (result_code_ == chrome::RESULT_CODE_DOWNGRADE_AND_RELAUNCH) {
Expand Down
11 changes: 6 additions & 5 deletions chrome/browser/chrome_security_exploit_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <tuple>

#include "base/bind.h"
#include "base/command_line.h"
#include "base/ignore_result.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
Expand Down Expand Up @@ -500,8 +501,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityExploitBrowserTestMojoBlobURLs,

// The renderer should always get killed, but sometimes ExecuteScript returns
// true anyway, so just ignore the result.
ignore_result(
content::ExecuteScript(rfh, "URL.createObjectURL(new Blob(['foo']))"));
std::ignore =
content::ExecuteScript(rfh, "URL.createObjectURL(new Blob(['foo']))");

// If the process is killed, this test passes.
EXPECT_EQ(
Expand Down Expand Up @@ -544,8 +545,8 @@ IN_PROC_BROWSER_TEST_F(ChromeSecurityExploitBrowserTestMojoBlobURLs,

// The renderer should always get killed, but sometimes ExecuteScript returns
// true anyway, so just ignore the result.
ignore_result(
content::ExecuteScript(rfh, "URL.createObjectURL(new Blob(['foo']))"));
std::ignore =
content::ExecuteScript(rfh, "URL.createObjectURL(new Blob(['foo']))");

// If the process is killed, this test passes.
EXPECT_EQ(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
#include <stddef.h>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/guid.h"
#include "base/ignore_result.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
Expand Down Expand Up @@ -159,7 +159,7 @@ std::string ReadFileToString(const base::FilePath& path) {
std::string data;
// This call can fail, but it doesn't matter for our purposes. If it fails,
// we simply return an empty string for the manifest, and ignore it.
ignore_result(base::ReadFileToString(path, &data));
std::ignore = base::ReadFileToString(path, &data);
return data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h"

#include <memory>
#include <tuple>
#include <utility>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/ignore_result.h"
#include "base/json/json_file_value_serializer.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
Expand Down Expand Up @@ -126,7 +126,7 @@ void ScopedTestNativeMessagingHost::RegisterTestHost(bool user_level) {

ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {
base::ScopedAllowBlockingForTesting allow_blocking;
ignore_result(temp_dir_.Delete());
std::ignore = temp_dir_.Delete();
}

} // namespace extensions
7 changes: 4 additions & 3 deletions chrome/browser/extensions/process_management_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include <stddef.h>

#include "base/ignore_result.h"
#include <tuple>

#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
Expand Down Expand Up @@ -709,8 +710,8 @@ IN_PROC_BROWSER_TEST_F(

// WaitForLoadStop() will return false on a 404, but that can happen if we
// navigate to a blocked or nonexistent extension page.
ignore_result(content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents()));
std::ignore = content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());

EXPECT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, kGetAccess,
&can_access));
Expand Down
Loading

0 comments on commit 8eed2d7

Please sign in to comment.