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 | 9 |
9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
14 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 DCHECK(data); | 186 DCHECK(data); |
186 cur_request_->SetUserData(this, data); | 187 cur_request_->SetUserData(this, data); |
187 | 188 |
188 if (post_data.empty()) { | 189 if (post_data.empty()) { |
189 cur_request_->set_method("GET"); | 190 cur_request_->set_method("GET"); |
190 } else { | 191 } else { |
191 cur_request_->set_method("POST"); | 192 cur_request_->set_method("POST"); |
192 scoped_ptr<UploadElementReader> reader( | 193 scoped_ptr<UploadElementReader> reader( |
193 UploadOwnedBytesElementReader::CreateWithString(post_data)); | 194 UploadOwnedBytesElementReader::CreateWithString(post_data)); |
194 cur_request_->set_upload( | 195 cur_request_->set_upload( |
195 ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); | 196 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |
196 HttpRequestHeaders headers; | 197 HttpRequestHeaders headers; |
197 headers.SetHeader(HttpRequestHeaders::kContentType, | 198 headers.SetHeader(HttpRequestHeaders::kContentType, |
198 "application/json"); | 199 "application/json"); |
199 cur_request_->SetExtraRequestHeaders(headers); | 200 cur_request_->SetExtraRequestHeaders(headers); |
200 } | 201 } |
201 | 202 |
202 // Post a task to timeout this request if it takes too long. | 203 // Post a task to timeout this request if it takes too long. |
203 base::MessageLoop::current()->PostDelayedTask( | 204 base::MessageLoop::current()->PostDelayedTask( |
204 FROM_HERE, | 205 FROM_HERE, |
205 base::Bind(&SpawnerCommunicator::OnTimeout, | 206 base::Bind(&SpawnerCommunicator::OnTimeout, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 std::string server_return_data; | 375 std::string server_return_data; |
375 int result_code; | 376 int result_code; |
376 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); | 377 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); |
377 Shutdown(); | 378 Shutdown(); |
378 if (OK != result_code || server_return_data != "killed") | 379 if (OK != result_code || server_return_data != "killed") |
379 return false; | 380 return false; |
380 return true; | 381 return true; |
381 } | 382 } |
382 | 383 |
383 } // namespace net | 384 } // namespace net |
OLD | NEW |