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