| 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_STREAM_H_ |
| 6 #define BLIMP_NET_HELIUM_HELIUM_STREAM_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 class HeliumMessage; |
| 16 |
| 17 // Pure virtual interface for HeliumMessage-oriented transport streams. |
| 18 // Details about how the HeliumStream is bound to the network layer are handled |
| 19 // by subclasses of HeliumStream. |
| 20 class HeliumStream { |
| 21 public: |
| 22 using ReceiveMessageCallback = |
| 23 base::Callback<void(std::unique_ptr<HeliumMessage>, HeliumResult)>; |
| 24 |
| 25 virtual ~HeliumStream() = default; |
| 26 |
| 27 // Sends |helium_message| over the Stream. |callback| is invoked when the |
| 28 // message is sent (or otherwise moved to the low-level write buffers), |
| 29 // which signals the caller that it is clear to send another message. |
| 30 // |
| 31 // The caller is responsible for ensuring that only one outstanding |
| 32 // SendMessage() call is made at a time. |
| 33 virtual void SendMessage( |
| 34 std::unique_ptr<HeliumMessage> helium_message, |
| 35 const base::Callback<void(HeliumResult)>& callback) = 0; |
| 36 |
| 37 // Asynchronously reads a HeliumMessage from the stream. |
| 38 // The caller is responsible for ensuring that only one outstanding |
| 39 // ReceiveMessage() call is made at a time. |
| 40 // |
| 41 // In the event that an error occurred, a null pointer will be passed instead |
| 42 // of a HeliumMessage, with a HeliumResult describing the failure reason. |
| 43 // The HeliumStream object is considered inactive/unusable at this point and |
| 44 // should be discarded by its owner. |
| 45 virtual void ReceiveMessage(const ReceiveMessageCallback& on_receive_cb) = 0; |
| 46 }; |
| 47 |
| 48 } // namespace blimp |
| 49 |
| 50 #endif // BLIMP_NET_HELIUM_HELIUM_STREAM_H_ |
| OLD | NEW |