Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "remoting/protocol/authenticator.h" | 10 #include "remoting/protocol/authenticator.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 HOST, | 51 HOST, |
| 52 CLIENT, | 52 CLIENT, |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 enum Action { | 55 enum Action { |
| 56 ACCEPT, | 56 ACCEPT, |
| 57 REJECT, | 57 REJECT, |
| 58 REJECT_CHANNEL | 58 REJECT_CHANNEL |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 FakeAuthenticator(Type type, int round_trips, int messages_till_started, | |
|
Sergey Ulanov
2014/04/02 19:49:26
It's better to avoid function overloading: http://
| |
| 62 Action action, bool async); | |
| 61 FakeAuthenticator(Type type, int round_trips, Action action, bool async); | 63 FakeAuthenticator(Type type, int round_trips, Action action, bool async); |
| 64 | |
| 62 virtual ~FakeAuthenticator(); | 65 virtual ~FakeAuthenticator(); |
| 63 | 66 |
| 64 // Authenticator interface. | 67 // Authenticator interface. |
| 65 virtual State state() const OVERRIDE; | 68 virtual State state() const OVERRIDE; |
| 69 virtual bool started() const OVERRIDE; | |
| 66 virtual RejectionReason rejection_reason() const OVERRIDE; | 70 virtual RejectionReason rejection_reason() const OVERRIDE; |
| 67 virtual void ProcessMessage(const buzz::XmlElement* message, | 71 virtual void ProcessMessage(const buzz::XmlElement* message, |
| 68 const base::Closure& resume_callback) OVERRIDE; | 72 const base::Closure& resume_callback) OVERRIDE; |
| 69 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; | 73 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; |
| 70 virtual scoped_ptr<ChannelAuthenticator> | 74 virtual scoped_ptr<ChannelAuthenticator> |
| 71 CreateChannelAuthenticator() const OVERRIDE; | 75 CreateChannelAuthenticator() const OVERRIDE; |
| 72 | 76 |
| 73 protected: | 77 protected: |
| 74 Type type_; | 78 Type type_; |
| 75 int round_trips_; | 79 int round_trips_; |
| 76 Action action_; | 80 Action action_; |
| 77 bool async_; | 81 bool async_; |
| 78 | 82 |
| 79 // Total number of messages that have been processed. | 83 // Total number of messages that have been processed. |
| 80 int messages_; | 84 int messages_; |
| 85 // Number of messages that the authenticator needs to process before started() | |
| 86 // returns true. Default to 0 | |
|
Sergey Ulanov
2014/04/02 19:49:26
nit: add '.' at the end of the comment
kelvinp
2014/04/07 18:48:01
Done.
| |
| 87 int messages_till_started_; | |
| 81 | 88 |
| 82 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); | 89 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); |
| 83 }; | 90 }; |
| 84 | 91 |
| 85 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { | 92 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { |
| 86 public: | 93 public: |
| 87 FakeHostAuthenticatorFactory( | 94 FakeHostAuthenticatorFactory( |
| 88 int round_trips, FakeAuthenticator::Action action, bool async); | 95 int round_trips, int messages_till_start, |
| 96 FakeAuthenticator::Action action, bool async); | |
| 89 virtual ~FakeHostAuthenticatorFactory(); | 97 virtual ~FakeHostAuthenticatorFactory(); |
| 90 | 98 |
| 91 // AuthenticatorFactory interface. | 99 // AuthenticatorFactory interface. |
| 92 virtual scoped_ptr<Authenticator> CreateAuthenticator( | 100 virtual scoped_ptr<Authenticator> CreateAuthenticator( |
| 93 const std::string& local_jid, | 101 const std::string& local_jid, |
| 94 const std::string& remote_jid, | 102 const std::string& remote_jid, |
| 95 const buzz::XmlElement* first_message) OVERRIDE; | 103 const buzz::XmlElement* first_message) OVERRIDE; |
| 96 | 104 |
| 97 private: | 105 private: |
| 98 int round_trips_; | 106 int round_trips_; |
| 107 int messages_till_started_; | |
| 99 FakeAuthenticator::Action action_; | 108 FakeAuthenticator::Action action_; |
| 100 bool async_; | 109 bool async_; |
| 101 | 110 |
| 102 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); | 111 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); |
| 103 }; | 112 }; |
| 104 | 113 |
| 105 } // namespace protocol | 114 } // namespace protocol |
| 106 } // namespace remoting | 115 } // namespace remoting |
| 107 | 116 |
| 108 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | 117 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| OLD | NEW |