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 #ifndef COMPONENTS_PROXIMITY_AUTH_CONNECTION_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_CONNECTION_H |
6 #define COMPONENTS_PROXIMITY_AUTH_CONNECTION_H | 6 #define COMPONENTS_PROXIMITY_AUTH_CONNECTION_H |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 virtual void SendMessageImpl(scoped_ptr<WireMessage> message) = 0; | 78 virtual void SendMessageImpl(scoped_ptr<WireMessage> message) = 0; |
79 | 79 |
80 // Deserializes the |recieved_bytes_| and returns the resulting WireMessage, | 80 // Deserializes the |recieved_bytes_| and returns the resulting WireMessage, |
81 // or NULL if the message is malformed. Sets |is_incomplete_message| to true | 81 // or NULL if the message is malformed. Sets |is_incomplete_message| to true |
82 // if the |serialized_message| does not have enough data to parse the header, | 82 // if the |serialized_message| does not have enough data to parse the header, |
83 // or if the message length encoded in the message header exceeds the size of | 83 // or if the message length encoded in the message header exceeds the size of |
84 // the |serialized_message|. Exposed for testing. | 84 // the |serialized_message|. Exposed for testing. |
85 virtual scoped_ptr<WireMessage> DeserializeWireMessage( | 85 virtual scoped_ptr<WireMessage> DeserializeWireMessage( |
86 bool* is_incomplete_message); | 86 bool* is_incomplete_message); |
87 | 87 |
| 88 // Exposed so it is possible to override DeserializeWireMessage in |
| 89 // BluetoothLowEnergyConnection class, while mantaining the same |
| 90 // functionality. |
| 91 // TODO(sacomoto): remove this when FakeWireMessage is not needed anymore. |
| 92 const std::string& received_bytes() { return received_bytes_; } |
| 93 |
88 private: | 94 private: |
89 // The remote device corresponding to this connection. | 95 // The remote device corresponding to this connection. |
90 const RemoteDevice remote_device_; | 96 const RemoteDevice remote_device_; |
91 | 97 |
92 // The current status of the connection. | 98 // The current status of the connection. |
93 Status status_; | 99 Status status_; |
94 | 100 |
95 // The registered observers of the connection. | 101 // The registered observers of the connection. |
96 ObserverList<ConnectionObserver> observers_; | 102 ObserverList<ConnectionObserver> observers_; |
97 | 103 |
98 // A temporary buffer storing bytes received before a received message can be | 104 // A temporary buffer storing bytes received before a received message can be |
99 // fully constructed. | 105 // fully constructed. |
100 std::string received_bytes_; | 106 std::string received_bytes_; |
101 | 107 |
102 // Whether a message is currently in the process of being sent. | 108 // Whether a message is currently in the process of being sent. |
103 bool is_sending_message_; | 109 bool is_sending_message_; |
104 | 110 |
105 DISALLOW_COPY_AND_ASSIGN(Connection); | 111 DISALLOW_COPY_AND_ASSIGN(Connection); |
106 }; | 112 }; |
107 | 113 |
108 } // namespace proximity_auth | 114 } // namespace proximity_auth |
109 | 115 |
110 #endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_H | 116 #endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_H |
OLD | NEW |