Commit 2570142a authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Clean-up components/password_manager/sync

Presubmit checks flag some deprecated functions in the sync layer of
password_manager component. This CL fixes those issues to unblock
merging that layer with the core layer in a separate CL.

The two most frequent fixes here are:
* Replacing base::Closure with base::RepeatingClosure in cases when
  this seems intended. Note 1: Closure is currently an alias for
  RepeatingClosure, so this results in no change. Note 2: There was
  also one case when OnceClosure was more appropriate. This was
  handled in https://crrev.com/c/1252582.
* arraysize -> base::size; this is the encouraged and a straightforward
  change

Bug: 515108
Change-Id: I554cff1c1ef1965eab82f87bbd3fceb92c2ebd41
Reviewed-on: https://chromium-review.googlesource.com/1252745Reviewed-by: default avatarChristos Froussios <cfroussios@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595434}
parent 0f5c25c7
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
namespace browser_sync { namespace browser_sync {
PasswordDataTypeController::PasswordDataTypeController( PasswordDataTypeController::PasswordDataTypeController(
const base::Closure& dump_stack, const base::RepeatingClosure& dump_stack,
syncer::SyncClient* sync_client, syncer::SyncClient* sync_client,
const base::Closure& state_changed_callback, const base::RepeatingClosure& state_changed_callback,
const scoped_refptr<password_manager::PasswordStore>& password_store) const scoped_refptr<password_manager::PasswordStore>& password_store)
: AsyncDirectoryTypeController(syncer::PASSWORDS, : AsyncDirectoryTypeController(syncer::PASSWORDS,
dump_stack, dump_stack,
...@@ -30,7 +30,7 @@ PasswordDataTypeController::~PasswordDataTypeController() {} ...@@ -30,7 +30,7 @@ PasswordDataTypeController::~PasswordDataTypeController() {}
bool PasswordDataTypeController::PostTaskOnModelThread( bool PasswordDataTypeController::PostTaskOnModelThread(
const base::Location& from_here, const base::Location& from_here,
const base::Closure& task) { const base::RepeatingClosure& task) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
if (!password_store_) if (!password_store_)
return false; return false;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H__ #ifndef COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H_
#define COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H__ #define COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H_
#include <string> #include <string>
...@@ -27,16 +27,16 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController, ...@@ -27,16 +27,16 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController,
public: public:
// |dump_stack| is called when an unrecoverable error occurs. // |dump_stack| is called when an unrecoverable error occurs.
PasswordDataTypeController( PasswordDataTypeController(
const base::Closure& dump_stack, const base::RepeatingClosure& dump_stack,
syncer::SyncClient* sync_client, syncer::SyncClient* sync_client,
const base::Closure& state_changed_callback, const base::RepeatingClosure& state_changed_callback,
const scoped_refptr<password_manager::PasswordStore>& password_store); const scoped_refptr<password_manager::PasswordStore>& password_store);
~PasswordDataTypeController() override; ~PasswordDataTypeController() override;
protected: protected:
// AsyncDirectoryTypeController interface. // AsyncDirectoryTypeController interface.
bool PostTaskOnModelThread(const base::Location& from_here, bool PostTaskOnModelThread(const base::Location& from_here,
const base::Closure& task) override; const base::RepeatingClosure& task) override;
bool StartModels() override; bool StartModels() override;
void StopModels() override; void StopModels() override;
...@@ -45,7 +45,7 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController, ...@@ -45,7 +45,7 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController,
private: private:
syncer::SyncClient* const sync_client_; syncer::SyncClient* const sync_client_;
const base::Closure state_changed_callback_; const base::RepeatingClosure state_changed_callback_;
scoped_refptr<password_manager::PasswordStore> password_store_; scoped_refptr<password_manager::PasswordStore> password_store_;
DISALLOW_COPY_AND_ASSIGN(PasswordDataTypeController); DISALLOW_COPY_AND_ASSIGN(PasswordDataTypeController);
...@@ -53,4 +53,4 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController, ...@@ -53,4 +53,4 @@ class PasswordDataTypeController : public syncer::AsyncDirectoryTypeController,
} // namespace browser_sync } // namespace browser_sync
#endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H__ #endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_DATA_TYPE_CONTROLLER_H_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <stddef.h> #include <stddef.h>
#include "base/macros.h" #include "base/stl_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/password_reuse_defines.h" #include "components/password_manager/core/browser/password_reuse_defines.h"
...@@ -24,7 +24,7 @@ using autofill::PasswordForm; ...@@ -24,7 +24,7 @@ using autofill::PasswordForm;
namespace password_manager { namespace password_manager {
namespace sync_util { namespace sync_util {
typedef SyncUsernameTestBase PasswordSyncUtilTest; using PasswordSyncUtilTest = SyncUsernameTestBase;
PasswordForm SimpleGAIAChangePasswordForm() { PasswordForm SimpleGAIAChangePasswordForm() {
PasswordForm form; PasswordForm form;
...@@ -58,7 +58,7 @@ TEST_F(PasswordSyncUtilTest, GetSyncUsernameIfSyncingPasswords) { ...@@ -58,7 +58,7 @@ TEST_F(PasswordSyncUtilTest, GetSyncUsernameIfSyncingPasswords) {
nullptr}, nullptr},
}; };
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
SetSyncingPasswords(kTestCases[i].password_sync == SetSyncingPasswords(kTestCases[i].password_sync ==
TestCase::SYNCING_PASSWORDS); TestCase::SYNCING_PASSWORDS);
...@@ -85,7 +85,7 @@ TEST_F(PasswordSyncUtilTest, IsSyncAccountCredential) { ...@@ -85,7 +85,7 @@ TEST_F(PasswordSyncUtilTest, IsSyncAccountCredential) {
{SimpleGAIAChangePasswordForm(), "sync_user@example.org", true}, {SimpleGAIAChangePasswordForm(), "sync_user@example.org", true},
}; };
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
SetSyncingPasswords(true); SetSyncingPasswords(true);
FakeSigninAs(kTestCases[i].fake_sync_username); FakeSigninAs(kTestCases[i].fake_sync_username);
...@@ -179,7 +179,7 @@ TEST_F(PasswordSyncUtilEnterpriseTest, ShouldSavePasswordHash) { ...@@ -179,7 +179,7 @@ TEST_F(PasswordSyncUtilEnterpriseTest, ShouldSavePasswordHash) {
}; };
for (bool syncing_passwords : {false, true}) { for (bool syncing_passwords : {false, true}) {
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
SetSyncingPasswords(syncing_passwords); SetSyncingPasswords(syncing_passwords);
FakeSigninAs(kTestCases[i].fake_sync_username); FakeSigninAs(kTestCases[i].fake_sync_username);
......
...@@ -22,10 +22,10 @@ namespace password_manager { ...@@ -22,10 +22,10 @@ namespace password_manager {
// The sync- and GAIA- aware implementation of the filter. // The sync- and GAIA- aware implementation of the filter.
class SyncCredentialsFilter : public CredentialsFilter { class SyncCredentialsFilter : public CredentialsFilter {
public: public:
typedef base::Callback<const syncer::SyncService*(void)> using SyncServiceFactoryFunction =
SyncServiceFactoryFunction; base::RepeatingCallback<const syncer::SyncService*(void)>;
typedef base::Callback<const SigninManagerBase*(void)> using SigninManagerFactoryFunction =
SigninManagerFactoryFunction; base::RepeatingCallback<const SigninManagerBase*(void)>;
// Implements protection of sync credentials. Uses |client| to get the last // Implements protection of sync credentials. Uses |client| to get the last
// commited entry URL for a check against GAIA reauth site. Uses the factory // commited entry URL for a check against GAIA reauth site. Uses the factory
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h" #include "base/test/metrics/user_action_tester.h"
...@@ -139,10 +140,10 @@ class CredentialsFilterTest : public SyncUsernameTestBase { ...@@ -139,10 +140,10 @@ class CredentialsFilterTest : public SyncUsernameTestBase {
std::make_unique<StubFormSaver>(), std::make_unique<StubFormSaver>(),
&fetcher_), &fetcher_),
filter_(&client_, filter_(&client_,
base::Bind(&SyncUsernameTestBase::sync_service, base::BindRepeating(&SyncUsernameTestBase::sync_service,
base::Unretained(this)), base::Unretained(this)),
base::Bind(&SyncUsernameTestBase::signin_manager, base::BindRepeating(&SyncUsernameTestBase::signin_manager,
base::Unretained(this))) { base::Unretained(this))) {
form_manager_.Init(nullptr); form_manager_.Init(nullptr);
fetcher_.Fetch(); fetcher_.Fetch();
} }
...@@ -224,7 +225,7 @@ TEST_F(CredentialsFilterTest, FilterResults_AllowAll_SyncingAccount) { ...@@ -224,7 +225,7 @@ TEST_F(CredentialsFilterTest, FilterResults_AllowAll_SyncingAccount) {
TestCase::NO_HISTOGRAM}, TestCase::NO_HISTOGRAM},
}; };
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
CheckFilterResultsTestCase(kTestCases[i]); CheckFilterResultsTestCase(kTestCases[i]);
} }
...@@ -276,7 +277,7 @@ TEST_F(CredentialsFilterTest, ...@@ -276,7 +277,7 @@ TEST_F(CredentialsFilterTest,
TestCase::NO_HISTOGRAM}, TestCase::NO_HISTOGRAM},
}; };
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
CheckFilterResultsTestCase(kTestCases[i]); CheckFilterResultsTestCase(kTestCases[i]);
} }
...@@ -326,7 +327,7 @@ TEST_F(CredentialsFilterTest, FilterResults_DisallowSync_SyncingAccount) { ...@@ -326,7 +327,7 @@ TEST_F(CredentialsFilterTest, FilterResults_DisallowSync_SyncingAccount) {
TestCase::HISTOGRAM_REPORTED}, TestCase::HISTOGRAM_REPORTED},
}; };
for (size_t i = 0; i < arraysize(kTestCases); ++i) { for (size_t i = 0; i < base::size(kTestCases); ++i) {
SCOPED_TRACE(testing::Message() << "i=" << i); SCOPED_TRACE(testing::Message() << "i=" << i);
CheckFilterResultsTestCase(kTestCases[i]); CheckFilterResultsTestCase(kTestCases[i]);
} }
......
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