Commit 2c695fe8 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Introduce BulkLeakCheckService::kCancelled state.

Bug: 1049185
Change-Id: I9a688339f61d60d943088c413857744d7090e98b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094129
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748241}
parent f0f01b00
......@@ -69,6 +69,8 @@ api::passwords_private::PasswordCheckState ConvertPasswordCheckState(
return api::passwords_private::PASSWORD_CHECK_STATE_IDLE;
case BulkLeakCheckService::State::kRunning:
return api::passwords_private::PASSWORD_CHECK_STATE_RUNNING;
case BulkLeakCheckService::State::kCanceled:
return api::passwords_private::PASSWORD_CHECK_STATE_CANCELED;
case BulkLeakCheckService::State::kSignedOut:
return api::passwords_private::PASSWORD_CHECK_STATE_SIGNED_OUT;
case BulkLeakCheckService::State::kNetworkError:
......
......@@ -157,6 +157,7 @@ void SafetyCheckHandler::OnStateChanged(
using password_manager::BulkLeakCheckService;
switch (state) {
case BulkLeakCheckService::State::kIdle:
case BulkLeakCheckService::State::kCanceled:
// TODO(crbug.com/1015841): Implement retrieving the number
// of leaked passwords (if any) once PasswordsPrivateDelegate provides an
// API for that (see crrev.com/c/2072742).
......
......@@ -53,7 +53,7 @@ void BulkLeakCheckService::Cancel() {
DCHECK_NE(State::kRunning, state_);
return;
}
state_ = State::kIdle;
state_ = State::kCanceled;
bulk_leak_check_.reset();
NotifyStateChanged();
}
......
......@@ -42,6 +42,8 @@ class BulkLeakCheckService : public KeyedService,
// Those below are error states. On any error the current job is aborted.
// The error is sticky until next CheckUsernamePasswordPairs() call.
// Cancel() aborted the running check.
kCanceled,
// The user isn't signed-in to Chrome.
kSignedOut,
// Error obtaining an access token.
......
......@@ -192,10 +192,10 @@ TEST_F(BulkLeakCheckServiceTest, CancelSomething) {
StrictMock<MockObserver> observer;
service().AddObserver(&observer);
EXPECT_CALL(observer, OnStateChanged(BulkLeakCheckService::State::kIdle));
EXPECT_CALL(observer, OnStateChanged(BulkLeakCheckService::State::kCanceled));
service().Cancel();
EXPECT_EQ(BulkLeakCheckService::State::kIdle, service().state());
EXPECT_EQ(BulkLeakCheckService::State::kCanceled, service().state());
EXPECT_EQ(0u, service().GetPendingChecksCount());
}
......
......@@ -206,7 +206,7 @@ TEST_F(BulkLeakCheckServiceAdapterTest, StopBulkLeakCheck) {
adapter().GetBulkLeakCheckState());
adapter().StopBulkLeakCheck();
EXPECT_EQ(BulkLeakCheckService::State::kIdle,
EXPECT_EQ(BulkLeakCheckService::State::kCanceled,
adapter().GetBulkLeakCheckState());
}
......
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