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

Side by Side Diff: remoting/protocol/fake_authenticator.h

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « remoting/protocol/datagram_channel_factory.h ('k') | remoting/protocol/fake_authenticator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "remoting/protocol/authenticator.h" 11 #include "remoting/protocol/authenticator.h"
12 #include "remoting/protocol/channel_authenticator.h" 12 #include "remoting/protocol/channel_authenticator.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 namespace protocol { 15 namespace protocol {
16 16
17 class FakeChannelAuthenticator : public ChannelAuthenticator { 17 class FakeChannelAuthenticator : public ChannelAuthenticator {
18 public: 18 public:
19 FakeChannelAuthenticator(bool accept, bool async); 19 FakeChannelAuthenticator(bool accept, bool async);
20 ~FakeChannelAuthenticator() override; 20 ~FakeChannelAuthenticator() override;
21 21
22 // ChannelAuthenticator interface. 22 // ChannelAuthenticator interface.
23 void SecureAndAuthenticate(scoped_ptr<P2PStreamSocket> socket, 23 void SecureAndAuthenticate(std::unique_ptr<P2PStreamSocket> socket,
24 const DoneCallback& done_callback) override; 24 const DoneCallback& done_callback) override;
25 25
26 private: 26 private:
27 void OnAuthBytesWritten(int result); 27 void OnAuthBytesWritten(int result);
28 void OnAuthBytesRead(int result); 28 void OnAuthBytesRead(int result);
29 29
30 void CallDoneCallback(); 30 void CallDoneCallback();
31 31
32 const int result_; 32 const int result_;
33 const bool async_; 33 const bool async_;
34 34
35 scoped_ptr<P2PStreamSocket> socket_; 35 std::unique_ptr<P2PStreamSocket> socket_;
36 DoneCallback done_callback_; 36 DoneCallback done_callback_;
37 37
38 bool did_read_bytes_ = false; 38 bool did_read_bytes_ = false;
39 bool did_write_bytes_ = false; 39 bool did_write_bytes_ = false;
40 40
41 base::WeakPtrFactory<FakeChannelAuthenticator> weak_factory_; 41 base::WeakPtrFactory<FakeChannelAuthenticator> weak_factory_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator); 43 DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator);
44 }; 44 };
45 45
(...skipping 21 matching lines...) Expand all
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 // Authenticator interface. 71 // Authenticator interface.
72 State state() const override; 72 State state() const override;
73 bool started() const override; 73 bool started() const override;
74 RejectionReason rejection_reason() const override; 74 RejectionReason rejection_reason() const override;
75 void ProcessMessage(const buzz::XmlElement* message, 75 void ProcessMessage(const buzz::XmlElement* message,
76 const base::Closure& resume_callback) override; 76 const base::Closure& resume_callback) override;
77 scoped_ptr<buzz::XmlElement> GetNextMessage() override; 77 std::unique_ptr<buzz::XmlElement> GetNextMessage() override;
78 const std::string& GetAuthKey() const override; 78 const std::string& GetAuthKey() const override;
79 scoped_ptr<ChannelAuthenticator> CreateChannelAuthenticator() const override; 79 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator()
80 const override;
80 81
81 protected: 82 protected:
82 const Type type_; 83 const Type type_;
83 const int round_trips_; 84 const int round_trips_;
84 const Action action_; 85 const Action action_;
85 const bool async_; 86 const bool async_;
86 87
87 // Total number of messages that have been processed. 88 // Total number of messages that have been processed.
88 int messages_ = 0; 89 int messages_ = 0;
89 // Number of messages that the authenticator needs to process before started() 90 // Number of messages that the authenticator needs to process before started()
90 // returns true. Default to 0. 91 // returns true. Default to 0.
91 int messages_till_started_ = 0; 92 int messages_till_started_ = 0;
92 93
93 std::string auth_key_; 94 std::string auth_key_;
94 95
95 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); 96 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator);
96 }; 97 };
97 98
98 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { 99 class FakeHostAuthenticatorFactory : public AuthenticatorFactory {
99 public: 100 public:
100 FakeHostAuthenticatorFactory( 101 FakeHostAuthenticatorFactory(
101 int round_trips, int messages_till_start, 102 int round_trips, int messages_till_start,
102 FakeAuthenticator::Action action, bool async); 103 FakeAuthenticator::Action action, bool async);
103 ~FakeHostAuthenticatorFactory() override; 104 ~FakeHostAuthenticatorFactory() override;
104 105
105 // AuthenticatorFactory interface. 106 // AuthenticatorFactory interface.
106 scoped_ptr<Authenticator> CreateAuthenticator( 107 std::unique_ptr<Authenticator> CreateAuthenticator(
107 const std::string& local_jid, 108 const std::string& local_jid,
108 const std::string& remote_jid) override; 109 const std::string& remote_jid) override;
109 110
110 private: 111 private:
111 const int round_trips_; 112 const int round_trips_;
112 const int messages_till_started_; 113 const int messages_till_started_;
113 const FakeAuthenticator::Action action_; 114 const FakeAuthenticator::Action action_;
114 const bool async_; 115 const bool async_;
115 116
116 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); 117 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory);
117 }; 118 };
118 119
119 } // namespace protocol 120 } // namespace protocol
120 } // namespace remoting 121 } // namespace remoting
121 122
122 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ 123 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_
OLDNEW
« no previous file with comments | « remoting/protocol/datagram_channel_factory.h ('k') | remoting/protocol/fake_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698