Commit 9f661efb authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Change pass by value to pass by ref to const.

This is a follow up for
https://chromium-review.googlesource.com/c/chromium/src/+/2495332

The idea is that passing input parameters by const references, when
possible is still the C++ style.

I don't recall what the specific issue was when the code did not
build in the original CL. At any rate, this change does not
affect the lifetime of any of the parameters, since the binding
of the references in callbacks is always by value, unless the
caller specifies std::ref of std::cref.

Bug: 1147094
Change-Id: I47c9aef89ddbeea386e6efb9f8ae42d3385c3601
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547430Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829236}
parent f3fbebe1
...@@ -107,7 +107,8 @@ void ControlServiceImpl::MaybeCheckForUpdates() { ...@@ -107,7 +107,8 @@ void ControlServiceImpl::MaybeCheckForUpdates() {
base::BindOnce(std::move(callback_)), config_)); base::BindOnce(std::move(callback_)), config_));
} }
void ControlServiceImpl::UnregisterMissingApps(std::vector<AppInfo> apps) { void ControlServiceImpl::UnregisterMissingApps(
const std::vector<AppInfo>& apps) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ThreadPool::PostTaskAndReplyWithResult( base::ThreadPool::PostTaskAndReplyWithResult(
...@@ -123,7 +124,7 @@ void ControlServiceImpl::UnregisterMissingAppsDone() { ...@@ -123,7 +124,7 @@ void ControlServiceImpl::UnregisterMissingAppsDone() {
} }
std::vector<ControlServiceImpl::PingInfo> ControlServiceImpl::GetAppIDsToRemove( std::vector<ControlServiceImpl::PingInfo> ControlServiceImpl::GetAppIDsToRemove(
std::vector<AppInfo> apps) { const std::vector<AppInfo>& apps) {
std::vector<PingInfo> app_ids_to_remove; std::vector<PingInfo> app_ids_to_remove;
for (const auto& app : apps) { for (const auto& app : apps) {
// Skip if app_id is equal to updater app id. // Skip if app_id is equal to updater app id.
...@@ -143,7 +144,7 @@ std::vector<ControlServiceImpl::PingInfo> ControlServiceImpl::GetAppIDsToRemove( ...@@ -143,7 +144,7 @@ std::vector<ControlServiceImpl::PingInfo> ControlServiceImpl::GetAppIDsToRemove(
} }
void ControlServiceImpl::RemoveAppIDsAndSendUninstallPings( void ControlServiceImpl::RemoveAppIDsAndSendUninstallPings(
std::vector<PingInfo> app_ids_to_remove) { const std::vector<PingInfo>& app_ids_to_remove) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (app_ids_to_remove.empty()) { if (app_ids_to_remove.empty()) {
...@@ -151,10 +152,10 @@ void ControlServiceImpl::RemoveAppIDsAndSendUninstallPings( ...@@ -151,10 +152,10 @@ void ControlServiceImpl::RemoveAppIDsAndSendUninstallPings(
return; return;
} }
for (const auto& app_id_to_remove : app_ids_to_remove) { for (const PingInfo& app_id_to_remove : app_ids_to_remove) {
const auto app_id = app_id_to_remove.app_id_; const std::string& app_id = app_id_to_remove.app_id_;
const int ping_reason = app_id_to_remove.ping_reason_; const int ping_reason = app_id_to_remove.ping_reason_;
const base::Version app_version = app_id_to_remove.app_version_; const base::Version& app_version = app_id_to_remove.app_version_;
if (persisted_data_->RemoveApp(app_id)) { if (persisted_data_->RemoveApp(app_id)) {
VLOG(1) << "Uninstall ping for app id: " << app_id VLOG(1) << "Uninstall ping for app id: " << app_id
......
...@@ -75,7 +75,7 @@ class ControlServiceImpl : public ControlService { ...@@ -75,7 +75,7 @@ class ControlServiceImpl : public ControlService {
// Provides a way to remove apps from the persisted data if the app is no // Provides a way to remove apps from the persisted data if the app is no
// longer installed on the machine. // longer installed on the machine.
void UnregisterMissingApps(std::vector<AppInfo> apps); void UnregisterMissingApps(const std::vector<AppInfo>& apps);
// After an uninstall ping has been processed, reduces the number of pings // After an uninstall ping has been processed, reduces the number of pings
// that we need to wait on before checking for updates. // that we need to wait on before checking for updates.
...@@ -87,12 +87,12 @@ class ControlServiceImpl : public ControlService { ...@@ -87,12 +87,12 @@ class ControlServiceImpl : public ControlService {
// Returns a list of apps that need to be unregistered. // Returns a list of apps that need to be unregistered.
std::vector<ControlServiceImpl::PingInfo> GetAppIDsToRemove( std::vector<ControlServiceImpl::PingInfo> GetAppIDsToRemove(
std::vector<AppInfo> apps); const std::vector<AppInfo>& apps);
// Unregisters the apps in |app_ids_to_remove| and starts an update check // Unregisters the apps in |app_ids_to_remove| and starts an update check
// if necessary. // if necessary.
void RemoveAppIDsAndSendUninstallPings( void RemoveAppIDsAndSendUninstallPings(
std::vector<PingInfo> app_ids_to_remove); const std::vector<PingInfo>& app_ids_to_remove);
scoped_refptr<updater::Configurator> config_; scoped_refptr<updater::Configurator> config_;
scoped_refptr<updater::PersistedData> persisted_data_; scoped_refptr<updater::PersistedData> persisted_data_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment