| OLD | NEW |
| 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_JINGLE_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "crypto/rsa_private_key.h" | 16 #include "crypto/rsa_private_key.h" |
| 17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 18 #include "remoting/protocol/authenticator.h" | 18 #include "remoting/protocol/authenticator.h" |
| 19 #include "remoting/protocol/datagram_channel_factory.h" | 19 #include "remoting/protocol/datagram_channel_factory.h" |
| 20 #include "remoting/protocol/jingle_messages.h" | 20 #include "remoting/protocol/jingle_messages.h" |
| 21 #include "remoting/protocol/ordered_message_queue.h" |
| 21 #include "remoting/protocol/session.h" | 22 #include "remoting/protocol/session.h" |
| 22 #include "remoting/protocol/session_config.h" | 23 #include "remoting/protocol/session_config.h" |
| 23 #include "remoting/signaling/iq_sender.h" | 24 #include "remoting/signaling/iq_sender.h" |
| 24 | 25 |
| 25 namespace remoting { | 26 namespace remoting { |
| 26 namespace protocol { | 27 namespace protocol { |
| 27 | 28 |
| 28 class JingleSessionManager; | 29 class JingleSessionManager; |
| 29 class Transport; | 30 class Transport; |
| 30 | 31 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const buzz::XmlElement* response); | 75 const buzz::XmlElement* response); |
| 75 | 76 |
| 76 // Response handler for transport-info responses. Transport-info timeouts are | 77 // Response handler for transport-info responses. Transport-info timeouts are |
| 77 // ignored and don't terminate connection. | 78 // ignored and don't terminate connection. |
| 78 void OnTransportInfoResponse(IqRequest* request, | 79 void OnTransportInfoResponse(IqRequest* request, |
| 79 const buzz::XmlElement* response); | 80 const buzz::XmlElement* response); |
| 80 | 81 |
| 81 // Called by JingleSessionManager on incoming |message|. Must call | 82 // Called by JingleSessionManager on incoming |message|. Must call |
| 82 // |reply_callback| to send reply message before sending any other | 83 // |reply_callback| to send reply message before sending any other |
| 83 // messages. | 84 // messages. |
| 84 void OnIncomingMessage(std::unique_ptr<JingleMessage> message, | 85 void OnIncomingMessage(std::string id, |
| 86 std::unique_ptr<JingleMessage> message, |
| 85 const ReplyCallback& reply_callback); | 87 const ReplyCallback& reply_callback); |
| 86 | 88 |
| 89 // Called by OnIncomingMessage() to process the incoming Jingle messages |
| 90 // in the same order that they are sent. |
| 91 void OnIncomingMessageInOrder(std::unique_ptr<JingleMessage> message, |
| 92 const ReplyCallback& reply_callback); |
| 93 |
| 87 // Message handlers for incoming messages. | 94 // Message handlers for incoming messages. |
| 88 void OnAccept(std::unique_ptr<JingleMessage> message, | 95 void OnAccept(std::unique_ptr<JingleMessage> message, |
| 89 const ReplyCallback& reply_callback); | 96 const ReplyCallback& reply_callback); |
| 90 void OnSessionInfo(std::unique_ptr<JingleMessage> message, | 97 void OnSessionInfo(std::unique_ptr<JingleMessage> message, |
| 91 const ReplyCallback& reply_callback); | 98 const ReplyCallback& reply_callback); |
| 92 void OnTerminate(std::unique_ptr<JingleMessage> message, | 99 void OnTerminate(std::unique_ptr<JingleMessage> message, |
| 93 const ReplyCallback& reply_callback); | 100 const ReplyCallback& reply_callback); |
| 94 | 101 |
| 95 // Called from OnAccept() to initialize session config. | 102 // Called from OnAccept() to initialize session config. |
| 96 bool InitializeConfigFromDescription(const ContentDescription* description); | 103 bool InitializeConfigFromDescription(const ContentDescription* description); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 std::unique_ptr<Authenticator> authenticator_; | 135 std::unique_ptr<Authenticator> authenticator_; |
| 129 | 136 |
| 130 Transport* transport_ = nullptr; | 137 Transport* transport_ = nullptr; |
| 131 | 138 |
| 132 // Pending Iq requests. Used for all messages except transport-info. | 139 // Pending Iq requests. Used for all messages except transport-info. |
| 133 std::set<std::unique_ptr<IqRequest>> pending_requests_; | 140 std::set<std::unique_ptr<IqRequest>> pending_requests_; |
| 134 | 141 |
| 135 // Pending transport-info requests. | 142 // Pending transport-info requests. |
| 136 std::list<std::unique_ptr<IqRequest>> transport_info_requests_; | 143 std::list<std::unique_ptr<IqRequest>> transport_info_requests_; |
| 137 | 144 |
| 145 struct QueueItem { |
| 146 QueueItem(std::unique_ptr<JingleMessage> message, |
| 147 const ReplyCallback& reply_callback); |
| 148 ~QueueItem(); |
| 149 std::unique_ptr<JingleMessage> message; |
| 150 const ReplyCallback reply_callback; |
| 151 }; |
| 152 |
| 153 // A message queue to guarantee the incoming messages are processed in order. |
| 154 OrderedMessageQueue<std::unique_ptr<QueueItem>> message_queue_; |
| 155 |
| 138 base::WeakPtrFactory<JingleSession> weak_factory_; | 156 base::WeakPtrFactory<JingleSession> weak_factory_; |
| 139 | 157 |
| 140 DISALLOW_COPY_AND_ASSIGN(JingleSession); | 158 DISALLOW_COPY_AND_ASSIGN(JingleSession); |
| 141 }; | 159 }; |
| 142 | 160 |
| 143 } // namespace protocol | 161 } // namespace protocol |
| 144 } // namespace remoting | 162 } // namespace remoting |
| 145 | 163 |
| 146 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ | 164 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| OLD | NEW |