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

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

Issue 1545743002: Move ownership of Transport out of Session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass_client
Patch Set: Created 4 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
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | remoting/protocol/transport.h » ('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_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/macros.h" 10 #include "base/macros.h"
11 #include "remoting/protocol/errors.h" 11 #include "remoting/protocol/errors.h"
12 #include "remoting/protocol/session_config.h" 12 #include "remoting/protocol/session_config.h"
13 #include "remoting/protocol/transport.h"
14
15 namespace buzz {
16 class XmlElement;
17 } // namespace buzz
13 18
14 namespace remoting { 19 namespace remoting {
15 namespace protocol { 20 namespace protocol {
16 21
22 class Authenicator;
17 class StreamChannelFactory; 23 class StreamChannelFactory;
18 class Transport; 24 class Transport;
19 struct TransportRoute; 25 struct TransportRoute;
20 26
21 // Generic interface for Chromotocol connection used by both client and host. 27 // Session is responsible for initializing and authenticating both incoming and
22 // Provides access to the connection channels, but doesn't depend on the 28 // outgoing connections. It uses TransportInfoSink interface to pass
23 // protocol used for each channel. 29 // transport-info messages to the transport.
24 class Session { 30 class Session {
25 public: 31 public:
26 enum State { 32 enum State {
27 // Created, but not connecting yet. 33 // Created, but not connecting yet.
28 INITIALIZING, 34 INITIALIZING,
29 35
30 // Sent session-initiate, but haven't received session-accept. 36 // Sent session-initiate, but haven't received session-accept.
31 CONNECTING, 37 CONNECTING,
32 38
33 // Received session-initiate, but haven't sent session-accept. 39 // Received session-initiate, but haven't sent session-accept.
34 ACCEPTING, 40 ACCEPTING,
35 41
36 // Session has been accepted and is pending authentication. 42 // Session has been accepted and is pending authentication.
37 ACCEPTED, 43 ACCEPTED,
38 44
39 // Session has started authenticating. 45 // Session has started authenticating.
40 AUTHENTICATING, 46 AUTHENTICATING,
41 47
42 // Session has been connected and authenticated. 48 // Session has been connected and authenticated.
43 AUTHENTICATED, 49 AUTHENTICATED,
44 50
45 // Session has been connected.
46 CONNECTED,
47
48 // Session has been closed. 51 // Session has been closed.
49 CLOSED, 52 CLOSED,
50 53
51 // Connection has failed. 54 // Connection has failed.
52 FAILED, 55 FAILED,
53 }; 56 };
54 57
55 class EventHandler { 58 class EventHandler {
56 public: 59 public:
57 EventHandler() {} 60 EventHandler() {}
58 virtual ~EventHandler() {} 61 virtual ~EventHandler() {}
59 62
60 // Called after session state has changed. It is safe to destroy 63 // Called after session state has changed. It is safe to destroy
61 // the session from within the handler if |state| is AUTHENTICATING 64 // the session from within the handler if |state| is AUTHENTICATING
62 // or CLOSED or FAILED. 65 // or CLOSED or FAILED.
63 virtual void OnSessionStateChange(State state) = 0; 66 virtual void OnSessionStateChange(State state) = 0;
64
65 // Called whenever route for the channel specified with
66 // |channel_name| changes. Session must not be destroyed by the
67 // handler of this event.
68 virtual void OnSessionRouteChange(const std::string& channel_name,
69 const TransportRoute& route) = 0;
70 }; 67 };
71 68
72 Session() {} 69 Session() {}
73 virtual ~Session() {} 70 virtual ~Session() {}
74 71
75 // Set event handler for this session. |event_handler| must outlive 72 // Set event handler for this session. |event_handler| must outlive
76 // this object. 73 // this object.
77 virtual void SetEventHandler(EventHandler* event_handler) = 0; 74 virtual void SetEventHandler(EventHandler* event_handler) = 0;
78 75
79 // Returns error code for a failed session. 76 // Returns error code for a failed session.
80 virtual ErrorCode error() = 0; 77 virtual ErrorCode error() = 0;
81 78
82 // JID of the other side. 79 // JID of the other side.
83 virtual const std::string& jid() = 0; 80 virtual const std::string& jid() = 0;
84 81
85 // Protocol configuration. Can be called only after session has been accepted. 82 // Protocol configuration. Can be called only after session has been accepted.
86 // Returned pointer is valid until connection is closed. 83 // Returned pointer is valid until connection is closed.
87 virtual const SessionConfig& config() = 0; 84 virtual const SessionConfig& config() = 0;
88 85
89 // Returns Transport that can be used to create transport channels. 86 // Sets Transport to be used by the session. Must be called before the
90 virtual Transport* GetTransport() = 0; 87 // session becomes AUTHENTICATED. The transport must outlive the session.
88 virtual void SetTransport(Transport* transport) = 0;
91 89
92 // Closes connection. Callbacks are guaranteed not to be called after this 90 // Closes connection. EventHandler is guaranteed not to be called after this
93 // method returns. |error| specifies the error code in case when the session 91 // method returns. |error| specifies the error code in case when the session
94 // is being closed due to an error. 92 // is being closed due to an error.
95 virtual void Close(ErrorCode error) = 0; 93 virtual void Close(ErrorCode error) = 0;
96 94
97 private: 95 private:
98 DISALLOW_COPY_AND_ASSIGN(Session); 96 DISALLOW_COPY_AND_ASSIGN(Session);
99 }; 97 };
100 98
101 } // namespace protocol 99 } // namespace protocol
102 } // namespace remoting 100 } // namespace remoting
103 101
104 #endif // REMOTING_PROTOCOL_SESSION_H_ 102 #endif // REMOTING_PROTOCOL_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protocol_mock_objects.h ('k') | remoting/protocol/transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698