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

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

Issue 2842263003: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: clean Created 3 years, 7 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
« no previous file with comments | « no previous file | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/supports_user_data.h" 17 #include "base/supports_user_data.h"
17 #include "base/test/test_timeouts.h" 18 #include "base/test/test_timeouts.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "base/values.h" 21 #include "base/values.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "net/base/elements_upload_data_stream.h" 23 #include "net/base/elements_upload_data_stream.h"
23 #include "net/base/port_util.h" 24 #include "net/base/port_util.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DCHECK(loop); 180 DCHECK(loop);
180 DCHECK(loop->task_runner()->BelongsToCurrentThread()); 181 DCHECK(loop->task_runner()->BelongsToCurrentThread());
181 182
182 // Prepare the URLRequest for sending the command. 183 // Prepare the URLRequest for sending the command.
183 DCHECK(!cur_request_.get()); 184 DCHECK(!cur_request_.get());
184 context_.reset(new TestURLRequestContext); 185 context_.reset(new TestURLRequestContext);
185 cur_request_ = context_->CreateRequest( 186 cur_request_ = context_->CreateRequest(
186 GenerateSpawnerCommandURL(command, port_), DEFAULT_PRIORITY, this); 187 GenerateSpawnerCommandURL(command, port_), DEFAULT_PRIORITY, this);
187 DCHECK(cur_request_); 188 DCHECK(cur_request_);
188 int current_request_id = ++next_id_; 189 int current_request_id = ++next_id_;
189 SpawnerRequestData* data = new SpawnerRequestData(current_request_id, 190 cur_request_->SetUserData(
190 result_code, 191 this, base::MakeUnique<SpawnerRequestData>(current_request_id,
191 data_received); 192 result_code, data_received));
192 DCHECK(data);
193 cur_request_->SetUserData(this, data);
194 193
195 if (post_data.empty()) { 194 if (post_data.empty()) {
196 cur_request_->set_method("GET"); 195 cur_request_->set_method("GET");
197 } else { 196 } else {
198 cur_request_->set_method("POST"); 197 cur_request_->set_method("POST");
199 std::unique_ptr<UploadElementReader> reader( 198 std::unique_ptr<UploadElementReader> reader(
200 UploadOwnedBytesElementReader::CreateWithString(post_data)); 199 UploadOwnedBytesElementReader::CreateWithString(post_data));
201 cur_request_->set_upload( 200 cur_request_->set_upload(
202 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); 201 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
203 HttpRequestHeaders headers; 202 HttpRequestHeaders headers;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 std::string server_return_data; 388 std::string server_return_data;
390 int result_code; 389 int result_code;
391 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data); 390 SendCommandAndWaitForResult("kill", "", &result_code, &server_return_data);
392 Shutdown(); 391 Shutdown();
393 if (OK != result_code || server_return_data != "killed") 392 if (OK != result_code || server_return_data != "killed")
394 return false; 393 return false;
395 return true; 394 return true;
396 } 395 }
397 396
398 } // namespace net 397 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698