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

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

Issue 8774017: Add AUTHENTICATED session state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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
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_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_SESSION_H_
6 #define REMOTING_PROTOCOL_SESSION_H_ 6 #define REMOTING_PROTOCOL_SESSION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 17 matching lines...) Expand all
28 // while it is being invoked all Session instances must be deleted 28 // while it is being invoked all Session instances must be deleted
29 // with a clean stack, i.e. not from event handlers, when sigslot may 29 // with a clean stack, i.e. not from event handlers, when sigslot may
30 // be present in the stack. 30 // be present in the stack.
31 class Session : public base::NonThreadSafe { 31 class Session : public base::NonThreadSafe {
32 public: 32 public:
33 enum State { 33 enum State {
34 // Created, but not connecting yet. 34 // Created, but not connecting yet.
35 INITIALIZING, 35 INITIALIZING,
36 36
37 // Sent or received session-initiate, but haven't sent or received 37 // Sent or received session-initiate, but haven't sent or received
38 // session-accept. 38 // session-accept.
Wez 2011/12/03 00:10:37 Combining this description with those of CONNECTED
Sergey Ulanov 2011/12/06 02:33:20 I think we do need to distinguish between CONNECTE
39 CONNECTING, 39 CONNECTING,
40 40
41 // Session has been accepted. 41 // Session has been accepted, but authentication is not finished yet.
Wez 2011/12/03 00:10:37 nit: "... and is pending authentication."
Sergey Ulanov 2011/12/06 02:33:20 Done.
42 CONNECTED, 42 CONNECTED,
43 43
44 // Session has been connected and authenticated.
45 AUTHENTICATED,
46
44 // Session has been closed. 47 // Session has been closed.
45 CLOSED, 48 CLOSED,
46 49
47 // Connection has failed. 50 // Connection has failed.
48 FAILED, 51 FAILED,
49 }; 52 };
50 53
51 // TODO(sergeyu): Move error codes to a separate file. 54 // TODO(sergeyu): Move error codes to a separate file.
52 enum Error { 55 enum Error {
53 OK = 0, 56 OK = 0,
54 PEER_IS_OFFLINE, 57 PEER_IS_OFFLINE,
55 SESSION_REJECTED, 58 SESSION_REJECTED,
56 INCOMPATIBLE_PROTOCOL, 59 INCOMPATIBLE_PROTOCOL,
57 AUTHENTICATION_FAILED, 60 AUTHENTICATION_FAILED,
58 CHANNEL_CONNECTION_ERROR, 61 CHANNEL_CONNECTION_ERROR,
59 }; 62 };
60 63
61 typedef base::Callback<void(State)> StateChangeCallback; 64 // State change callbacks are called after session state has
65 // changed. Handlers can destroy session only when |state| is set to
66 // CLOSED or FAILED.
Wez 2011/12/03 00:10:37 nit: "It is not safe to destroy the session from w
Sergey Ulanov 2011/12/06 02:33:20 Done.
67 typedef base::Callback<void(State state)> StateChangeCallback;
62 68
63 // TODO(sergeyu): Specify connection error code when channel 69 // TODO(sergeyu): Specify connection error code when channel
64 // connection fails. 70 // connection fails.
65 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; 71 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback;
66 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; 72 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback;
67 73
68 Session() { } 74 Session() { }
69 virtual ~Session() { } 75 virtual ~Session() { }
70 76
71 // Set callback that is called when state of the connection is changed. 77 // Set callback that is called when state of the connection is changed.
72 // Must be called on the jingle thread only. 78 // Must be called on the jingle thread only.
73 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; 79 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0;
74 80
75 // Returns error code for a failed session. 81 // Returns error code for a failed session.
76 virtual Error error() = 0; 82 virtual Error error() = 0;
77 83
78 // Creates new channels for this connection. The specified callback 84 // Creates new channels for this connection. The specified callback
79 // is called when then new channel is created and connected. The 85 // is called when then new channel is created and connected. The
80 // callback is called with NULL if connection failed for any reason. 86 // callback is called with NULL if connection failed for any reason.
81 // Ownership of the channel socket is given to the caller when the 87 // Ownership of the channel socket is given to the caller when the
82 // callback is called. All channels must be destroyed before the 88 // callback is called. All channels must be destroyed before the
83 // session is destroyed. Can be called only when in CONNECTING or 89 // session is destroyed. Can be called only when in CONNECTING,
84 // CONNECTED state. 90 // CONNECTED or AUTHENTICATED states.
85 virtual void CreateStreamChannel( 91 virtual void CreateStreamChannel(
86 const std::string& name, const StreamChannelCallback& callback) = 0; 92 const std::string& name, const StreamChannelCallback& callback) = 0;
87 virtual void CreateDatagramChannel( 93 virtual void CreateDatagramChannel(
88 const std::string& name, const DatagramChannelCallback& callback) = 0; 94 const std::string& name, const DatagramChannelCallback& callback) = 0;
89 95
90 // Cancels a pending CreateStreamChannel() or CreateDatagramChannel() 96 // Cancels a pending CreateStreamChannel() or CreateDatagramChannel()
91 // operation for the named channel. If the channel creation already 97 // operation for the named channel. If the channel creation already
92 // completed then cancelling it has no effect. When shutting down 98 // completed then cancelling it has no effect. When shutting down
93 // this method must be called for each channel pending creation. 99 // this method must be called for each channel pending creation.
94 virtual void CancelChannelCreation(const std::string& name) = 0; 100 virtual void CancelChannelCreation(const std::string& name) = 0;
(...skipping 21 matching lines...) Expand all
116 virtual void Close() = 0; 122 virtual void Close() = 0;
117 123
118 private: 124 private:
119 DISALLOW_COPY_AND_ASSIGN(Session); 125 DISALLOW_COPY_AND_ASSIGN(Session);
120 }; 126 };
121 127
122 } // namespace protocol 128 } // namespace protocol
123 } // namespace remoting 129 } // namespace remoting
124 130
125 #endif // REMOTING_PROTOCOL_SESSION_H_ 131 #endif // REMOTING_PROTOCOL_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698