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

Side by Side Diff: components/proximity_auth/bluetooth_connection.cc

Issue 1912433002: Convert //components/proximity_auth from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/proximity_auth/bluetooth_connection.h" 5 #include "components/proximity_auth/bluetooth_connection.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (socket_.get()) { 65 if (socket_.get()) {
66 socket_->Disconnect(base::Bind(&base::DoNothing)); 66 socket_->Disconnect(base::Bind(&base::DoNothing));
67 socket_ = NULL; 67 socket_ = NULL;
68 } 68 }
69 if (adapter_.get()) { 69 if (adapter_.get()) {
70 adapter_->RemoveObserver(this); 70 adapter_->RemoveObserver(this);
71 adapter_ = NULL; 71 adapter_ = NULL;
72 } 72 }
73 } 73 }
74 74
75 void BluetoothConnection::SendMessageImpl(scoped_ptr<WireMessage> message) { 75 void BluetoothConnection::SendMessageImpl(
76 std::unique_ptr<WireMessage> message) {
76 DCHECK_EQ(status(), CONNECTED); 77 DCHECK_EQ(status(), CONNECTED);
77 78
78 // Serialize the message. 79 // Serialize the message.
79 std::string serialized_message = message->Serialize(); 80 std::string serialized_message = message->Serialize();
80 int message_length = base::checked_cast<int>(serialized_message.size()); 81 int message_length = base::checked_cast<int>(serialized_message.size());
81 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(message_length); 82 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(message_length);
82 memcpy(buffer->data(), serialized_message.c_str(), message_length); 83 memcpy(buffer->data(), serialized_message.c_str(), message_length);
83 84
84 // Send it. 85 // Send it.
85 pending_message_ = std::move(message); 86 pending_message_ = std::move(message);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 PA_LOG(WARNING) << "Error receiving bytes: " << error_message; 198 PA_LOG(WARNING) << "Error receiving bytes: " << error_message;
198 199
199 // Post a task to delay the read until the socket is available, as 200 // Post a task to delay the read until the socket is available, as
200 // calling StartReceive at this point would error with ERR_IO_PENDING. 201 // calling StartReceive at this point would error with ERR_IO_PENDING.
201 base::ThreadTaskRunnerHandle::Get()->PostTask( 202 base::ThreadTaskRunnerHandle::Get()->PostTask(
202 FROM_HERE, base::Bind(&BluetoothConnection::StartReceive, 203 FROM_HERE, base::Bind(&BluetoothConnection::StartReceive,
203 weak_ptr_factory_.GetWeakPtr())); 204 weak_ptr_factory_.GetWeakPtr()));
204 } 205 }
205 206
206 } // namespace proximity_auth 207 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/bluetooth_connection.h ('k') | components/proximity_auth/bluetooth_connection_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698