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

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

Issue 2384063008: Enables delegating signal strategy for It2Me Host. (Closed)
Patch Set: Fix unit tests 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_( 158 keep_alive_timer_(true /* retain_user_task */, true /* is_repeating */) {
Sergey Ulanov 2016/10/06 18:28:57 Change keep_alive_timer_ to base::RepeatingTimer,
kelvinp 2016/10/06 20:30:28 Done.
159 FROM_HERE,
160 base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds),
161 base::Bind(&Core::SendKeepAlive, base::Unretained(this)),
162 true) {
163 #if defined(NDEBUG) 159 #if defined(NDEBUG)
164 // Non-secure connections are allowed only for debugging. 160 // Non-secure connections are allowed only for debugging.
165 CHECK(xmpp_server_config_.use_tls); 161 CHECK(xmpp_server_config_.use_tls);
166 #endif 162 #endif
163 thread_checker_.DetachFromThread();
167 } 164 }
168 165
169 XmppSignalStrategy::Core::~Core() { 166 XmppSignalStrategy::Core::~Core() {
170 Disconnect(); 167 Disconnect();
171 } 168 }
172 169
173 void XmppSignalStrategy::Core::Connect() { 170 void XmppSignalStrategy::Core::Connect() {
174 DCHECK(thread_checker_.CalledOnValidThread()); 171 DCHECK(thread_checker_.CalledOnValidThread());
175 172
176 // Disconnect first if we are currently connected. 173 // Disconnect first if we are currently connected.
177 Disconnect(); 174 Disconnect();
178 175
179 error_ = OK; 176 error_ = OK;
180 177
181 FOR_EACH_OBSERVER(Listener, listeners_, 178 FOR_EACH_OBSERVER(Listener, listeners_,
182 OnSignalStrategyStateChange(CONNECTING)); 179 OnSignalStrategyStateChange(CONNECTING));
183 180
184 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( 181 socket_.reset(new jingle_glue::ProxyResolvingClientSocket(
185 socket_factory_, request_context_getter_, net::SSLConfig(), 182 socket_factory_, request_context_getter_, net::SSLConfig(),
186 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port))); 183 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port)));
187 184
188 int result = socket_->Connect(base::Bind( 185 int result = socket_->Connect(base::Bind(
189 &Core::OnSocketConnected, base::Unretained(this))); 186 &Core::OnSocketConnected, base::Unretained(this)));
187
188 keep_alive_timer_.Start(
189 FROM_HERE, base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds),
190 base::Bind(&Core::SendKeepAlive, base::Unretained(this)));
191
190 if (result != net::ERR_IO_PENDING) 192 if (result != net::ERR_IO_PENDING)
191 OnSocketConnected(result); 193 OnSocketConnected(result);
192 } 194 }
193 195
194 void XmppSignalStrategy::Core::Disconnect() { 196 void XmppSignalStrategy::Core::Disconnect() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 197 DCHECK(thread_checker_.CalledOnValidThread());
196 198
197 if (socket_) { 199 if (socket_) {
198 login_handler_.reset(); 200 login_handler_.reset();
199 stream_parser_.reset(); 201 stream_parser_.reset();
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 std::string XmppSignalStrategy::GetNextId() { 552 std::string XmppSignalStrategy::GetNextId() {
551 return base::Uint64ToString(base::RandUint64()); 553 return base::Uint64ToString(base::RandUint64());
552 } 554 }
553 555
554 void XmppSignalStrategy::SetAuthInfo(const std::string& username, 556 void XmppSignalStrategy::SetAuthInfo(const std::string& username,
555 const std::string& auth_token) { 557 const std::string& auth_token) {
556 core_->SetAuthInfo(username, auth_token); 558 core_->SetAuthInfo(username, auth_token);
557 } 559 }
558 560
559 } // namespace remoting 561 } // namespace remoting
OLDNEW
« remoting/signaling/delegating_signal_strategy.h ('K') | « remoting/signaling/xmpp_signal_strategy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698