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

Side by Side Diff: remoting/protocol/connection_tester.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac 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
« no previous file with comments | « remoting/protocol/connection_tester.h ('k') | remoting/protocol/connection_to_client.h » ('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 "remoting/protocol/connection_tester.h" 5 #include "remoting/protocol/connection_tester.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 client_pipe_(client_pipe), 269 client_pipe_(client_pipe),
270 message_size_(message_size), 270 message_size_(message_size),
271 message_count_(message_count) {} 271 message_count_(message_count) {}
272 MessagePipeConnectionTester::~MessagePipeConnectionTester() {} 272 MessagePipeConnectionTester::~MessagePipeConnectionTester() {}
273 273
274 void MessagePipeConnectionTester::RunAndCheckResults() { 274 void MessagePipeConnectionTester::RunAndCheckResults() {
275 host_pipe_->StartReceiving(base::Bind( 275 host_pipe_->StartReceiving(base::Bind(
276 &MessagePipeConnectionTester::OnMessageReceived, base::Unretained(this))); 276 &MessagePipeConnectionTester::OnMessageReceived, base::Unretained(this)));
277 277
278 for (int i = 0; i < message_count_; ++i) { 278 for (int i = 0; i < message_count_; ++i) {
279 scoped_ptr<VideoPacket> message(new VideoPacket()); 279 std::unique_ptr<VideoPacket> message(new VideoPacket());
280 message->mutable_data()->resize(message_size_); 280 message->mutable_data()->resize(message_size_);
281 for (int p = 0; p < message_size_; ++p) { 281 for (int p = 0; p < message_size_; ++p) {
282 message->mutable_data()[0] = static_cast<char>(i + p); 282 message->mutable_data()[0] = static_cast<char>(i + p);
283 } 283 }
284 client_pipe_->Send(message.get(), base::Closure()); 284 client_pipe_->Send(message.get(), base::Closure());
285 sent_messages_.push_back(std::move(message)); 285 sent_messages_.push_back(std::move(message));
286 } 286 }
287 287
288 run_loop_.Run(); 288 run_loop_.Run();
289 289
290 ASSERT_EQ(sent_messages_.size(), received_messages_.size()); 290 ASSERT_EQ(sent_messages_.size(), received_messages_.size());
291 for (size_t i = 0; i < sent_messages_.size(); ++i) { 291 for (size_t i = 0; i < sent_messages_.size(); ++i) {
292 EXPECT_TRUE(sent_messages_[i]->data() == received_messages_[i]->data()); 292 EXPECT_TRUE(sent_messages_[i]->data() == received_messages_[i]->data());
293 } 293 }
294 } 294 }
295 295
296 void MessagePipeConnectionTester::OnMessageReceived( 296 void MessagePipeConnectionTester::OnMessageReceived(
297 scoped_ptr<CompoundBuffer> message) { 297 std::unique_ptr<CompoundBuffer> message) {
298 received_messages_.push_back(ParseMessage<VideoPacket>(message.get())); 298 received_messages_.push_back(ParseMessage<VideoPacket>(message.get()));
299 if (received_messages_.size() >= sent_messages_.size()) { 299 if (received_messages_.size() >= sent_messages_.size()) {
300 run_loop_.Quit(); 300 run_loop_.Quit();
301 } 301 }
302 } 302 }
303 303
304 } // namespace protocol 304 } // namespace protocol
305 } // namespace remoting 305 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/connection_tester.h ('k') | remoting/protocol/connection_to_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698