| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 WaitForResponse(); | 168 WaitForResponse(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread( | 171 void SpawnerCommunicator::SendCommandAndWaitForResultOnIOThread( |
| 172 const std::string& command, | 172 const std::string& command, |
| 173 const std::string& post_data, | 173 const std::string& post_data, |
| 174 int* result_code, | 174 int* result_code, |
| 175 std::string* data_received) { | 175 std::string* data_received) { |
| 176 base::MessageLoop* loop = io_thread_.message_loop(); | 176 base::MessageLoop* loop = io_thread_.message_loop(); |
| 177 DCHECK(loop); | 177 DCHECK(loop); |
| 178 DCHECK_EQ(base::MessageLoop::current(), loop); | 178 DCHECK(loop->task_runner()->BelongsToCurrentThread()); |
| 179 | 179 |
| 180 // Prepare the URLRequest for sending the command. | 180 // Prepare the URLRequest for sending the command. |
| 181 DCHECK(!cur_request_.get()); | 181 DCHECK(!cur_request_.get()); |
| 182 context_.reset(new TestURLRequestContext); | 182 context_.reset(new TestURLRequestContext); |
| 183 cur_request_ = context_->CreateRequest( | 183 cur_request_ = context_->CreateRequest( |
| 184 GenerateSpawnerCommandURL(command, port_), DEFAULT_PRIORITY, this); | 184 GenerateSpawnerCommandURL(command, port_), DEFAULT_PRIORITY, this); |
| 185 DCHECK(cur_request_); | 185 DCHECK(cur_request_); |
| 186 int current_request_id = ++next_id_; | 186 int current_request_id = ++next_id_; |
| 187 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, | 187 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, |
| 188 result_code, | 188 result_code, |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 std::string server_return_data; | 378 std::string server_return_data; |
| 379 int result_code; | 379 int result_code; |
| 380 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 380 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
| 381 Shutdown(); | 381 Shutdown(); |
| 382 if (OK != result_code || server_return_data != "killed") | 382 if (OK != result_code || server_return_data != "killed") |
| 383 return false; | 383 return false; |
| 384 return true; | 384 return true; |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace net | 387 } // namespace net |
| OLD | NEW |