OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
8 extern "C" { | 8 extern "C" { |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 } | 10 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 NewCallback(this, &ProtocolTestClient::OnNewChromotocolConnection)); | 281 NewCallback(this, &ProtocolTestClient::OnNewChromotocolConnection)); |
282 server_->set_allow_local_ips(true); | 282 server_->set_allow_local_ips(true); |
283 | 283 |
284 if (host_jid_ != "") { | 284 if (host_jid_ != "") { |
285 ProtocolTestConnection* connection = | 285 ProtocolTestConnection* connection = |
286 new ProtocolTestConnection(this, client_->message_loop()); | 286 new ProtocolTestConnection(this, client_->message_loop()); |
287 connection->Init(server_->Connect( | 287 connection->Init(server_->Connect( |
288 host_jid_, CandidateChromotocolConfig::CreateDefault(), | 288 host_jid_, CandidateChromotocolConfig::CreateDefault(), |
289 NewCallback(connection, | 289 NewCallback(connection, |
290 &ProtocolTestConnection::OnStateChange))); | 290 &ProtocolTestConnection::OnStateChange))); |
291 connections_.push_back(connection); | 291 connections_.push_back(make_scoped_refptr(connection)); |
292 } | 292 } |
293 } else if (state == JingleClient::CLOSED) { | 293 } else if (state == JingleClient::CLOSED) { |
294 std::cerr << "Connection closed" << std::endl; | 294 std::cerr << "Connection closed" << std::endl; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 void ProtocolTestClient::OnNewChromotocolConnection( | 298 void ProtocolTestClient::OnNewChromotocolConnection( |
299 ChromotocolConnection* connection, | 299 ChromotocolConnection* connection, |
300 ChromotocolServer::IncomingConnectionResponse* response) { | 300 ChromotocolServer::IncomingConnectionResponse* response) { |
301 std::cerr << "Accepting connection from " << connection->jid() << std::endl; | 301 std::cerr << "Accepting connection from " << connection->jid() << std::endl; |
302 | 302 |
303 connection->set_config(ChromotocolConfig::CreateDefault()); | 303 connection->set_config(ChromotocolConfig::CreateDefault()); |
304 *response = ChromotocolServer::ACCEPT; | 304 *response = ChromotocolServer::ACCEPT; |
305 | 305 |
306 ProtocolTestConnection* test_connection = | 306 ProtocolTestConnection* test_connection = |
307 new ProtocolTestConnection(this, client_->message_loop()); | 307 new ProtocolTestConnection(this, client_->message_loop()); |
308 connection->SetStateChangeCallback( | 308 connection->SetStateChangeCallback( |
309 NewCallback(test_connection, &ProtocolTestConnection::OnStateChange)); | 309 NewCallback(test_connection, &ProtocolTestConnection::OnStateChange)); |
310 test_connection->Init(connection); | 310 test_connection->Init(connection); |
311 AutoLock auto_lock(connections_lock_); | 311 AutoLock auto_lock(connections_lock_); |
312 connections_.push_back(test_connection); | 312 connections_.push_back(make_scoped_refptr(test_connection)); |
313 } | 313 } |
314 | 314 |
315 void ProtocolTestClient::OnFinishedClosing() { | 315 void ProtocolTestClient::OnFinishedClosing() { |
316 closed_event_.Signal(); | 316 closed_event_.Signal(); |
317 } | 317 } |
318 | 318 |
319 void ProtocolTestClient::DestroyConnection( | 319 void ProtocolTestClient::DestroyConnection( |
320 scoped_refptr<ProtocolTestConnection> connection) { | 320 scoped_refptr<ProtocolTestConnection> connection) { |
321 connection->Close(); | 321 connection->Close(); |
322 AutoLock auto_lock(connections_lock_); | 322 AutoLock auto_lock(connections_lock_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (!cmd_line->HasSwitch("auth_token")) | 361 if (!cmd_line->HasSwitch("auth_token")) |
362 usage(argv[0]); | 362 usage(argv[0]); |
363 std::string auth_token(cmd_line->GetSwitchValueASCII("auth_token")); | 363 std::string auth_token(cmd_line->GetSwitchValueASCII("auth_token")); |
364 | 364 |
365 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient()); | 365 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient()); |
366 | 366 |
367 client->Run(username, auth_token, host_jid); | 367 client->Run(username, auth_token, host_jid); |
368 | 368 |
369 return 0; | 369 return 0; |
370 } | 370 } |
OLD | NEW |