| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const RemoteDevice& remote_device() const { return remote_device_; } | 47 const RemoteDevice& remote_device() const { return remote_device_; } |
| 48 | 48 |
| 49 // Abstract methods that subclasses should implement: | 49 // Abstract methods that subclasses should implement: |
| 50 | 50 |
| 51 // Attempts to connect to the remote device if not already connected. | 51 // Attempts to connect to the remote device if not already connected. |
| 52 virtual void Connect() = 0; | 52 virtual void Connect() = 0; |
| 53 | 53 |
| 54 // Disconnects from the remote device. | 54 // Disconnects from the remote device. |
| 55 virtual void Disconnect() = 0; | 55 virtual void Disconnect() = 0; |
| 56 | 56 |
| 57 Status status() const { return status_; } |
| 58 |
| 57 protected: | 59 protected: |
| 58 // Sets the connection's status to |status|. If this is different from the | 60 // Sets the connection's status to |status|. If this is different from the |
| 59 // previous status, notifies observers of the change in status. | 61 // previous status, notifies observers of the change in status. |
| 60 // Virtual for testing. | 62 // Virtual for testing. |
| 61 virtual void SetStatus(Status status); | 63 virtual void SetStatus(Status status); |
| 62 | 64 |
| 63 Status status() const { return status_; } | |
| 64 | |
| 65 // Called after attempting to send bytes over the connection, whether the | 65 // Called after attempting to send bytes over the connection, whether the |
| 66 // message was successfully sent or not. | 66 // message was successfully sent or not. |
| 67 // Virtual for testing. | 67 // Virtual for testing. |
| 68 virtual void OnDidSendMessage(const WireMessage& message, bool success); | 68 virtual void OnDidSendMessage(const WireMessage& message, bool success); |
| 69 | 69 |
| 70 // Called when bytes are read from the connection. There should not be a send | 70 // Called when bytes are read from the connection. There should not be a send |
| 71 // in progress when this function is called. | 71 // in progress when this function is called. |
| 72 // Virtual for testing. | 72 // Virtual for testing. |
| 73 virtual void OnBytesReceived(const std::string& bytes); | 73 virtual void OnBytesReceived(const std::string& bytes); |
| 74 | 74 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Whether a message is currently in the process of being sent. | 109 // Whether a message is currently in the process of being sent. |
| 110 bool is_sending_message_; | 110 bool is_sending_message_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(Connection); | 112 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace proximity_auth | 115 } // namespace proximity_auth |
| 116 | 116 |
| 117 #endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_H | 117 #endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_H |
| OLD | NEW |