| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |
| 6 #define BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/cancelable_callback.h" |
| 12 #include "blimp/net/helium/helium_result.h" |
| 13 |
| 14 namespace blimp { |
| 15 |
| 16 // Pure virtual interface for a HeliumStream factory. Subclasses can use this |
| 17 // interface to encapsulate transport-specific stream connection semantics. |
| 18 class HeliumTransport { |
| 19 public: |
| 20 // Callback invoked with the stream and result code of a Connect or Accept |
| 21 // attempt. |
| 22 // The HeliumStream is assumed to be authenticated and ready to use. |
| 23 // If the connection attempt failed, the value of |stream| will be null and |
| 24 // |result| will be set to the relevant error code. |
| 25 using StreamCreatedCallback = |
| 26 base::CancelableCallback<void(std::unique_ptr<HeliumStream> stream, |
| 27 HeliumResult result)>; |
| 28 |
| 29 // Callback to be invoked when the underlying transport transitions |
| 30 // between an offline/unusable state and an online/usable state. |
| 31 using AvailabilityChangedCallback = base::Callback<void(bool)>; |
| 32 |
| 33 virtual void SetAvailabilityChangedCallback( |
| 34 const AvailabilityChangedCallback& callback); |
| 35 |
| 36 // Asynchronously attempts to connect a new HeliumStream. |
| 37 // Multiple overlapping connection attempts are permitted. |
| 38 // The caller can cancel |cb| if it no longer needs the stream. |
| 39 virtual void Connect(const StreamCreatedCallback& cb) = 0; |
| 40 |
| 41 // Accepts an incoming connection from the peer. |
| 42 virtual void Accept(const StreamCreatedCallback& cb) = 0; |
| 43 |
| 44 // Returns true if the underlying transport has the necessary resources |
| 45 // and connectivity for Connect and Accept operations. |
| 46 virtual bool IsAvailable() = 0; |
| 47 }; |
| 48 |
| 49 } // namespace blimp |
| 50 |
| 51 #endif // BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |
| OLD | NEW |