-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure only one IdentityManagerFactory instance gets created #8731
Conversation
@AlexeyBarabash pointed out to me on Slack today that this is not entirely correct because I am disabling Still we both agree on that having 2 factories around is not a good idea so perhaps we could add one more commit on top of this PR adding some more code (maybe in the chromium_src overrides) so that we decide when to use upstream's implementation of However, while discussing this we realized that extensions like Google Keep are currently broken with similar symptoms to the ones described in brave/brave-browser#3650, meaning that we can't really progress on this PR until that problem is fixed first, so I filed a new issue for it: brave/brave-browser#15754 @iefremov As discussed with @AlexeyBarabash , for now I think I'm going to keep the patch from #8731 applied in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just be components/signin/public/identity_manager/identity_manager.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment on #include. Otherwise, chromium_src
and patches
LGTM.
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
Failures unrelated to this PR, merging... |
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
Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
See Test Plan from #7480