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

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

Issue 9452038: Implement timeouts for IQ requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 10 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 | Annotate | Revision Log
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_PEPPER_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_PEPPER_SESSION_H_
6 #define REMOTING_PROTOCOL_PEPPER_SESSION_H_ 6 #define REMOTING_PROTOCOL_PEPPER_SESSION_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "crypto/rsa_private_key.h" 14 #include "crypto/rsa_private_key.h"
15 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
16 #include "remoting/jingle_glue/iq_sender.h"
16 #include "remoting/protocol/authenticator.h" 17 #include "remoting/protocol/authenticator.h"
17 #include "remoting/protocol/jingle_messages.h" 18 #include "remoting/protocol/jingle_messages.h"
18 #include "remoting/protocol/session.h" 19 #include "remoting/protocol/session.h"
19 #include "remoting/protocol/session_config.h" 20 #include "remoting/protocol/session_config.h"
20 #include "remoting/protocol/transport.h" 21 #include "remoting/protocol/transport.h"
21 22
22 namespace net { 23 namespace net {
23 class Socket; 24 class Socket;
24 class StreamSocket; 25 class StreamSocket;
25 } // namespace net 26 } // namespace net
26 27
27 namespace remoting { 28 namespace remoting {
28
29 class IqRequest;
30
31 namespace protocol { 29 namespace protocol {
32 30
33 class JingleSessionManager; 31 class JingleSessionManager;
34 32
35 // Implements the protocol::Session interface using the Pepper P2P 33 // Implements the protocol::Session interface using the Pepper P2P
36 // Transport API. Created by JingleSessionManager for incoming and 34 // Transport API. Created by JingleSessionManager for incoming and
37 // outgoing connections. 35 // outgoing connections.
38 class JingleSession : public Session, 36 class JingleSession : public Session,
39 public Transport::EventHandler { 37 public Transport::EventHandler {
40 public: 38 public:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void StartConnection(const std::string& peer_jid, 77 void StartConnection(const std::string& peer_jid,
80 scoped_ptr<Authenticator> authenticator, 78 scoped_ptr<Authenticator> authenticator,
81 scoped_ptr<CandidateSessionConfig> config, 79 scoped_ptr<CandidateSessionConfig> config,
82 const StateChangeCallback& state_change_callback); 80 const StateChangeCallback& state_change_callback);
83 81
84 // Called by JingleSessionManager for incoming connections. 82 // Called by JingleSessionManager for incoming connections.
85 void InitializeIncomingConnection(const JingleMessage& initiate_message, 83 void InitializeIncomingConnection(const JingleMessage& initiate_message,
86 scoped_ptr<Authenticator> authenticator); 84 scoped_ptr<Authenticator> authenticator);
87 void AcceptIncomingConnection(const JingleMessage& initiate_message); 85 void AcceptIncomingConnection(const JingleMessage& initiate_message);
88 86
89 // Handler for session-initiate response. 87 // Helper to send outgoing messages.
90 void OnSessionInitiateResponse(const buzz::XmlElement* response); 88 void SendMessage(const JingleMessage& message);
91 89
92 // Called by JingleSessionManager on incoming |message|. Must call 90 // Called by JingleSessionManager on incoming |message|. Must call
93 // |reply_callback| to send reply message before sending any other 91 // |reply_callback| to send reply message before sending any other
94 // messages. 92 // messages.
95 void OnIncomingMessage(const JingleMessage& message, 93 void OnIncomingMessage(const JingleMessage& message,
96 const ReplyCallback& reply_callback); 94 const ReplyCallback& reply_callback);
97 95
98 // Message handlers for incoming messages. 96 // Message handlers for incoming messages.
99 void OnAccept(const JingleMessage& message, 97 void OnAccept(const JingleMessage& message,
100 const ReplyCallback& reply_callback); 98 const ReplyCallback& reply_callback);
101 void OnSessionInfo(const JingleMessage& message, 99 void OnSessionInfo(const JingleMessage& message,
102 const ReplyCallback& reply_callback); 100 const ReplyCallback& reply_callback);
103 void OnTerminate(const JingleMessage& message, 101 void OnTerminate(const JingleMessage& message,
104 const ReplyCallback& reply_callback); 102 const ReplyCallback& reply_callback);
105 void ProcessTransportInfo(const JingleMessage& message); 103 void ProcessTransportInfo(const JingleMessage& message);
106 104
107 // Called from OnAccept() to initialize session config. 105 // Called from OnAccept() to initialize session config.
108 bool InitializeConfigFromDescription(const ContentDescription* description); 106 bool InitializeConfigFromDescription(const ContentDescription* description);
109 107
110 void ProcessAuthenticationStep(); 108 void ProcessAuthenticationStep();
111 void OnSessionInfoResponse(const buzz::XmlElement* response);
112 109
113 void SendTransportInfo(); 110 void SendTransportInfo();
114 void OnTransportInfoResponse(const buzz::XmlElement* response); 111
112 void OnIqMessageResponse(JingleMessage::ActionType request_type,
113 IqRequest* request,
114 const buzz::XmlElement* response);
115
116 void CleanupPendingRequests(IqRequest* request);
115 117
116 // Terminates the session and sends session-terminate if it is 118 // Terminates the session and sends session-terminate if it is
117 // necessary. |error| specifies the error code in case when the 119 // necessary. |error| specifies the error code in case when the
118 // session is being closed due to an error. 120 // session is being closed due to an error.
119 void CloseInternal(Error error); 121 void CloseInternal(Error error);
120 122
121 // Sets |state_| to |new_state| and calls state change callback. 123 // Sets |state_| to |new_state| and calls state change callback.
122 void SetState(State new_state); 124 void SetState(State new_state);
123 125
124 JingleSessionManager* session_manager_; 126 JingleSessionManager* session_manager_;
125 std::string peer_jid_; 127 std::string peer_jid_;
126 scoped_ptr<CandidateSessionConfig> candidate_config_; 128 scoped_ptr<CandidateSessionConfig> candidate_config_;
127 StateChangeCallback state_change_callback_; 129 StateChangeCallback state_change_callback_;
128 RouteChangeCallback route_change_callback_; 130 RouteChangeCallback route_change_callback_;
129 131
130 std::string session_id_; 132 std::string session_id_;
131 State state_; 133 State state_;
132 Error error_; 134 Error error_;
133 135
134 SessionConfig config_; 136 SessionConfig config_;
135 bool config_is_set_; 137 bool config_is_set_;
136 138
137 scoped_ptr<Authenticator> authenticator_; 139 scoped_ptr<Authenticator> authenticator_;
138 140
139 scoped_ptr<IqRequest> initiate_request_; 141 // Container for pending Iq requests. Requests are removed in
140 scoped_ptr<IqRequest> session_info_request_; 142 // CleanupPendingRequests() which is called when a response is
141 scoped_ptr<IqRequest> transport_info_request_; 143 // received or one of the requests times out.
144 std::list<IqRequest*> pending_requests_;
142 145
143 ChannelsMap channels_; 146 ChannelsMap channels_;
144 147
145 base::OneShotTimer<JingleSession> transport_infos_timer_; 148 base::OneShotTimer<JingleSession> transport_infos_timer_;
146 std::list<cricket::Candidate> pending_candidates_; 149 std::list<cricket::Candidate> pending_candidates_;
147 150
148 DISALLOW_COPY_AND_ASSIGN(JingleSession); 151 DISALLOW_COPY_AND_ASSIGN(JingleSession);
149 }; 152 };
150 153
151 } // namespace protocol 154 } // namespace protocol
152 } // namespace remoting 155 } // namespace remoting
153 156
154 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ 157 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698