Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ | 5 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ |
| 6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ | 6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 namespace blimp { | 12 namespace blimp { |
| 12 | 13 |
| 13 // Interfaces for attaching transport-specific implementations to BlobChannel | 14 // Interfaces for attaching transport-specific implementations to BlobChannel |
| 14 // operations. The caller is responsible for handling call deduplication; | 15 // operations. The caller is responsible for handling call deduplication; |
| 15 // bindings objects simply execute the command. | 16 // bindings objects simply execute the command. |
| 16 | 17 |
| 17 class BlobSenderBindings { | 18 class BlobSenderBindings { |
| 18 public: | 19 public: |
| 19 // Send blob |id| with payload |data| to the receiver. | 20 // Send blob |id| with payload |data| to the receiver. |
| 20 virtual void Send(const std::string& id, | 21 virtual void Send(const std::string& id, |
| 21 const std::vector<uint8_t>& data) = 0; | 22 const std::vector<uint8_t>& data) = 0; |
| 22 }; | 23 }; |
| 23 | 24 |
| 25 class BlobReceiverBindings { | |
| 26 public: | |
| 27 class Delegate { | |
|
Wez
2016/04/15 17:27:43
Why is this callback wrapped in a class and called
Kevin M
2016/04/15 23:53:43
The delegate dispatches events for a single client
| |
| 28 public: | |
| 29 // Invoked when a blob arrives asynchronously. | |
| 30 virtual void OnBlobReceived(const std::string& id, | |
| 31 std::unique_ptr<std::vector<uint8_t>> data) = 0; | |
| 32 }; | |
| 33 | |
| 34 // Requests the blob |id| from the sender. The delegate method | |
| 35 // OnBlobReceived() is triggered if and when the blob arrives. | |
| 36 virtual void Get(const std::string& id) = 0; | |
| 37 | |
| 38 virtual void SetDelegate(Delegate* delegate) = 0; | |
| 39 }; | |
| 40 | |
| 24 } // namespace blimp | 41 } // namespace blimp |
| 25 | 42 |
| 26 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ | 43 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_BINDINGS_H_ |
| OLD | NEW |