OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/test/spawned_test_server/spawner_communicator.h" | 5 #include "net/test/spawned_test_server/spawner_communicator.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 std::string* data_received) { | 155 std::string* data_received) { |
156 if (!result_code || !data_received) | 156 if (!result_code || !data_received) |
157 return; | 157 return; |
158 // Start the communicator thread to talk to test server spawner. | 158 // Start the communicator thread to talk to test server spawner. |
159 StartIOThread(); | 159 StartIOThread(); |
160 DCHECK(io_thread_.message_loop()); | 160 DCHECK(io_thread_.message_loop()); |
161 | 161 |
162 // Since the method will be blocked until SpawnerCommunicator gets result | 162 // Since the method will be blocked until SpawnerCommunicator gets result |
163 // from the spawner server or timed-out. It's safe to use base::Unretained | 163 // from the spawner server or timed-out. It's safe to use base::Unretained |
164 // when using base::Bind. | 164 // when using base::Bind. |
165 io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 165 io_thread_.task_runner()->PostTask( |
166 &SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread, | 166 FROM_HERE, |
167 base::Unretained(this), command, post_data, result_code, data_received)); | 167 base::Bind(&SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread, |
| 168 base::Unretained(this), command, post_data, result_code, |
| 169 data_received)); |
168 WaitForResponse(); | 170 WaitForResponse(); |
169 } | 171 } |
170 | 172 |
171 void SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread( | 173 void SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread( |
172 const std::string& command, | 174 const std::string& command, |
173 const std::string& post_data, | 175 const std::string& post_data, |
174 int* result_code, | 176 int* result_code, |
175 std::string* data_received) { | 177 std::string* data_received) { |
176 base::MessageLoop* loop = io_thread_.message_loop(); | 178 base::MessageLoop* loop = io_thread_.message_loop(); |
177 DCHECK(loop); | 179 DCHECK(loop); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 std::string server_return_data; | 380 std::string server_return_data; |
379 int result_code; | 381 int result_code; |
380 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 382 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
381 Shutdown(); | 383 Shutdown(); |
382 if (OK != result_code || server_return_data != "killed") | 384 if (OK != result_code || server_return_data != "killed") |
383 return false; | 385 return false; |
384 return true; | 386 return true; |
385 } | 387 } |
386 | 388 |
387 } // namespace net | 389 } // namespace net |
OLD | NEW |