Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: chrome/browser/ui/login/login_prompt.cc

Issue 10067033: RefCounted types should not have public destructors, chrome/browser/ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fix Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/login/login_prompt.h ('k') | chrome/browser/ui/login/login_prompt_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/login/login_prompt.cc
diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc
index 74400df148442edbda55e4dc5894a691b35d3ef8..1b1cf95224f9acdcbd659515809e338208d3b1e2 100644
--- a/chrome/browser/ui/login/login_prompt.cc
+++ b/chrome/browser/ui/login/login_prompt.cc
@@ -105,8 +105,15 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
}
}
-LoginHandler::~LoginHandler() {
- SetModel(NULL);
+void LoginHandler::OnRequestCancelled() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
+ "Why is OnRequestCancelled called from the UI thread?";
+
+ // Reference is no longer valid.
+ request_ = NULL;
+
+ // Give up on auth if the request was cancelled.
+ CancelAuth();
}
void LoginHandler::SetPasswordForm(const webkit::forms::PasswordForm& form) {
@@ -184,34 +191,6 @@ void LoginHandler::CancelAuth() {
base::Bind(&LoginHandler::CancelAuthDeferred, this));
}
-void LoginHandler::OnRequestCancelled() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
- "Why is OnRequestCancelled called from the UI thread?";
-
- // Reference is no longer valid.
- request_ = NULL;
-
- // Give up on auth if the request was cancelled.
- CancelAuth();
-}
-
-void LoginHandler::AddObservers() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // This is probably OK; we need to listen to everything and we break out of
- // the Observe() if we aren't handling the same auth_info().
- registrar_.reset(new content::NotificationRegistrar);
- registrar_->Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED,
- content::NotificationService::AllBrowserContextsAndSources());
- registrar_->Add(this, chrome::NOTIFICATION_AUTH_CANCELLED,
- content::NotificationService::AllBrowserContextsAndSources());
-}
-
-void LoginHandler::RemoveObservers() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- registrar_.reset();
-}
void LoginHandler::Observe(int type,
const content::NotificationSource& source,
@@ -255,6 +234,17 @@ void LoginHandler::Observe(int type,
}
}
+// Returns whether authentication had been handled (SetAuth or CancelAuth).
+bool LoginHandler::WasAuthHandled() const {
+ base::AutoLock lock(handled_auth_lock_);
+ bool was_handled = handled_auth_;
+ return was_handled;
+}
+
+LoginHandler::~LoginHandler() {
+ SetModel(NULL);
+}
+
void LoginHandler::SetModel(LoginModel* model) {
if (login_model_)
login_model_->SetObserver(NULL);
@@ -287,23 +277,40 @@ void LoginHandler::NotifyAuthNeeded() {
content::Details<LoginNotificationDetails>(&details));
}
-void LoginHandler::NotifyAuthCancelled() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(WasAuthHandled());
+void LoginHandler::ReleaseSoon() {
+ if (!TestAndSetAuthHandled()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&LoginHandler::CancelAuthDeferred, this));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&LoginHandler::NotifyAuthCancelled, this));
+ }
- content::NotificationService* service =
- content::NotificationService::current();
- NavigationController* controller = NULL;
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&LoginHandler::RemoveObservers, this));
- WebContents* requesting_contents = GetWebContentsForLogin();
- if (requesting_contents)
- controller = &requesting_contents->GetController();
+ // Delete this object once all InvokeLaters have been called.
+ BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, this);
+}
- LoginNotificationDetails details(this);
+void LoginHandler::AddObservers() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- service->Notify(chrome::NOTIFICATION_AUTH_CANCELLED,
- content::Source<NavigationController>(controller),
- content::Details<LoginNotificationDetails>(&details));
+ // This is probably OK; we need to listen to everything and we break out of
+ // the Observe() if we aren't handling the same auth_info().
+ registrar_.reset(new content::NotificationRegistrar);
+ registrar_->Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ registrar_->Add(this, chrome::NOTIFICATION_AUTH_CANCELLED,
+ content::NotificationService::AllBrowserContextsAndSources());
+}
+
+void LoginHandler::RemoveObservers() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ registrar_.reset();
}
void LoginHandler::NotifyAuthSupplied(const string16& username,
@@ -327,29 +334,23 @@ void LoginHandler::NotifyAuthSupplied(const string16& username,
content::Details<AuthSuppliedLoginNotificationDetails>(&details));
}
-void LoginHandler::ReleaseSoon() {
- if (!TestAndSetAuthHandled()) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&LoginHandler::CancelAuthDeferred, this));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&LoginHandler::NotifyAuthCancelled, this));
- }
+void LoginHandler::NotifyAuthCancelled() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(WasAuthHandled());
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&LoginHandler::RemoveObservers, this));
+ content::NotificationService* service =
+ content::NotificationService::current();
+ NavigationController* controller = NULL;
- // Delete this object once all InvokeLaters have been called.
- BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, this);
-}
+ WebContents* requesting_contents = GetWebContentsForLogin();
+ if (requesting_contents)
+ controller = &requesting_contents->GetController();
-// Returns whether authentication had been handled (SetAuth or CancelAuth).
-bool LoginHandler::WasAuthHandled() const {
- base::AutoLock lock(handled_auth_lock_);
- bool was_handled = handled_auth_;
- return was_handled;
+ LoginNotificationDetails details(this);
+
+ service->Notify(chrome::NOTIFICATION_AUTH_CANCELLED,
+ content::Source<NavigationController>(controller),
+ content::Details<LoginNotificationDetails>(&details));
}
// Marks authentication as handled and returns the previous handled state.
« no previous file with comments | « chrome/browser/ui/login/login_prompt.h ('k') | chrome/browser/ui/login/login_prompt_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698