| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ~FakeAuthenticator() override; | 61 ~FakeAuthenticator() override; |
| 62 | 62 |
| 63 // Set the number of messages that the authenticator needs to process before | 63 // Set the number of messages that the authenticator needs to process before |
| 64 // started() returns true. Default to 0. | 64 // started() returns true. Default to 0. |
| 65 void set_messages_till_started(int messages); | 65 void set_messages_till_started(int messages); |
| 66 | 66 |
| 67 // Sets auth key to be returned by GetAuthKey(). Must be called when | 67 // Sets auth key to be returned by GetAuthKey(). Must be called when |
| 68 // |round_trips| is set to 0. | 68 // |round_trips| is set to 0. |
| 69 void set_auth_key(const std::string& auth_key) { auth_key_ = auth_key; } | 69 void set_auth_key(const std::string& auth_key) { auth_key_ = auth_key; } |
| 70 | 70 |
| 71 // When pause_message_index is set the authenticator will pause in |
| 72 // PROCESSING_MESSAGE state after that message, until |
| 73 // TakeResumeClosure().Run() is called. |
| 74 void set_pause_message_index(int pause_message_index) { |
| 75 pause_message_index_ = pause_message_index; |
| 76 } |
| 77 void Resume(); |
| 78 |
| 71 // Authenticator interface. | 79 // Authenticator interface. |
| 72 State state() const override; | 80 State state() const override; |
| 73 bool started() const override; | 81 bool started() const override; |
| 74 RejectionReason rejection_reason() const override; | 82 RejectionReason rejection_reason() const override; |
| 75 void ProcessMessage(const buzz::XmlElement* message, | 83 void ProcessMessage(const buzz::XmlElement* message, |
| 76 const base::Closure& resume_callback) override; | 84 const base::Closure& resume_callback) override; |
| 77 std::unique_ptr<buzz::XmlElement> GetNextMessage() override; | 85 std::unique_ptr<buzz::XmlElement> GetNextMessage() override; |
| 78 const std::string& GetAuthKey() const override; | 86 const std::string& GetAuthKey() const override; |
| 79 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator() | 87 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator() |
| 80 const override; | 88 const override; |
| 81 | 89 |
| 82 protected: | 90 protected: |
| 83 const Type type_; | 91 const Type type_; |
| 84 const int round_trips_; | 92 const int round_trips_; |
| 85 const Action action_; | 93 const Action action_; |
| 86 const bool async_; | 94 const bool async_; |
| 87 | 95 |
| 88 // Total number of messages that have been processed. | 96 // Total number of messages that have been processed. |
| 89 int messages_ = 0; | 97 int messages_ = 0; |
| 90 // Number of messages that the authenticator needs to process before started() | 98 // Number of messages that the authenticator needs to process before started() |
| 91 // returns true. Default to 0. | 99 // returns true. Default to 0. |
| 92 int messages_till_started_ = 0; | 100 int messages_till_started_ = 0; |
| 93 | 101 |
| 102 int pause_message_index_ = -1; |
| 103 base::Closure resume_closure_; |
| 104 |
| 94 std::string auth_key_; | 105 std::string auth_key_; |
| 95 | 106 |
| 96 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); | 107 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); |
| 97 }; | 108 }; |
| 98 | 109 |
| 99 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { | 110 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { |
| 100 public: | 111 public: |
| 101 FakeHostAuthenticatorFactory( | 112 FakeHostAuthenticatorFactory( |
| 102 int round_trips, int messages_till_start, | 113 int round_trips, int messages_till_start, |
| 103 FakeAuthenticator::Action action, bool async); | 114 FakeAuthenticator::Action action, bool async); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 114 const FakeAuthenticator::Action action_; | 125 const FakeAuthenticator::Action action_; |
| 115 const bool async_; | 126 const bool async_; |
| 116 | 127 |
| 117 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); | 128 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); |
| 118 }; | 129 }; |
| 119 | 130 |
| 120 } // namespace protocol | 131 } // namespace protocol |
| 121 } // namespace remoting | 132 } // namespace remoting |
| 122 | 133 |
| 123 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ | 134 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| OLD | NEW |