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

Side by Side Diff: components/proximity_auth/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
« no previous file with comments | « components/proximity_auth/connection.h ('k') | components/proximity_auth/connection_finder.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 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/connection.h" 5 #include "components/proximity_auth/connection.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/proximity_auth/connection_observer.h" 10 #include "components/proximity_auth/connection_observer.h"
11 #include "components/proximity_auth/wire_message.h" 11 #include "components/proximity_auth/wire_message.h"
12 12
13 namespace proximity_auth { 13 namespace proximity_auth {
14 14
15 Connection::Connection(const RemoteDevice& remote_device) 15 Connection::Connection(const RemoteDevice& remote_device)
16 : remote_device_(remote_device), 16 : remote_device_(remote_device),
17 status_(DISCONNECTED), 17 status_(DISCONNECTED),
18 is_sending_message_(false) { 18 is_sending_message_(false) {
19 } 19 }
20 20
21 Connection::~Connection() { 21 Connection::~Connection() {
22 } 22 }
23 23
24 bool Connection::IsConnected() const { 24 bool Connection::IsConnected() const {
25 return status_ == CONNECTED; 25 return status_ == CONNECTED;
26 } 26 }
27 27
28 void Connection::SendMessage(scoped_ptr<WireMessage> message) { 28 void Connection::SendMessage(std::unique_ptr<WireMessage> message) {
29 if (!IsConnected()) { 29 if (!IsConnected()) {
30 VLOG(1) << "Cannot send message when disconnected."; 30 VLOG(1) << "Cannot send message when disconnected.";
31 return; 31 return;
32 } 32 }
33 33
34 if (is_sending_message_) { 34 if (is_sending_message_) {
35 VLOG(1) << "Another message is currently in progress."; 35 VLOG(1) << "Another message is currently in progress.";
36 return; 36 return;
37 } 37 }
38 38
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void Connection::OnBytesReceived(const std::string& bytes) { 78 void Connection::OnBytesReceived(const std::string& bytes) {
79 if (!IsConnected()) { 79 if (!IsConnected()) {
80 VLOG(1) << "Received bytes, but not connected."; 80 VLOG(1) << "Received bytes, but not connected.";
81 return; 81 return;
82 } 82 }
83 83
84 received_bytes_ += bytes; 84 received_bytes_ += bytes;
85 85
86 bool is_incomplete_message; 86 bool is_incomplete_message;
87 scoped_ptr<WireMessage> message = 87 std::unique_ptr<WireMessage> message =
88 DeserializeWireMessage(&is_incomplete_message); 88 DeserializeWireMessage(&is_incomplete_message);
89 if (is_incomplete_message) 89 if (is_incomplete_message)
90 return; 90 return;
91 91
92 if (message) { 92 if (message) {
93 FOR_EACH_OBSERVER( 93 FOR_EACH_OBSERVER(
94 ConnectionObserver, observers_, OnMessageReceived(*this, *message)); 94 ConnectionObserver, observers_, OnMessageReceived(*this, *message));
95 } 95 }
96 96
97 // Whether the message was parsed successfully or not, clear the 97 // Whether the message was parsed successfully or not, clear the
98 // |received_bytes_| buffer. 98 // |received_bytes_| buffer.
99 received_bytes_.clear(); 99 received_bytes_.clear();
100 } 100 }
101 101
102 scoped_ptr<WireMessage> Connection::DeserializeWireMessage( 102 std::unique_ptr<WireMessage> Connection::DeserializeWireMessage(
103 bool* is_incomplete_message) { 103 bool* is_incomplete_message) {
104 return WireMessage::Deserialize(received_bytes_, is_incomplete_message); 104 return WireMessage::Deserialize(received_bytes_, is_incomplete_message);
105 } 105 }
106 106
107 } // namespace proximity_auth 107 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/connection.h ('k') | components/proximity_auth/connection_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698