| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 | 119 |
| 120 void ProtocolTestConnection::Init(ChromotocolConnection* connection) { | 120 void ProtocolTestConnection::Init(ChromotocolConnection* connection) { |
| 121 connection_ = connection; | 121 connection_ = connection; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ProtocolTestConnection::Write(const std::string& str) { | 124 void ProtocolTestConnection::Write(const std::string& str) { |
| 125 if (str.empty()) | 125 if (str.empty()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(str.length()); | 128 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(str.length())); |
| 129 memcpy(buf->data(), str.c_str(), str.length()); | 129 memcpy(buf->data(), str.c_str(), str.length()); |
| 130 message_loop_->PostTask( | 130 message_loop_->PostTask( |
| 131 FROM_HERE, NewRunnableMethod( | 131 FROM_HERE, NewRunnableMethod( |
| 132 this, &ProtocolTestConnection::DoWrite, buf, str.length())); | 132 this, &ProtocolTestConnection::DoWrite, buf, str.length())); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ProtocolTestConnection::DoWrite( | 135 void ProtocolTestConnection::DoWrite( |
| 136 scoped_refptr<net::IOBuffer> buf, int size) { | 136 scoped_refptr<net::IOBuffer> buf, int size) { |
| 137 if (pending_write_) { | 137 if (pending_write_) { |
| 138 LOG(ERROR) << "Cannot write because there is another pending write."; | 138 LOG(ERROR) << "Cannot write because there is another pending write."; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 std::string host_jid(cmd_line->GetSwitchValueASCII("host_jid")); | 355 std::string host_jid(cmd_line->GetSwitchValueASCII("host_jid")); |
| 356 | 356 |
| 357 if (!cmd_line->HasSwitch("username")) | 357 if (!cmd_line->HasSwitch("username")) |
| 358 usage(argv[0]); | 358 usage(argv[0]); |
| 359 std::string username(cmd_line->GetSwitchValueASCII("username")); | 359 std::string username(cmd_line->GetSwitchValueASCII("username")); |
| 360 | 360 |
| 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 |