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

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

Issue 9240033: Use scoped_ptr<>.Pass() to pass ownership in the remoting protocol code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/protocol/authenticator.cc » ('j') | remoting/protocol/jingle_session.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_AUTHENTICATOR_H_ 5 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_AUTHENTICATOR_H_ 6 #define REMOTING_PROTOCOL_AUTHENTICATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h"
11
10 namespace buzz { 12 namespace buzz {
11 class XmlElement; 13 class XmlElement;
12 } // namespace buzz 14 } // namespace buzz
13 15
14 namespace remoting { 16 namespace remoting {
15 namespace protocol { 17 namespace protocol {
16 18
17 class ChannelAuthenticator; 19 class ChannelAuthenticator;
18 20
19 // Authenticator is an abstract interface for authentication protocol 21 // Authenticator is an abstract interface for authentication protocol
(...skipping 30 matching lines...) Expand all
50 ACCEPTED, 52 ACCEPTED,
51 53
52 // Session is rejected. 54 // Session is rejected.
53 REJECTED, 55 REJECTED,
54 }; 56 };
55 57
56 // Returns true if |message| is an Authenticator message. 58 // Returns true if |message| is an Authenticator message.
57 static bool IsAuthenticatorMessage(const buzz::XmlElement* message); 59 static bool IsAuthenticatorMessage(const buzz::XmlElement* message);
58 60
59 // Creates an empty Authenticator message, owned by the caller. 61 // Creates an empty Authenticator message, owned by the caller.
60 static buzz::XmlElement* CreateEmptyAuthenticatorMessage(); 62 static scoped_ptr<buzz::XmlElement> CreateEmptyAuthenticatorMessage();
61 63
62 // Finds Authenticator message among child elements of |message|, or 64 // Finds Authenticator message among child elements of |message|, or
63 // returns NULL otherwise. 65 // returns NULL otherwise.
64 static const buzz::XmlElement* FindAuthenticatorMessage( 66 static const buzz::XmlElement* FindAuthenticatorMessage(
65 const buzz::XmlElement* message); 67 const buzz::XmlElement* message);
66 68
67 Authenticator() {} 69 Authenticator() {}
68 virtual ~Authenticator() {} 70 virtual ~Authenticator() {}
69 71
70 // Returns current state of the authenticator. 72 // Returns current state of the authenticator.
71 virtual State state() const = 0; 73 virtual State state() const = 0;
72 74
73 // Called in response to incoming message received from the peer. 75 // Called in response to incoming message received from the peer.
74 // Should only be called when in WAITING_MESSAGE state. Caller 76 // Should only be called when in WAITING_MESSAGE state. Caller
75 // retains ownership of |message|. 77 // retains ownership of |message|.
76 virtual void ProcessMessage(const buzz::XmlElement* message) = 0; 78 virtual void ProcessMessage(const buzz::XmlElement* message) = 0;
77 79
78 // Must be called when in MESSAGE_READY state. Returns next 80 // Must be called when in MESSAGE_READY state. Returns next
79 // authentication message that needs to be sent to the peer. 81 // authentication message that needs to be sent to the peer.
80 virtual buzz::XmlElement* GetNextMessage() = 0; 82 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() = 0;
81 83
82 // Creates new authenticator for a channel. Caller must take 84 // Creates new authenticator for a channel. Can be called only in
83 // ownership of the result. Can be called only in the ACCEPTED 85 // the ACCEPTED state.
84 // state. 86 virtual scoped_ptr<ChannelAuthenticator>
85 virtual ChannelAuthenticator* CreateChannelAuthenticator() const = 0; 87 CreateChannelAuthenticator() const = 0;
86 }; 88 };
87 89
88 // Factory for Authenticator instances. 90 // Factory for Authenticator instances.
89 class AuthenticatorFactory { 91 class AuthenticatorFactory {
90 public: 92 public:
91 AuthenticatorFactory() {} 93 AuthenticatorFactory() {}
92 virtual ~AuthenticatorFactory() {} 94 virtual ~AuthenticatorFactory() {}
93 95
94 // Called when session-initiate stanza is received to create 96 // Called when session-initiate stanza is received to create
95 // authenticator for the new session. |first_message| specifies 97 // authenticator for the new session. |first_message| specifies
96 // authentication part of the session-initiate stanza so that 98 // authentication part of the session-initiate stanza so that
97 // appropriate type of Authenticator can be chosen for the session 99 // appropriate type of Authenticator can be chosen for the session
98 // (useful when multiple authenticators is supported). Returns NULL 100 // (useful when multiple authenticators is supported). Returns NULL
99 // if the |first_message| is invalid and the session should be 101 // if the |first_message| is invalid and the session should be
100 // rejected. ProcessMessage() should be called with |first_message| 102 // rejected. ProcessMessage() should be called with |first_message|
101 // for the result of this method. 103 // for the result of this method.
102 virtual Authenticator* CreateAuthenticator( 104 virtual scoped_ptr<Authenticator> CreateAuthenticator(
103 const std::string& remote_jid, 105 const std::string& remote_jid,
104 const buzz::XmlElement* first_message) = 0; 106 const buzz::XmlElement* first_message) = 0;
105 }; 107 };
106 108
107 } // namespace protocol 109 } // namespace protocol
108 } // namespace remoting 110 } // namespace remoting
109 111
110 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ 112 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/authenticator.cc » ('j') | remoting/protocol/jingle_session.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698