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

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

Issue 2425483002: Remove usage of FOR_EACH_OBSERVER macro in remoting (Closed)
Patch Set: braces 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/fake_signal_strategy.cc ('k') | remoting/test/test_chromoting_client.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 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 void XmppSignalStrategy::Core::Connect() { 169 void XmppSignalStrategy::Core::Connect() {
170 DCHECK(thread_checker_.CalledOnValidThread()); 170 DCHECK(thread_checker_.CalledOnValidThread());
171 171
172 // Disconnect first if we are currently connected. 172 // Disconnect first if we are currently connected.
173 Disconnect(); 173 Disconnect();
174 174
175 error_ = OK; 175 error_ = OK;
176 176
177 FOR_EACH_OBSERVER(Listener, listeners_, 177 for (auto& observer : listeners_)
178 OnSignalStrategyStateChange(CONNECTING)); 178 observer.OnSignalStrategyStateChange(CONNECTING);
179 179
180 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( 180 socket_.reset(new jingle_glue::ProxyResolvingClientSocket(
181 socket_factory_, request_context_getter_, net::SSLConfig(), 181 socket_factory_, request_context_getter_, net::SSLConfig(),
182 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port))); 182 net::HostPortPair(xmpp_server_config_.host, xmpp_server_config_.port)));
183 183
184 int result = socket_->Connect(base::Bind( 184 int result = socket_->Connect(base::Bind(
185 &Core::OnSocketConnected, base::Unretained(this))); 185 &Core::OnSocketConnected, base::Unretained(this)));
186 186
187 keep_alive_timer_.Start( 187 keep_alive_timer_.Start(
188 FROM_HERE, base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds), 188 FROM_HERE, base::TimeDelta::FromSeconds(kKeepAliveIntervalSeconds),
189 base::Bind(&Core::SendKeepAlive, base::Unretained(this))); 189 base::Bind(&Core::SendKeepAlive, base::Unretained(this)));
190 190
191 if (result != net::ERR_IO_PENDING) 191 if (result != net::ERR_IO_PENDING)
192 OnSocketConnected(result); 192 OnSocketConnected(result);
193 } 193 }
194 194
195 void XmppSignalStrategy::Core::Disconnect() { 195 void XmppSignalStrategy::Core::Disconnect() {
196 DCHECK(thread_checker_.CalledOnValidThread()); 196 DCHECK(thread_checker_.CalledOnValidThread());
197 197
198 if (socket_) { 198 if (socket_) {
199 login_handler_.reset(); 199 login_handler_.reset();
200 stream_parser_.reset(); 200 stream_parser_.reset();
201 writer_.reset(); 201 writer_.reset();
202 socket_.reset(); 202 socket_.reset();
203 tls_state_ = TlsState::NOT_REQUESTED; 203 tls_state_ = TlsState::NOT_REQUESTED;
204 read_pending_ = false; 204 read_pending_ = false;
205 205
206 FOR_EACH_OBSERVER(Listener, listeners_, 206 for (auto& observer : listeners_)
207 OnSignalStrategyStateChange(DISCONNECTED)); 207 observer.OnSignalStrategyStateChange(DISCONNECTED);
208 } 208 }
209 } 209 }
210 210
211 SignalStrategy::State XmppSignalStrategy::Core::GetState() const { 211 SignalStrategy::State XmppSignalStrategy::Core::GetState() const {
212 DCHECK(thread_checker_.CalledOnValidThread()); 212 DCHECK(thread_checker_.CalledOnValidThread());
213 213
214 if (stream_parser_) { 214 if (stream_parser_) {
215 DCHECK(socket_); 215 DCHECK(socket_);
216 return CONNECTED; 216 return CONNECTED;
217 } else if (socket_) { 217 } else if (socket_) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 jid_ = jid; 330 jid_ = jid;
331 stream_parser_ = std::move(parser); 331 stream_parser_ = std::move(parser);
332 stream_parser_->SetCallbacks( 332 stream_parser_->SetCallbacks(
333 base::Bind(&Core::OnStanza, base::Unretained(this)), 333 base::Bind(&Core::OnStanza, base::Unretained(this)),
334 base::Bind(&Core::OnParserError, base::Unretained(this))); 334 base::Bind(&Core::OnParserError, base::Unretained(this)));
335 335
336 // Don't need |login_handler_| anymore. 336 // Don't need |login_handler_| anymore.
337 login_handler_.reset(); 337 login_handler_.reset();
338 338
339 FOR_EACH_OBSERVER(Listener, listeners_, 339 for (auto& observer : listeners_)
340 OnSignalStrategyStateChange(CONNECTED)); 340 observer.OnSignalStrategyStateChange(CONNECTED);
341 } 341 }
342 342
343 void XmppSignalStrategy::Core::OnLoginHandlerError( 343 void XmppSignalStrategy::Core::OnLoginHandlerError(
344 SignalStrategy::Error error) { 344 SignalStrategy::Error error) {
345 DCHECK(thread_checker_.CalledOnValidThread()); 345 DCHECK(thread_checker_.CalledOnValidThread());
346 346
347 error_ = error; 347 error_ = error;
348 Disconnect(); 348 Disconnect();
349 } 349 }
350 350
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 std::string XmppSignalStrategy::GetNextId() { 550 std::string XmppSignalStrategy::GetNextId() {
551 return base::Uint64ToString(base::RandUint64()); 551 return base::Uint64ToString(base::RandUint64());
552 } 552 }
553 553
554 void XmppSignalStrategy::SetAuthInfo(const std::string& username, 554 void XmppSignalStrategy::SetAuthInfo(const std::string& username,
555 const std::string& auth_token) { 555 const std::string& auth_token) {
556 core_->SetAuthInfo(username, auth_token); 556 core_->SetAuthInfo(username, auth_token);
557 } 557 }
558 558
559 } // namespace remoting 559 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/fake_signal_strategy.cc ('k') | remoting/test/test_chromoting_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698