| 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 "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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "net/base/request_priority.h" |
| 16 #include "net/base/upload_bytes_element_reader.h" | 17 #include "net/base/upload_bytes_element_reader.h" |
| 17 #include "net/base/upload_data_stream.h" | 18 #include "net/base/upload_data_stream.h" |
| 18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| 19 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 int* result_code, | 166 int* result_code, |
| 166 std::string* data_received) { | 167 std::string* data_received) { |
| 167 base::MessageLoop* loop = io_thread_.message_loop(); | 168 base::MessageLoop* loop = io_thread_.message_loop(); |
| 168 DCHECK(loop); | 169 DCHECK(loop); |
| 169 DCHECK_EQ(base::MessageLoop::current(), loop); | 170 DCHECK_EQ(base::MessageLoop::current(), loop); |
| 170 | 171 |
| 171 // Prepare the URLRequest for sending the command. | 172 // Prepare the URLRequest for sending the command. |
| 172 DCHECK(!cur_request_.get()); | 173 DCHECK(!cur_request_.get()); |
| 173 context_.reset(new TestURLRequestContext); | 174 context_.reset(new TestURLRequestContext); |
| 174 cur_request_.reset(context_->CreateRequest( | 175 cur_request_.reset(context_->CreateRequest( |
| 175 GenerateSpawnerCommandURL(command, port_), this)); | 176 GenerateSpawnerCommandURL(command, port_), DEFAULT_PRIORITY, this)); |
| 176 DCHECK(cur_request_.get()); | 177 DCHECK(cur_request_.get()); |
| 177 int current_request_id = ++next_id_; | 178 int current_request_id = ++next_id_; |
| 178 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, | 179 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, |
| 179 result_code, | 180 result_code, |
| 180 data_received); | 181 data_received); |
| 181 DCHECK(data); | 182 DCHECK(data); |
| 182 cur_request_->SetUserData(this, data); | 183 cur_request_->SetUserData(this, data); |
| 183 | 184 |
| 184 if (post_data.empty()) { | 185 if (post_data.empty()) { |
| 185 cur_request_->set_method("GET"); | 186 cur_request_->set_method("GET"); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 std::string server_return_data; | 371 std::string server_return_data; |
| 371 int result_code; | 372 int result_code; |
| 372 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 373 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
| 373 Shutdown(); | 374 Shutdown(); |
| 374 if (OK != result_code || server_return_data != "killed") | 375 if (OK != result_code || server_return_data != "killed") |
| 375 return false; | 376 return false; |
| 376 return true; | 377 return true; |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace net | 380 } // namespace net |
| OLD | NEW |