| 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/spawner_communicator.h" | 5 #include "net/test/spawner_communicator.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 const std::string& post_data, | 162 const std::string& post_data, |
| 163 int* result_code, | 163 int* result_code, |
| 164 std::string* data_received) { | 164 std::string* data_received) { |
| 165 MessageLoop* loop = io_thread_.message_loop(); | 165 MessageLoop* loop = io_thread_.message_loop(); |
| 166 DCHECK(loop); | 166 DCHECK(loop); |
| 167 DCHECK_EQ(MessageLoop::current(), loop); | 167 DCHECK_EQ(MessageLoop::current(), loop); |
| 168 | 168 |
| 169 // Prepare the URLRequest for sending the command. | 169 // Prepare the URLRequest for sending the command. |
| 170 DCHECK(!cur_request_.get()); | 170 DCHECK(!cur_request_.get()); |
| 171 context_.reset(new TestURLRequestContext); | 171 context_.reset(new TestURLRequestContext); |
| 172 cur_request_.reset(new URLRequest(GenerateSpawnerCommandURL(command, port_), | 172 cur_request_.reset(context_->CreateRequest( |
| 173 this, | 173 GenerateSpawnerCommandURL(command, port_), this)); |
| 174 context_.get())); | |
| 175 DCHECK(cur_request_.get()); | 174 DCHECK(cur_request_.get()); |
| 176 int current_request_id = ++next_id_; | 175 int current_request_id = ++next_id_; |
| 177 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, | 176 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, |
| 178 result_code, | 177 result_code, |
| 179 data_received); | 178 data_received); |
| 180 DCHECK(data); | 179 DCHECK(data); |
| 181 cur_request_->SetUserData(this, data); | 180 cur_request_->SetUserData(this, data); |
| 182 | 181 |
| 183 if (post_data.empty()) { | 182 if (post_data.empty()) { |
| 184 cur_request_->set_method("GET"); | 183 cur_request_->set_method("GET"); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 std::string server_return_data; | 363 std::string server_return_data; |
| 365 int result_code; | 364 int result_code; |
| 366 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 365 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
| 367 Shutdown(); | 366 Shutdown(); |
| 368 if (OK != result_code || server_return_data != "killed") | 367 if (OK != result_code || server_return_data != "killed") |
| 369 return false; | 368 return false; |
| 370 return true; | 369 return true; |
| 371 } | 370 } |
| 372 | 371 |
| 373 } // namespace net | 372 } // namespace net |
| OLD | NEW |