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

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: fix release build 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
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | remoting/protocol/jingle_session.cc » ('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_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 // JingleSessionManager and JingleSession implement the subset of the 33 // JingleSessionManager and JingleSession implement the subset of the
36 // Jingle protocol used in Chromoting. Instances of this class are 34 // Jingle protocol used in Chromoting. Instances of this class are
37 // created by the JingleSessionManager. 35 // created by the JingleSessionManager.
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 IqRequests to the peer. It sets up the response
90 void OnSessionInitiateResponse(const buzz::XmlElement* response); 88 // callback to OnMessageResponse() which simply terminates the
89 // session whenever a request fails or times out. This method should
90 // not be used for messages that need to be handled differently.
91 void SendMessage(const JingleMessage& message);
92 void OnMessageResponse(JingleMessage::ActionType request_type,
93 IqRequest* request,
94 const buzz::XmlElement* response);
95 void CleanupPendingRequests(IqRequest* request);
91 96
92 // Called by JingleSessionManager on incoming |message|. Must call 97 // Called by JingleSessionManager on incoming |message|. Must call
93 // |reply_callback| to send reply message before sending any other 98 // |reply_callback| to send reply message before sending any other
94 // messages. 99 // messages.
95 void OnIncomingMessage(const JingleMessage& message, 100 void OnIncomingMessage(const JingleMessage& message,
96 const ReplyCallback& reply_callback); 101 const ReplyCallback& reply_callback);
97 102
98 // Message handlers for incoming messages. 103 // Message handlers for incoming messages.
99 void OnAccept(const JingleMessage& message, 104 void OnAccept(const JingleMessage& message,
100 const ReplyCallback& reply_callback); 105 const ReplyCallback& reply_callback);
101 void OnSessionInfo(const JingleMessage& message, 106 void OnSessionInfo(const JingleMessage& message,
102 const ReplyCallback& reply_callback); 107 const ReplyCallback& reply_callback);
103 void OnTerminate(const JingleMessage& message, 108 void OnTerminate(const JingleMessage& message,
104 const ReplyCallback& reply_callback); 109 const ReplyCallback& reply_callback);
105 void ProcessTransportInfo(const JingleMessage& message); 110 void ProcessTransportInfo(const JingleMessage& message);
106 111
107 // Called from OnAccept() to initialize session config. 112 // Called from OnAccept() to initialize session config.
108 bool InitializeConfigFromDescription(const ContentDescription* description); 113 bool InitializeConfigFromDescription(const ContentDescription* description);
109 114
110 void ProcessAuthenticationStep(); 115 void ProcessAuthenticationStep();
111 void OnSessionInfoResponse(const buzz::XmlElement* response);
112 116
113 void SendTransportInfo(); 117 void SendTransportInfo();
114 void OnTransportInfoResponse(const buzz::XmlElement* response);
115 118
116 // Terminates the session and sends session-terminate if it is 119 // Terminates the session and sends session-terminate if it is
117 // necessary. |error| specifies the error code in case when the 120 // necessary. |error| specifies the error code in case when the
118 // session is being closed due to an error. 121 // session is being closed due to an error.
119 void CloseInternal(Error error); 122 void CloseInternal(Error error);
120 123
121 // Sets |state_| to |new_state| and calls state change callback. 124 // Sets |state_| to |new_state| and calls state change callback.
122 void SetState(State new_state); 125 void SetState(State new_state);
123 126
124 JingleSessionManager* session_manager_; 127 JingleSessionManager* session_manager_;
125 std::string peer_jid_; 128 std::string peer_jid_;
126 scoped_ptr<CandidateSessionConfig> candidate_config_; 129 scoped_ptr<CandidateSessionConfig> candidate_config_;
127 StateChangeCallback state_change_callback_; 130 StateChangeCallback state_change_callback_;
128 RouteChangeCallback route_change_callback_; 131 RouteChangeCallback route_change_callback_;
129 132
130 std::string session_id_; 133 std::string session_id_;
131 State state_; 134 State state_;
132 Error error_; 135 Error error_;
133 136
134 SessionConfig config_; 137 SessionConfig config_;
135 bool config_is_set_; 138 bool config_is_set_;
136 139
137 scoped_ptr<Authenticator> authenticator_; 140 scoped_ptr<Authenticator> authenticator_;
138 141
139 scoped_ptr<IqRequest> initiate_request_; 142 // Container for pending Iq requests. Requests are removed in
140 scoped_ptr<IqRequest> session_info_request_; 143 // CleanupPendingRequests() which is called when a response is
141 scoped_ptr<IqRequest> transport_info_request_; 144 // received or one of the requests times out.
145 std::list<IqRequest*> pending_requests_;
142 146
143 ChannelsMap channels_; 147 ChannelsMap channels_;
144 148
145 base::OneShotTimer<JingleSession> transport_infos_timer_; 149 base::OneShotTimer<JingleSession> transport_infos_timer_;
146 std::list<cricket::Candidate> pending_candidates_; 150 std::list<cricket::Candidate> pending_candidates_;
147 151
148 DISALLOW_COPY_AND_ASSIGN(JingleSession); 152 DISALLOW_COPY_AND_ASSIGN(JingleSession);
149 }; 153 };
150 154
151 } // namespace protocol 155 } // namespace protocol
152 } // namespace remoting 156 } // namespace remoting
153 157
154 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_ 158 #endif // REMOTING_PROTOCOL_PEPPER_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | remoting/protocol/jingle_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698