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

Unified Diff: remoting/host/pam_authorization_factory_posix.cc

Issue 12389010: Refactor of Authenticator to allow it to ProcessMessage asynchronously and then call a callback (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Remove useless include Created 7 years, 10 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 | « no previous file | remoting/protocol/authenticator.h » ('j') | remoting/protocol/authenticator.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/pam_authorization_factory_posix.cc
diff --git a/remoting/host/pam_authorization_factory_posix.cc b/remoting/host/pam_authorization_factory_posix.cc
index 6d1bf588f701aa7fa6adf281560db12083972c9e..f59cb9b853cc76b984e2316ae302ba5c227f2cb2 100644
--- a/remoting/host/pam_authorization_factory_posix.cc
+++ b/remoting/host/pam_authorization_factory_posix.cc
@@ -6,6 +6,8 @@
#include <security/pam_appl.h>
+#include "base/bind.h"
+#include "base/callback.h"
#include "base/environment.h"
#include "base/logging.h"
#include "remoting/protocol/channel_authenticator.h"
@@ -22,7 +24,8 @@ class PamAuthorizer : public protocol::Authenticator {
// protocol::Authenticator interface.
virtual State state() const OVERRIDE;
virtual RejectionReason rejection_reason() const OVERRIDE;
- virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE;
+ virtual void ProcessMessage(const base::Closure& resume_callback,
+ const buzz::XmlElement* message) OVERRIDE;
virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
virtual scoped_ptr<protocol::ChannelAuthenticator>
CreateChannelAuthenticator() const OVERRIDE;
@@ -30,6 +33,7 @@ class PamAuthorizer : public protocol::Authenticator {
private:
void MaybeCheckLocalLogin();
bool IsLocalLoginAllowed();
+ void OnMessageProcessed(const base::Closure& resume_callback);
static int PamConversation(int num_messages,
const struct pam_message** messages,
@@ -66,13 +70,22 @@ PamAuthorizer::rejection_reason() const {
}
}
-void PamAuthorizer::ProcessMessage(const buzz::XmlElement* message) {
- underlying_->ProcessMessage(message);
+void PamAuthorizer::ProcessMessage(const base::Closure& resume_callback,
+ const buzz::XmlElement* message) {
+ // |this| outlives underlying_, so using Unretained is safe here.
+ underlying_->ProcessMessage(
+ base::Bind(&PamAuthorizer::OnMessageProcessed,
+ base::Unretained(this), resume_callback),
+ message);
+}
+
+void PamAuthorizer::OnMessageProcessed(const base::Closure& resume_callback) {
MaybeCheckLocalLogin();
+ resume_callback.Run();
}
scoped_ptr<buzz::XmlElement> PamAuthorizer::GetNextMessage() {
- scoped_ptr<buzz::XmlElement> result (underlying_->GetNextMessage());
+ scoped_ptr<buzz::XmlElement> result(underlying_->GetNextMessage());
MaybeCheckLocalLogin();
return result.Pass();
}
« no previous file with comments | « no previous file | remoting/protocol/authenticator.h » ('j') | remoting/protocol/authenticator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698