OLD | NEW |
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/cryptauth/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/cryptauth/connection_observer.h" |
11 #include "components/proximity_auth/wire_message.h" | 11 #include "components/cryptauth/wire_message.h" |
12 | 12 |
13 namespace proximity_auth { | 13 namespace cryptauth { |
14 | 14 |
15 Connection::Connection(const cryptauth::RemoteDevice& remote_device) | 15 Connection::Connection(const cryptauth::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 Connection::~Connection() { | 20 Connection::~Connection() {} |
21 } | |
22 | 21 |
23 bool Connection::IsConnected() const { | 22 bool Connection::IsConnected() const { |
24 return status_ == CONNECTED; | 23 return status_ == CONNECTED; |
25 } | 24 } |
26 | 25 |
27 void Connection::SendMessage(std::unique_ptr<WireMessage> message) { | 26 void Connection::SendMessage(std::unique_ptr<WireMessage> message) { |
28 if (!IsConnected()) { | 27 if (!IsConnected()) { |
29 VLOG(1) << "Cannot send message when disconnected."; | 28 VLOG(1) << "Cannot send message when disconnected."; |
30 return; | 29 return; |
31 } | 30 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Whether the message was parsed successfully or not, clear the | 95 // Whether the message was parsed successfully or not, clear the |
97 // |received_bytes_| buffer. | 96 // |received_bytes_| buffer. |
98 received_bytes_.clear(); | 97 received_bytes_.clear(); |
99 } | 98 } |
100 | 99 |
101 std::unique_ptr<WireMessage> Connection::DeserializeWireMessage( | 100 std::unique_ptr<WireMessage> Connection::DeserializeWireMessage( |
102 bool* is_incomplete_message) { | 101 bool* is_incomplete_message) { |
103 return WireMessage::Deserialize(received_bytes_, is_incomplete_message); | 102 return WireMessage::Deserialize(received_bytes_, is_incomplete_message); |
104 } | 103 } |
105 | 104 |
106 } // namespace proximity_auth | 105 } // namespace cryptauth |
OLD | NEW |