Chromium Code Reviews| 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 "blimp/net/helium/helium_result.h" | |
| 12 | |
| 13 namespace blimp { | |
| 14 | |
| 15 // Abstract interface for a HeliumStream factory. Subclasses can use this | |
| 16 // interface to encapsulate transport-specific stream connection semantics. | |
| 17 class HeliumTransport { | |
| 18 public: | |
| 19 // Callback invoked with the stream and result code of a Connect or Accept | |
| 20 // attempt. | |
| 21 // The HeliumStream is assumed to be authenticated and ready to use. | |
| 22 // If the connection attempt failed, the value of |stream| will be null and | |
| 23 // |result| will be set to the relevant error code. | |
| 24 using StreamCreatedCallback = | |
| 25 base::Callback<void(std::unique_ptr<HeliumStream> stream, | |
| 26 HeliumResult result)>; | |
| 27 | |
| 28 class Delegate { | |
| 29 public: | |
| 30 // Called when the transport transitions between an offline/unsuable state | |
| 31 // and an online/usable state. | |
| 32 virtual void OnAvailabilityChanged(bool available) = 0; | |
| 33 }; | |
| 34 | |
| 35 virtual void SetDelegate(std::unique_ptr<Delegate> delegate); | |
| 36 | |
| 37 // Asynchronously attempts to connect a new HeliumStream. | |
| 38 // Multiple overlapping connection attempts are permitted. | |
| 39 virtual void Connect(const StreamCreatedCallback& cb) = 0; | |
| 40 | |
| 41 // Accepts an incoming connection from the peer. | |
| 42 // Multiple overlapping Accept requests are permitted. | |
|
Garrett Casto
2016/10/05 20:34:05
Is there any reason why we would ever want to have
Kevin M
2016/10/05 23:57:58
Hmmm. I was thinking of erring on the side of flex
| |
| 43 virtual void Accept(const StreamCreatedCallback& cb) = 0; | |
|
perumaal
2016/10/05 20:40:44
There is no Accept in grpc land. Could we just hav
Garrett Casto
2016/10/05 20:53:07
Take a look at go/helium-transport. Short answer i
perumaal
2016/10/05 22:22:14
Discussed offline, this is ok for now. thanks!
Kevin M
2016/10/05 23:57:58
What Garrett said.
| |
| 44 | |
| 45 // Returns true if the underlying transport has the necessary resources | |
| 46 // and connectivity for Connect and Accept operations. | |
| 47 virtual bool IsAvailable() = 0; | |
| 48 }; | |
| 49 | |
| 50 } // namespace blimp | |
| 51 | |
| 52 #endif // BLIMP_NET_HELIUM_HELIUM_TRANSPORT_H_ | |
| OLD | NEW |