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

Side by Side Diff: remoting/signaling/xmpp_signal_strategy.cc

Issue 2384063008: Enables delegating signal strategy for It2Me Host. (Closed)
Patch Set: Fix typos Created 4 years, 2 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
« no previous file with comments | « remoting/signaling/xmpp_signal_strategy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "remoting/signaling/xmpp_signal_strategy.h" 5 #include "remoting/signaling/xmpp_signal_strategy.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 TlsState tls_state_ = TlsState::NOT_REQUESTED; 134 TlsState tls_state_ = TlsState::NOT_REQUESTED;
135 135
136 std::unique_ptr<XmppLoginHandler> login_handler_; 136 std::unique_ptr<XmppLoginHandler> login_handler_;
137 std::unique_ptr<XmppStreamParser> stream_parser_; 137 std::unique_ptr<XmppStreamParser> stream_parser_;
138 std::string jid_; 138 std::string jid_;
139 139
140 Error error_ = OK; 140 Error error_ = OK;
141 141
142 base::ObserverList<Listener, true> listeners_; 142 base::ObserverList<Listener, true> listeners_;
143 143
144 base::Timer keep_alive_timer_; 144 base::RepeatingTimer keep_alive_timer_;
145 145
146 base::ThreadChecker thread_checker_; 146 base::ThreadChecker thread_checker_;
147 147
148 DISALLOW_COPY_AND_ASSIGN(Core); 148 DISALLOW_COPY_AND_ASSIGN(Core);
149 }; 149 };
150 150
151 XmppSignalStrategy::Core::Core( 151 XmppSignalStrategy::Core::Core(
152 net::ClientSocketFactory* socket_factory, 152 net::ClientSocketFactory* socket_factory,
153 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 153 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
154 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config) 154 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config)
155 : socket_factory_(socket_factory), 155 : socket_factory_(socket_factory),
156 request_context_getter_(request_context_getter), 156 request_context_getter_(request_context_getter),
157 xmpp_server_config_(xmpp_server_config), 157 xmpp_server_config_(xmpp_server_config) {
158 keep_alive_timer_(
159 FROM_HERE,
160 base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds),
161 base::Bind(&Core::SendKeepAlive, base::Unretained(this)),
162 true) {
163 #if defined(NDEBUG) 158 #if defined(NDEBUG)
164 // Non-secure connections are allowed only for debugging. 159 // Non-secure connections are allowed only for debugging.
165 CHECK(xmpp_server_config_.use_tls); 160 CHECK(xmpp_server_config_.use_tls);
166 #endif 161 #endif
162 thread_checker_.DetachFromThread();
167 } 163 }
168 164
169 XmppSignalStrategy::Core::~Core() { 165 XmppSignalStrategy::Core::~Core() {
170 Disconnect(); 166 Disconnect();
171 } 167 }
172 168
173 void XmppSignalStrategy::Core::Connect() { 169 void XmppSignalStrategy::Core::Connect() {
174 DCHECK(thread_checker_.CalledOnValidThread()); 170 DCHECK(thread_checker_.CalledOnValidThread());
175 171
176 // Disconnect first if we are currently connected. 172 // Disconnect first if we are currently connected.
177 Disconnect(); 173 Disconnect();
178 174
179 error_ = OK; 175 error_ = OK;
180 176
181 FOR_EACH_OBSERVER(Listener, listeners_, 177 FOR_EACH_OBSERVER(Listener, listeners_,
182 OnSignalStrategyStateChange(CONNECTING)); 178 OnSignalStrategyStateChange(CONNECTING));
183 179
184 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( 180 socket_.reset(new jingle_glue::ProxyResolvingClientSocket(
185 socket_factory_, request_context_getter_, net::SSLConfig(), 181 socket_factory_, request_context_getter_, net::SSLConfig(),
186 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port))); 182 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port)));
187 183
188 int result = socket_->Connect(base::Bind( 184 int result = socket_->Connect(base::Bind(
189 &Core::OnSocketConnected, base::Unretained(this))); 185 &Core::OnSocketConnected, base::Unretained(this)));
186
187 keep_alive_timer_.Start(
188 FROM_HERE, base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds),
189 base::Bind(&Core::SendKeepAlive, base::Unretained(this)));
190
190 if (result != net::ERR_IO_PENDING) 191 if (result != net::ERR_IO_PENDING)
191 OnSocketConnected(result); 192 OnSocketConnected(result);
192 } 193 }
193 194
194 void XmppSignalStrategy::Core::Disconnect() { 195 void XmppSignalStrategy::Core::Disconnect() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 196 DCHECK(thread_checker_.CalledOnValidThread());
196 197
197 if (socket_) { 198 if (socket_) {
198 login_handler_.reset(); 199 login_handler_.reset();
199 stream_parser_.reset(); 200 stream_parser_.reset();
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 std::string XmppSignalStrategy::GetNextId() { 551 std::string XmppSignalStrategy::GetNextId() {
551 return base::Uint64ToString(base::RandUint64()); 552 return base::Uint64ToString(base::RandUint64());
552 } 553 }
553 554
554 void XmppSignalStrategy::SetAuthInfo(const std::string& username, 555 void XmppSignalStrategy::SetAuthInfo(const std::string& username,
555 const std::string& auth_token) { 556 const std::string& auth_token) {
556 core_->SetAuthInfo(username, auth_token); 557 core_->SetAuthInfo(username, auth_token);
557 } 558 }
558 559
559 } // namespace remoting 560 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/xmpp_signal_strategy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698