-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure only one IdentityManagerFactory instance gets created
IdentityManagerFactory is a class meant to be instantiated in the browser process via base::Singleton, thus it's not expected to have several instance of them. However, since PR #7480[1] we're actually creating two instances for Brave: the BraveIdentityManagerFactory (subclass) instanced from ProfileSyncServiceFactory as part of a DependsOn() statement, and another one for every other place in the code (68 callpoints at this time) using DependsOn(IdentityManagerFactory::GetInstance()) to initialize different services. This hasn't rang any alarm until Chromium 92.0.4496.3, but in that release some changes were made[2] including the introduction of the IdentityManagerProvider class, which now DCHECKs for having only one instance of IdentityManagerFactory created in the browser: void SetIdentityManagerProvider(const IdentityManagerProvider& provider) { IdentityManagerProvider& instance = GetIdentityManagerProvider(); DCHECK(!instance); instance = provider; } ...meaning that we will get a crash on startup and all the unit and browser tests crashing on DCHECK-enabled builds, revealing this issue that we didn't know we had until now. This patch, makes changes to ensure we have one IdentityManagerFactory instance only, by removing a few parts of the infrastructure added with PR #7480[1] and simply leveraging chromium_src overrides to implement the changes we need for the IdentityManager: to empty implementations of GetAccountsInCookieJar() and GetPrimaryAccountMutator(). [1] #7480 [2] https://chromium-review.googlesource.com/c/chromium/src/+/2824129 Resolves brave/brave-browser#15659
- Loading branch information
Showing
18 changed files
with
43 additions
and
329 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
chromium_src/chrome/browser/signin/identity_manager_factory.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
chromium_src/components/signin/public/identity_manager/identity_manager.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/chromium_src/components/signin/public/identity_manager/identity_manager.h" | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
#define GetAccountsInCookieJar GetAccountsInCookieJar_Unused | ||
#include "../../../../../../components/signin/public/identity_manager/identity_manager.cc" | ||
#undef GetAccountsInCookieJar | ||
|
||
namespace signin { | ||
|
||
AccountsInCookieJarInfo IdentityManager::GetAccountsInCookieJar() const { | ||
// accounts_in_cookie_jar_info.accounts_are_fresh must be false, | ||
// see `ProfileSyncService::OnEngineInitialized` | ||
return AccountsInCookieJarInfo(false, std::vector<gaia::ListedAccount>(), | ||
std::vector<gaia::ListedAccount>()); | ||
} | ||
|
||
} // namespace signin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
chromium_src/components/signin/public/identity_manager/identity_manager_builder.h
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
components/signin/public/identity_manager/brave_identity_manager.cc
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
components/signin/public/identity_manager/brave_identity_manager.h
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.