Commit b8aae0c6 authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Chromium LUCI CQ

Convert c/b/sync_file_system/drive_backend/ to OnPrimaryAccountChanged()

Methods OnPrimaryAccountSet/Cleared() are deprecated, so this CL changes
the chrome/browser/sync_file_system/drive_backend/* to override the
method OnPrimaryAccountChanged().

Bug: 1163126
Change-Id: Ib619c24eff3778cf658acfef90009e240d7cea09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611088
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Auto-Submit: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840964}
parent cb7c16aa
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "storage/browser/quota/quota_manager.h" #include "storage/browser/quota/quota_manager.h"
#include "third_party/leveldatabase/leveldb_chrome.h" #include "third_party/leveldatabase/leveldb_chrome.h"
using signin::PrimaryAccountChangeEvent;
namespace sync_file_system { namespace sync_file_system {
namespace { namespace {
...@@ -125,11 +127,6 @@ class SyncFileSystemTest : public extensions::PlatformAppBrowserTest, ...@@ -125,11 +127,6 @@ class SyncFileSystemTest : public extensions::PlatformAppBrowserTest,
void SignIn() { void SignIn() {
identity_test_env_->SetPrimaryAccount(kEmail); identity_test_env_->SetPrimaryAccount(kEmail);
// It's necessary to invoke this method manually as the observer callback is
// not triggered on ChromeOS.
sync_engine()->OnPrimaryAccountSet(
identity_test_env_->identity_manager()->GetPrimaryAccountInfo());
} }
void SetSyncEnabled(bool enabled) { void SetSyncEnabled(bool enabled) {
...@@ -184,8 +181,11 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) { ...@@ -184,8 +181,11 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) {
// service. Wait for the completion and resume the app. // service. Wait for the completion and resume the app.
WaitUntilIdle(); WaitUntilIdle();
sync_engine()->OnPrimaryAccountCleared( sync_engine()->OnPrimaryAccountChanged(
identity_manager()->GetPrimaryAccountInfo()); PrimaryAccountChangeEvent(PrimaryAccountChangeEvent::State(
identity_manager()->GetPrimaryAccountInfo(),
signin::ConsentLevel::kSync),
PrimaryAccountChangeEvent::State()));
foo_created.Reply("resume"); foo_created.Reply("resume");
ASSERT_TRUE(bar_created.WaitUntilSatisfied()); ASSERT_TRUE(bar_created.WaitUntilSatisfied());
...@@ -198,8 +198,11 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) { ...@@ -198,8 +198,11 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemTest, AuthorizationTest) {
EXPECT_EQ(REMOTE_SERVICE_AUTHENTICATION_REQUIRED, EXPECT_EQ(REMOTE_SERVICE_AUTHENTICATION_REQUIRED,
sync_engine()->GetCurrentState()); sync_engine()->GetCurrentState());
sync_engine()->OnPrimaryAccountSet( sync_engine()->OnPrimaryAccountChanged(
identity_manager()->GetPrimaryAccountInfo()); PrimaryAccountChangeEvent(PrimaryAccountChangeEvent::State(),
PrimaryAccountChangeEvent::State(
identity_manager()->GetPrimaryAccountInfo(),
signin::ConsentLevel::kSync)));
WaitUntilIdle(); WaitUntilIdle();
bar_created.Reply("resume"); bar_created.Reply("resume");
......
...@@ -710,16 +710,20 @@ void SyncEngine::OnConnectionChanged(network::mojom::ConnectionType type) { ...@@ -710,16 +710,20 @@ void SyncEngine::OnConnectionChanged(network::mojom::ConnectionType type) {
} }
} }
void SyncEngine::OnPrimaryAccountSet( void SyncEngine::OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) { const signin::PrimaryAccountChangeEvent& event_details) {
Initialize(); switch (event_details.GetEventTypeFor(signin::ConsentLevel::kSync)) {
} case signin::PrimaryAccountChangeEvent::Type::kSet:
Initialize();
void SyncEngine::OnPrimaryAccountCleared( return;
const CoreAccountInfo& previous_primary_account_info) { case signin::PrimaryAccountChangeEvent::Type::kCleared:
Reset(); Reset();
UpdateServiceState(REMOTE_SERVICE_AUTHENTICATION_REQUIRED, UpdateServiceState(REMOTE_SERVICE_AUTHENTICATION_REQUIRED,
"User signed out."); "User signed out.");
return;
case signin::PrimaryAccountChangeEvent::Type::kNone:
return;
}
} }
SyncEngine::SyncEngine( SyncEngine::SyncEngine(
......
...@@ -145,10 +145,8 @@ class SyncEngine ...@@ -145,10 +145,8 @@ class SyncEngine
void OnConnectionChanged(network::mojom::ConnectionType type) override; void OnConnectionChanged(network::mojom::ConnectionType type) override;
// IdentityManager::Observer overrides. // IdentityManager::Observer overrides.
void OnPrimaryAccountSet( void OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override; const signin::PrimaryAccountChangeEvent& event) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) override;
private: private:
class WorkerObserver; class WorkerObserver;
......
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