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

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