isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_PROXIMITY_AUTH_CONNECTION_OBSERVER_H |
| 6 | #define COMPONENTS_PROXIMITY_AUTH_CONNECTION_OBSERVER_H |
| 7 | |
| 8 | #include "components/proximity_auth/connection.h" |
| 9 | |
| 10 | namespace proximity_auth { |
| 11 | |
| 12 | class WireMessage; |
| 13 | |
| 14 | // An interface for observing events that happen on a Connection. |
| 15 | class ConnectionObserver { |
| 16 | public: |
sacomoto | 4d303ae | 2015-09-18 11:11:21 | [diff] [blame] | 17 | virtual ~ConnectionObserver() {} |
| 18 | |
isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 19 | // Called when the |connection|'s status changes from |old_status| to |
isherman | fd7c534 | 2015-04-24 00:43:53 | [diff] [blame] | 20 | // |new_status|. The |connectoin| is guaranteed to be non-null. |
| 21 | virtual void OnConnectionStatusChanged(Connection* connection, |
isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 22 | Connection::Status old_status, |
isherman | 16aaea4 | 2014-10-14 23:17:34 | [diff] [blame] | 23 | Connection::Status new_status) {} |
isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 24 | |
| 25 | // Called when a |message| is received from a remote device over the |
| 26 | // |connection|. |
| 27 | virtual void OnMessageReceived(const Connection& connection, |
isherman | 16aaea4 | 2014-10-14 23:17:34 | [diff] [blame] | 28 | const WireMessage& message) {} |
isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 29 | |
| 30 | // Called after a |message| is sent to the remote device over the |
| 31 | // |connection|. |success| is |true| iff the message is sent successfully. |
| 32 | virtual void OnSendCompleted(const Connection& connection, |
| 33 | const WireMessage& message, |
isherman | 16aaea4 | 2014-10-14 23:17:34 | [diff] [blame] | 34 | bool success) {} |
isherman | 06c6a9a7 | 2014-09-10 05:48:21 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | } // namespace proximity_auth |
| 38 | |
| 39 | #endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_OBSERVER_H |