Commit 5ac97254 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

Move observing logic to Init/Shutdown in ChildAccountService

ChildAccountService listens to GaiaCookieManagerService for
notifications about signed in/out accounts. The code was starting to
observe in the constructor and stopping in the destructor. That is not
totally correct as services should start observing in Init() and stop
on Shutdown(). Moved the AddObserver/RemoveObserver calls to their
proper locations.

Bug: 921007
Change-Id: I6a0afef6845ab59c2f7bf4994cb8a9c90b8ef034
Reviewed-on: https://chromium-review.googlesource.com/c/1454500Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Sergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#629596}
parent 77d631e9
...@@ -77,11 +77,9 @@ ChildAccountService::ChildAccountService(Profile* profile) ...@@ -77,11 +77,9 @@ ChildAccountService::ChildAccountService(Profile* profile)
gaia_cookie_manager_( gaia_cookie_manager_(
GaiaCookieManagerServiceFactory::GetForProfile(profile)), GaiaCookieManagerServiceFactory::GetForProfile(profile)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
gaia_cookie_manager_->AddObserver(this);
} }
ChildAccountService::~ChildAccountService() { ChildAccountService::~ChildAccountService() {
gaia_cookie_manager_->RemoveObserver(this);
} }
// static // static
...@@ -102,6 +100,7 @@ void ChildAccountService::RegisterProfilePrefs( ...@@ -102,6 +100,7 @@ void ChildAccountService::RegisterProfilePrefs(
void ChildAccountService::Init() { void ChildAccountService::Init() {
SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(this); SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(this);
gaia_cookie_manager_->AddObserver(this);
IdentityManagerFactory::GetForProfile(profile_)->AddObserver(this); IdentityManagerFactory::GetForProfile(profile_)->AddObserver(this);
PropagateChildStatusToUser(profile_->IsChild()); PropagateChildStatusToUser(profile_->IsChild());
...@@ -121,6 +120,7 @@ bool ChildAccountService::IsChildAccountStatusKnown() { ...@@ -121,6 +120,7 @@ bool ChildAccountService::IsChildAccountStatusKnown() {
void ChildAccountService::Shutdown() { void ChildAccountService::Shutdown() {
family_fetcher_.reset(); family_fetcher_.reset();
IdentityManagerFactory::GetForProfile(profile_)->RemoveObserver(this); IdentityManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
gaia_cookie_manager_->RemoveObserver(this);
SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(nullptr); SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(nullptr);
DCHECK(!active_); DCHECK(!active_);
} }
......
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