Chromium Code Reviews| Index: blimp/net/helium/helium_transport.h |
| diff --git a/blimp/net/helium/helium_transport.h b/blimp/net/helium/helium_transport.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c7e3f3b1e76302dadbd4968a0119e58d7f6adf84 |
| --- /dev/null |
| +++ b/blimp/net/helium/helium_transport.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |
| +#define BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/callback.h" |
| +#include "blimp/net/helium/helium_result.h" |
| + |
| +namespace blimp { |
| + |
| +// Abstract interface for a HeliumStream factory. Subclasses can use this |
| +// interface to encapsulate transport-specific stream connection semantics. |
| +class HeliumTransport { |
| + public: |
| + // Callback invoked with the stream and result code of a Connect or Accept |
| + // attempt. |
| + // The HeliumStream is assumed to be authenticated and ready to use. |
| + // If the connection attempt failed, the value of |stream| will be null and |
| + // |result| will be set to the relevant error code. |
| + using StreamCreatedCallback = |
| + base::Callback<void(std::unique_ptr<HeliumStream> stream, |
| + HeliumResult result)>; |
| + |
| + class Delegate { |
| + public: |
| + // Called when the transport transitions between an offline/unusable state |
| + // and an online/usable state. |
| + virtual void OnAvailabilityChanged(bool available) = 0; |
|
Wez
2016/10/08 01:02:29
nit: Since this has only a single method right now
Kevin M
2016/10/11 20:02:37
Done.
|
| + }; |
| + |
| + virtual void SetDelegate(std::unique_ptr<Delegate> delegate); |
| + |
| + // Asynchronously attempts to connect a new HeliumStream. |
| + // Multiple overlapping connection attempts are permitted. |
| + virtual void Connect(const StreamCreatedCallback& cb) = 0; |
|
Wez
2016/10/08 01:02:29
As discussed previously, I think we need a way to
Kevin M
2016/10/11 20:02:37
I switched to CancelableCallback. The Stream that
|
| + |
| + // Accepts an incoming connection from the peer. |
| + // Only one Accept() call may be issued at a time. |
|
Wez
2016/10/08 01:02:30
Do we need that restriction, really? We could make
Kevin M
2016/10/11 20:02:37
Done.
|
| + virtual void Accept(const StreamCreatedCallback& cb) = 0; |
| + |
| + // Returns true if the underlying transport has the necessary resources |
| + // and connectivity for Connect and Accept operations. |
| + virtual bool IsAvailable() = 0; |
|
Wez
2016/10/08 01:02:29
nit: Do we need both a notification *and* this?
Kevin M
2016/10/11 20:02:37
I think it's useful for querying the initial conne
|
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ |