Commit bb51168f authored by avi@chromium.org's avatar avi@chromium.org

Remove RenderProcessHost notifications from the signin manager.

BUG=170921
TEST=everything still works

Review URL: https://codereview.chromium.org/126613002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244300 0039d316-1c4b-4281-b951-d872f2087c98
parent 54c5cbc8
......@@ -46,6 +46,7 @@ using namespace signin_internals_util;
using content::BrowserThread;
using content::ChildProcessHost;
using content::RenderProcessHost;
namespace {
......@@ -97,12 +98,10 @@ void SigninManager::SetSigninProcess(int process_id) {
signin_host_id_ != ChildProcessHost::kInvalidUniqueID)
<< "Replacing in-use signin process.";
signin_host_id_ = process_id;
const content::RenderProcessHost* process =
content::RenderProcessHost::FromID(process_id);
DCHECK(process);
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::Source<content::RenderProcessHost>(process));
RenderProcessHost* host = RenderProcessHost::FromID(process_id);
DCHECK(host);
host->AddObserver(this);
signin_hosts_observed_.insert(host);
}
void SigninManager::ClearSigninProcess() {
......@@ -130,6 +129,12 @@ void SigninManager::RemoveMergeSessionObserver(
}
SigninManager::~SigninManager() {
std::set<RenderProcessHost*>::iterator i;
for (i = signin_hosts_observed_.begin();
i != signin_hosts_observed_.end();
++i) {
(*i)->RemoveObserver(this);
}
}
void SigninManager::InitTokenService() {
......@@ -627,22 +632,14 @@ void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) {
OnClientLoginFailure(error);
}
void SigninManager::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, type);
// It's possible we're listening to a "stale" renderer because it was
// replaced with a new process by process-per-site. In either case,
// stop listening to it, but only reset signin_host_id_ tracking
// if this was from the current signin process.
registrar_.Remove(this,
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
source);
if (signin_host_id_ ==
content::Source<content::RenderProcessHost>(source)->GetID()) {
void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) {
// It's possible we're listening to a "stale" renderer because it was replaced
// with a new process by process-per-site. In either case, stop observing it,
// but only reset signin_host_id_ tracking if this was from the current signin
// process.
signin_hosts_observed_.erase(host);
if (signin_host_id_ == host->GetID())
signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
}
}
void SigninManager::ProhibitSignout(bool prohibit_signout) {
......
......@@ -21,6 +21,7 @@
#else
#include <set>
#include <string>
#include "base/compiler_specific.h"
......@@ -35,8 +36,7 @@
#include "chrome/browser/signin/signin_internals_util.h"
#include "chrome/browser/signin/signin_manager_base.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/render_process_host_observer.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/cookies/canonical_cookie.h"
......@@ -51,7 +51,7 @@ class SigninManagerDelegate;
class SigninManager : public SigninManagerBase,
public GaiaAuthConsumer,
public content::NotificationObserver {
public content::RenderProcessHostObserver {
public:
// The callback invoked once the OAuth token has been fetched during signin,
// but before the profile transitions to the "signed-in" state. This allows
......@@ -156,10 +156,9 @@ class SigninManager : public SigninManagerBase,
virtual void OnGetUserInfoFailure(
const GoogleServiceAuthError& error) OVERRIDE;
// content::NotificationObserver
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// content::RenderProcessHostObserver
virtual void RenderProcessHostDestroyed(
content::RenderProcessHost* host) OVERRIDE;
// Tells the SigninManager whether to prohibit signout for this profile.
// If |prohibit_signout| is true, then signout will be prohibited.
......@@ -258,9 +257,6 @@ class SigninManager : public SigninManagerBase,
// Actual client login handler.
scoped_ptr<GaiaAuthFetcher> client_login_;
// Registrar for notifications from the TokenService.
content::NotificationRegistrar registrar_;
// OAuth revocation fetcher for sign outs.
scoped_ptr<GaiaAuthFetcher> revoke_token_fetcher_;
......@@ -283,6 +279,9 @@ class SigninManager : public SigninManagerBase,
// by ID, if there is one.
int signin_host_id_;
// The RenderProcessHosts being observed.
std::set<content::RenderProcessHost*> signin_hosts_observed_;
// Callback invoked during signin after an OAuth token has been fetched
// but before signin is complete.
OAuthTokenFetchedCallback oauth_token_fetched_callback_;
......
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