Index: remoting/protocol/channel_authenticator.h |
diff --git a/remoting/protocol/channel_authenticator.h b/remoting/protocol/channel_authenticator.h |
index a95fd3d543ad4e78b0e054e49bcd94c60b0e86a1..3382151bccd0ecf6b3380f09c8c4ca6747b5bef9 100644 |
--- a/remoting/protocol/channel_authenticator.h |
+++ b/remoting/protocol/channel_authenticator.h |
@@ -8,14 +8,11 @@ |
#include <string> |
#include "base/callback.h" |
-#include "base/memory/ref_counted.h" |
#include "base/threading/non_thread_safe.h" |
-#include "net/base/completion_callback.h" |
+#include "net/base/net_errors.h" |
namespace net { |
-class DrainableIOBuffer; |
-class GrowableIOBuffer; |
-class SSLSocket; |
+class StreamSocket; |
} // namespace net |
namespace remoting { |
@@ -23,80 +20,22 @@ namespace protocol { |
class ChannelAuthenticator : public base::NonThreadSafe { |
Wez
2011/11/22 22:29:48
Should this interface really derive from NonThread
Wez
2011/11/22 22:29:48
Give a short description of what this interface is
Sergey Ulanov
2011/11/23 01:23:42
Done.
Sergey Ulanov
2011/11/23 01:23:42
Done.
|
public: |
- enum Result { |
- SUCCESS, |
- FAILURE, |
- }; |
+ typedef base::Callback<void(net::Error error, net::StreamSocket*)> |
+ DoneCallback; |
- typedef base::Callback<void(Result)> DoneCallback; |
+ ChannelAuthenticator() {} |
Wez
2011/11/22 22:29:48
Make this protected, since it doesn't make sense t
Sergey Ulanov
2011/11/23 01:23:42
Just removed this constructor.
|
+ virtual ~ChannelAuthenticator() {} |
- ChannelAuthenticator() { } |
- virtual ~ChannelAuthenticator() { } |
- |
- // Starts authentication of the |socket|. |done_callback| is called |
- // when authentication is finished. Caller retains ownership of |
- // |socket|. |shared_secret| is a shared secret that we use to |
- // authenticate the channel. |
- virtual void Authenticate(net::SSLSocket* socket, |
- const DoneCallback& done_callback) = 0; |
+ // Starts SSL on the |socket| and authenticates it. Takes ownership |
Wez
2011/11/22 22:29:48
Indicate that the caller must not attempt to use |
Sergey Ulanov
2011/11/23 01:23:42
Done.
|
+ // of |socket|. |done_callback| is called when authentication is |
Wez
2011/11/22 22:29:48
Is this always the case? Surely whether SSL is st
Sergey Ulanov
2011/11/23 01:23:42
Done.
|
+ // finished. Callback handler must take ownership of the result. |
Wez
2011/11/22 22:29:48
Indicate that the callback may be invoked before S
Sergey Ulanov
2011/11/23 01:23:42
Done.
|
+ virtual void SecureAndAuthenticate( |
+ net::StreamSocket* socket, const DoneCallback& done_callback) = 0; |
private: |
DISALLOW_COPY_AND_ASSIGN(ChannelAuthenticator); |
}; |
-class HostChannelAuthenticator : public ChannelAuthenticator { |
- public: |
- HostChannelAuthenticator(const std::string& shared_secret); |
- virtual ~HostChannelAuthenticator(); |
- |
- // ChannelAuthenticator overrides. |
- virtual void Authenticate(net::SSLSocket* socket, |
- const DoneCallback& done_callback) OVERRIDE; |
- |
- private: |
- void DoAuthRead(); |
- void OnAuthBytesRead(int result); |
- bool HandleAuthBytesRead(int result); |
- bool VerifyAuthBytes(const std::string& received_auth_bytes); |
- |
- std::string shared_secret_; |
- std::string auth_bytes_; |
- net::SSLSocket* socket_; |
- DoneCallback done_callback_; |
- |
- scoped_refptr<net::GrowableIOBuffer> auth_read_buf_; |
- |
- net::OldCompletionCallbackImpl<HostChannelAuthenticator> auth_read_callback_; |
- |
- DISALLOW_COPY_AND_ASSIGN(HostChannelAuthenticator); |
-}; |
- |
-class ClientChannelAuthenticator : public ChannelAuthenticator { |
- public: |
- ClientChannelAuthenticator(const std::string& shared_secret); |
- virtual ~ClientChannelAuthenticator(); |
- |
- // ChannelAuthenticator overrides. |
- virtual void Authenticate(net::SSLSocket* socket, |
- const DoneCallback& done_callback); |
- |
- private: |
- void DoAuthWrite(); |
- void OnAuthBytesWritten(int result); |
- bool HandleAuthBytesWritten(int result); |
- |
- std::string shared_secret_; |
- net::SSLSocket* socket_; |
- DoneCallback done_callback_; |
- |
- scoped_refptr<net::DrainableIOBuffer> auth_write_buf_; |
- |
- net::OldCompletionCallbackImpl<ClientChannelAuthenticator> |
- auth_write_callback_; |
- |
- DISALLOW_COPY_AND_ASSIGN(ClientChannelAuthenticator); |
-}; |
- |
} // namespace protocol |
} // namespace remoting |