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

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

Issue 2453933008: Bugfixes in JingleSession (Closed)
Patch Set: Created 4 years, 1 month 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
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_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>
9 #include <set>
10 #include <string> 8 #include <string>
9 #include <vector>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "base/rand_util.h" 13 #include "base/rand_util.h"
15 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
17 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
18 #include "crypto/rsa_private_key.h" 17 #include "crypto/rsa_private_key.h"
19 #include "net/base/completion_callback.h" 18 #include "net/base/completion_callback.h"
20 #include "remoting/protocol/authenticator.h" 19 #include "remoting/protocol/authenticator.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Called by OnIncomingMessage() to process the incoming Jingle messages 89 // Called by OnIncomingMessage() to process the incoming Jingle messages
91 // in the same order that they are sent. 90 // in the same order that they are sent.
92 void ProcessIncomingMessage(std::unique_ptr<JingleMessage> message, 91 void ProcessIncomingMessage(std::unique_ptr<JingleMessage> message,
93 const ReplyCallback& reply_callback); 92 const ReplyCallback& reply_callback);
94 93
95 // Message handlers for incoming messages. 94 // Message handlers for incoming messages.
96 void OnAccept(std::unique_ptr<JingleMessage> message, 95 void OnAccept(std::unique_ptr<JingleMessage> message,
97 const ReplyCallback& reply_callback); 96 const ReplyCallback& reply_callback);
98 void OnSessionInfo(std::unique_ptr<JingleMessage> message, 97 void OnSessionInfo(std::unique_ptr<JingleMessage> message,
99 const ReplyCallback& reply_callback); 98 const ReplyCallback& reply_callback);
99 void OnTransportInfo(std::unique_ptr<JingleMessage> message,
100 const ReplyCallback& reply_callback);
100 void OnTerminate(std::unique_ptr<JingleMessage> message, 101 void OnTerminate(std::unique_ptr<JingleMessage> message,
101 const ReplyCallback& reply_callback); 102 const ReplyCallback& reply_callback);
102 103
103 // Called from OnAccept() to initialize session config. 104 // Called from OnAccept() to initialize session config.
104 bool InitializeConfigFromDescription(const ContentDescription* description); 105 bool InitializeConfigFromDescription(const ContentDescription* description);
105 106
106 // Called after the initial incoming authenticator message is processed. 107 // Called after the initial incoming authenticator message is processed.
107 void ContinueAcceptIncomingConnection(); 108 void ContinueAcceptIncomingConnection();
108 109
109 // Called after subsequent authenticator messages are processed. 110 // Called after subsequent authenticator messages are processed.
110 void ProcessAuthenticationStep(); 111 void ProcessAuthenticationStep();
111 112
112 // Called after the authenticating step is finished.
113 void ContinueAuthenticationStep();
114
115 // Called when authentication is finished. 113 // Called when authentication is finished.
116 void OnAuthenticated(); 114 void OnAuthenticated();
117 115
118 // Sets |state_| to |new_state| and calls state change callback. 116 // Sets |state_| to |new_state| and calls state change callback.
119 void SetState(State new_state); 117 void SetState(State new_state);
120 118
121 // Returns true if the state of the session is not CLOSED or FAILED 119 // Returns true if the state of the session is not CLOSED or FAILED
122 bool is_session_active(); 120 bool is_session_active();
123 121
124 // Returns the value of the ID attribute of the next outgoing set IQ with the 122 // Returns the value of the ID attribute of the next outgoing set IQ with the
(...skipping 10 matching lines...) Expand all
135 State state_; 133 State state_;
136 ErrorCode error_; 134 ErrorCode error_;
137 135
138 std::unique_ptr<SessionConfig> config_; 136 std::unique_ptr<SessionConfig> config_;
139 137
140 std::unique_ptr<Authenticator> authenticator_; 138 std::unique_ptr<Authenticator> authenticator_;
141 139
142 Transport* transport_ = nullptr; 140 Transport* transport_ = nullptr;
143 141
144 // Pending Iq requests. Used for all messages except transport-info. 142 // Pending Iq requests. Used for all messages except transport-info.
145 std::set<std::unique_ptr<IqRequest>> pending_requests_; 143 std::vector<std::unique_ptr<IqRequest>> pending_requests_;
146 144
147 // Pending transport-info requests. 145 // Pending transport-info requests.
148 std::list<std::unique_ptr<IqRequest>> transport_info_requests_; 146 std::vector<std::unique_ptr<IqRequest>> transport_info_requests_;
149 147
150 struct PendingMessage { 148 struct PendingMessage {
149 PendingMessage();
150 PendingMessage(PendingMessage&& moved);
151 PendingMessage(std::unique_ptr<JingleMessage> message, 151 PendingMessage(std::unique_ptr<JingleMessage> message,
152 const ReplyCallback& reply_callback); 152 const ReplyCallback& reply_callback);
153 ~PendingMessage(); 153 ~PendingMessage();
154 PendingMessage& operator=(PendingMessage&& moved);
154 std::unique_ptr<JingleMessage> message; 155 std::unique_ptr<JingleMessage> message;
155 const ReplyCallback reply_callback; 156 ReplyCallback reply_callback;
156 }; 157 };
157 158
158 // A message queue to guarantee the incoming messages are processed in order. 159 // A message queue to guarantee the incoming messages are processed in order.
159 class OrderedMessageQueue; 160 class OrderedMessageQueue;
160 std::unique_ptr<OrderedMessageQueue> message_queue_; 161 std::unique_ptr<OrderedMessageQueue> message_queue_;
161 162
162 // This prefix is necessary to disambiguate between the ID's sent from the 163 // This prefix is necessary to disambiguate between the ID's sent from the
163 // client and the ID's sent from the host. 164 // client and the ID's sent from the host.
164 std::string outgoing_id_prefix_ = base::Uint64ToString(base::RandUint64()); 165 std::string outgoing_id_prefix_ = base::Uint64ToString(base::RandUint64());
165 int next_outgoing_id_ = 0; 166 int next_outgoing_id_ = 0;
166 167
168 // Transport info messages that are received while the session is being
169 // authenticated.
170 std::vector<PendingMessage> pending_transport_info_;
171
167 base::WeakPtrFactory<JingleSession> weak_factory_; 172 base::WeakPtrFactory<JingleSession> weak_factory_;
168 173
169 DISALLOW_COPY_AND_ASSIGN(JingleSession); 174 DISALLOW_COPY_AND_ASSIGN(JingleSession);
170 }; 175 };
171 176
172 } // namespace protocol 177 } // namespace protocol
173 } // namespace remoting 178 } // namespace remoting
174 179
175 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ 180 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698