summaryrefslogtreecommitdiffstats
path: root/chrome/browser/login_prompt.cc
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 07:52:03 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 07:52:03 +0000
commit2d06218ce27bbc8bd9d99135d7272d301e4ea5be (patch)
treeba8ee64a35680ae28b6b8ad4858daf7fcb6235a6 /chrome/browser/login_prompt.cc
parent003922c51c72d11ad6c99b7626b793f3a2d25ab0 (diff)
downloadchromium_src-2d06218ce27bbc8bd9d99135d7272d301e4ea5be.zip
chromium_src-2d06218ce27bbc8bd9d99135d7272d301e4ea5be.tar.gz
chromium_src-2d06218ce27bbc8bd9d99135d7272d301e4ea5be.tar.bz2
Remove atomic operations from login_prompt.cc. Removes an atomic tess and set, and replaces it with a lock. Rename confusing GotAuth test and set method to was WasAuthHandled, which will optionally marked as handled.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/login_prompt.cc')
-rw-r--r--chrome/browser/login_prompt.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/chrome/browser/login_prompt.cc b/chrome/browser/login_prompt.cc
index 650c1cf..987a884 100644
--- a/chrome/browser/login_prompt.cc
+++ b/chrome/browser/login_prompt.cc
@@ -29,8 +29,8 @@
#include "chrome/browser/login_prompt.h"
-#include "base/atomic.h"
#include "base/command_line.h"
+#include "base/lock.h"
#include "base/message_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/constrained_window.h"
@@ -80,7 +80,7 @@ class LoginHandlerImpl : public LoginHandler,
public:
LoginHandlerImpl(URLRequest* request, MessageLoop* ui_loop)
: dialog_(NULL),
- got_auth_(FALSE),
+ handled_auth_(false),
request_(request),
request_loop_(MessageLoop::current()),
ui_loop_(ui_loop),
@@ -144,7 +144,7 @@ class LoginHandlerImpl : public LoginHandler,
// Reference is no longer valid.
dialog_ = NULL;
- if (!GotAuth()) {
+ if (!WasAuthHandled(true)) {
request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &LoginHandlerImpl::CancelAuthDeferred));
SendNotifications();
@@ -172,7 +172,7 @@ class LoginHandlerImpl : public LoginHandler,
// LoginHandler:
virtual void SetAuth(const std::wstring& username,
const std::wstring& password) {
- if (GotAuth())
+ if (WasAuthHandled(true))
return;
// Tell the password manager the credentials were submitted / accepted.
@@ -191,7 +191,7 @@ class LoginHandlerImpl : public LoginHandler,
}
virtual void CancelAuth() {
- if (GotAuth())
+ if (WasAuthHandled(true))
return;
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
@@ -247,9 +247,14 @@ class LoginHandlerImpl : public LoginHandler,
dialog_->CloseConstrainedWindow();
}
- // Atomic test-and-set whether we've gotten (or cancelled) authentication.
- int32 GotAuth() {
- return base::AtomicSwap(&got_auth_, TRUE);
+ // Returns whether authentication had been handled (SetAuth or CancelAuth).
+ // If |set_handled| is true, it will mark authentication as handled.
+ bool WasAuthHandled(bool set_handled) {
+ AutoLock lock(handled_auth_lock_);
+ bool was_handled = handled_auth_;
+ if (set_handled)
+ handled_auth_ = true;
+ return was_handled;
}
// Notify observers that authentication is needed or received. The automation
@@ -263,7 +268,8 @@ class LoginHandlerImpl : public LoginHandler,
return;
NavigationController* controller = requesting_contents->controller();
- if (!got_auth_) {
+
+ if (WasAuthHandled(false)) {
LoginNotificationDetails details(this);
service->Notify(NOTIFY_AUTH_NEEDED,
Source<NavigationController>(controller),
@@ -275,9 +281,9 @@ class LoginHandlerImpl : public LoginHandler,
}
}
- // Whether SetAuth or CancelAuth have been called.
- // Must be aligned on a 32-bit boundary.
- int32 got_auth_;
+ // True if we've handled auth (SetAuth or CancelAuth has been called).
+ bool handled_auth_;
+ Lock handled_auth_lock_;
// The ConstrainedWindow that is hosting our LoginView.
// This should only be accessed on the ui_loop_.