Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: net/test/spawned_test_server/spawner_communicator.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, 183 SpawnerRequestData* data = new SpawnerRequestData(current_request_id,
184 result_code, 184 result_code,
185 data_received); 185 data_received);
186 DCHECK(data); 186 DCHECK(data);
187 cur_request_->SetUserData(this, data); 187 cur_request_->SetUserData(this, data);
188 188
189 if (post_data.empty()) { 189 if (post_data.empty()) {
190 cur_request_->set_method("GET"); 190 cur_request_->set_method("GET");
191 } else { 191 } else {
192 cur_request_->set_method("POST"); 192 cur_request_->set_method("POST");
193 scoped_ptr<UploadElementReader> reader( 193 std::unique_ptr<UploadElementReader> reader(
194 UploadOwnedBytesElementReader::CreateWithString(post_data)); 194 UploadOwnedBytesElementReader::CreateWithString(post_data));
195 cur_request_->set_upload( 195 cur_request_->set_upload(
196 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); 196 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
197 HttpRequestHeaders headers; 197 HttpRequestHeaders headers;
198 headers.SetHeader(HttpRequestHeaders::kContentType, 198 headers.SetHeader(HttpRequestHeaders::kContentType,
199 "application/json"); 199 "application/json");
200 cur_request_->SetExtraRequestHeaders(headers); 200 cur_request_->SetExtraRequestHeaders(headers);
201 } 201 }
202 202
203 // 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.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Send the start command to spawner server to start the Python test server 333 // Send the start command to spawner server to start the Python test server
334 // on remote machine. 334 // on remote machine.
335 std::string server_return_data; 335 std::string server_return_data;
336 int result_code; 336 int result_code;
337 SendCommandAndWaitForResult("start", arguments, &result_code, 337 SendCommandAndWaitForResult("start", arguments, &result_code,
338 &server_return_data); 338 &server_return_data);
339 if (OK != result_code || server_return_data.empty()) 339 if (OK != result_code || server_return_data.empty())
340 return false; 340 return false;
341 341
342 // Check whether the data returned from spawner server is JSON-formatted. 342 // Check whether the data returned from spawner server is JSON-formatted.
343 scoped_ptr<base::Value> value = base::JSONReader::Read(server_return_data); 343 std::unique_ptr<base::Value> value =
344 base::JSONReader::Read(server_return_data);
344 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) { 345 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) {
345 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str(); 346 LOG(ERROR) << "Invalid server data: " << server_return_data.c_str();
346 return false; 347 return false;
347 } 348 }
348 349
349 // Check whether spawner server returns valid data. 350 // Check whether spawner server returns valid data.
350 base::DictionaryValue* server_data = 351 base::DictionaryValue* server_data =
351 static_cast<base::DictionaryValue*>(value.get()); 352 static_cast<base::DictionaryValue*>(value.get());
352 std::string message; 353 std::string message;
353 if (!server_data->GetString("message", &message) || message != "started") { 354 if (!server_data->GetString("message", &message) || message != "started") {
(...skipping 21 matching lines...) Expand all
375 std::string server_return_data; 376 std::string server_return_data;
376 int result_code; 377 int result_code;
377 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); 378 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data);
378 Shutdown(); 379 Shutdown();
379 if (OK != result_code || server_return_data != "killed") 380 if (OK != result_code || server_return_data != "killed")
380 return false; 381 return false;
381 return true; 382 return true;
382 } 383 }
383 384
384 } // namespace net 385 } // namespace net
OLDNEW
« no previous file with comments | « net/test/spawned_test_server/spawner_communicator.h ('k') | net/test/url_request/ssl_certificate_error_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698