OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // The purprose of SessionManager is to facilitate creation of chromotocol | 5 // The purprose of SessionManager is to facilitate creation of chromotocol |
6 // sessions. Both host and client use it to establish chromotocol | 6 // sessions. Both host and client use it to establish chromotocol |
7 // sessions. JingleChromotocolServer implements this inteface using | 7 // sessions. JingleChromotocolServer implements this inteface using |
8 // libjingle. | 8 // libjingle. |
9 // | 9 // |
10 // OUTGOING SESSIONS | 10 // OUTGOING SESSIONS |
(...skipping 16 matching lines...) Expand all Loading... |
27 // of rejected and failed sessions. | 27 // of rejected and failed sessions. |
28 // | 28 // |
29 // PROTOCOL VERSION NEGOTIATION | 29 // PROTOCOL VERSION NEGOTIATION |
30 // When client connects to a host it sends a session-initiate stanza with list | 30 // When client connects to a host it sends a session-initiate stanza with list |
31 // of supported configurations for each channel. If the host decides to accept | 31 // of supported configurations for each channel. If the host decides to accept |
32 // session, then it selects configuration that is supported by both sides | 32 // session, then it selects configuration that is supported by both sides |
33 // and then replies with the session-accept stanza that contans selected | 33 // and then replies with the session-accept stanza that contans selected |
34 // configuration. The configuration specified in the session-accept is used | 34 // configuration. The configuration specified in the session-accept is used |
35 // for the session. | 35 // for the session. |
36 // | 36 // |
37 // The CandidateChromotocolConfig class represents list of configurations | 37 // The CandidateSessionConfig class represents list of configurations |
38 // supported by an endpoint. The |chromotocol_config| argument in the Connect() | 38 // supported by an endpoint. The |candidate_config| argument in the Connect() |
39 // specifies configuration supported on the client side. When the host receives | 39 // specifies configuration supported on the client side. When the host receives |
40 // session-initiate stanza, the IncomingSessionCallback is called. The | 40 // session-initiate stanza, the IncomingSessionCallback is called. The |
41 // configuration sent in the session-intiate staza is available via | 41 // configuration sent in the session-intiate staza is available via |
42 // ChromotocolConnnection::candidate_config(). If an incoming session is | 42 // ChromotocolConnnection::candidate_config(). If an incoming session is |
43 // being accepted then the IncomingSessionCallback callback function must | 43 // being accepted then the IncomingSessionCallback callback function must |
44 // select session configuration and then set it with Session::set_config(). | 44 // select session configuration and then set it with Session::set_config(). |
45 | 45 |
46 #ifndef REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 46 #ifndef REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
47 #define REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 47 #define REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
48 | 48 |
49 #include <string> | 49 #include <string> |
50 | 50 |
51 #include "base/callback.h" | 51 #include "base/callback.h" |
52 #include "base/ref_counted.h" | 52 #include "base/ref_counted.h" |
53 #include "remoting/protocol/session.h" | 53 #include "remoting/protocol/session.h" |
54 | 54 |
55 class Task; | 55 class Task; |
56 | 56 |
57 namespace remoting { | 57 namespace remoting { |
58 | |
59 namespace protocol { | 58 namespace protocol { |
60 | 59 |
61 // Generic interface for Chromoting session manager. | 60 // Generic interface for Chromoting session manager. |
62 class SessionManager : public base::RefCountedThreadSafe<SessionManager> { | 61 class SessionManager : public base::RefCountedThreadSafe<SessionManager> { |
63 public: | 62 public: |
64 enum IncomingSessionResponse { | 63 enum IncomingSessionResponse { |
65 ACCEPT, | 64 ACCEPT, |
66 INCOMPATIBLE, | 65 INCOMPATIBLE, |
67 DECLINE, | 66 DECLINE, |
68 }; | 67 }; |
69 | 68 |
70 // IncomingSessionCallback is called when a new session is received. If | 69 // IncomingSessionCallback is called when a new session is received. If |
71 // the callback decides to accept the session it should set the second | 70 // the callback decides to accept the session it should set the second |
72 // argument to ACCEPT. Otherwise it should set it to DECLINE, or | 71 // argument to ACCEPT. Otherwise it should set it to DECLINE, or |
73 // INCOMPATIBLE. INCOMPATIBLE indicates that the session has incompatible | 72 // INCOMPATIBLE. INCOMPATIBLE indicates that the session has incompatible |
74 // configuration, and cannot be accepted. | 73 // configuration, and cannot be accepted. |
75 // If the callback accepts session then it must also set configuration | 74 // If the callback accepts session then it must also set configuration |
76 // for the new session using Session::set_config(). | 75 // for the new session using Session::set_config(). |
77 typedef Callback2<Session*, IncomingSessionResponse*>::Type | 76 typedef Callback2<Session*, IncomingSessionResponse*>::Type |
78 IncomingSessionCallback; | 77 IncomingSessionCallback; |
79 | 78 |
80 // Initializes session to the host |jid|. Ownership of the | 79 // Initializes session to the host |jid|. Ownership of the |
81 // |chromotocol_config| is passed to the new session. | 80 // |config| is passed to the new session. |
82 virtual scoped_refptr<Session> Connect( | 81 virtual scoped_refptr<Session> Connect( |
83 const std::string& jid, | 82 const std::string& jid, |
84 CandidateChromotocolConfig* chromotocol_config, | 83 CandidateSessionConfig* config, |
85 Session::StateChangeCallback* state_change_callback) = 0; | 84 Session::StateChangeCallback* state_change_callback) = 0; |
86 | 85 |
87 // Close session manager and all current sessions. |close_task| is executed | 86 // Close session manager and all current sessions. |close_task| is executed |
88 // after the session client is actually closed. No callbacks are called after | 87 // after the session client is actually closed. No callbacks are called after |
89 // |closed_task| is executed. | 88 // |closed_task| is executed. |
90 virtual void Close(Task* closed_task) = 0; | 89 virtual void Close(Task* closed_task) = 0; |
91 | 90 |
92 protected: | 91 protected: |
93 friend class base::RefCountedThreadSafe<SessionManager>; | 92 friend class base::RefCountedThreadSafe<SessionManager>; |
94 | 93 |
95 SessionManager() { } | 94 SessionManager() { } |
96 virtual ~SessionManager() { } | 95 virtual ~SessionManager() { } |
97 | 96 |
98 private: | 97 private: |
99 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 98 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
100 }; | 99 }; |
101 | 100 |
102 } // namespace protocol | 101 } // namespace protocol |
103 | |
104 } // namespace remoting | 102 } // namespace remoting |
105 | 103 |
106 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 104 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
OLD | NEW |