Skip to content

Commit

Permalink
Add a callback to FetchTask API.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696947943
  • Loading branch information
vasilvv authored and copybara-github committed Nov 15, 2024
1 parent 19bed52 commit 01046c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions quiche/quic/moqt/moqt_failed_fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class MoqtFailedFetch : public MoqtFetchTask {
return kError;
}
absl::Status GetStatus() override { return status_; }
void SetObjectAvailableCallback(
ObjectsAvailableCallback /*callback*/) override {}

private:
absl::Status status_;
Expand Down
6 changes: 6 additions & 0 deletions quiche/quic/moqt/moqt_outgoing_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class MoqtOutgoingQueue : public MoqtTrackPublisher {
GetNextObjectResult GetNextObject(PublishedObject&) override;
absl::Status GetStatus() override { return status_; }

void SetObjectAvailableCallback(
ObjectsAvailableCallback /*callback*/) override {
// Not needed since all objects in a fetch against an in-memory queue are
// guaranteed to resolve immediately.
}

private:
GetNextObjectResult GetNextObjectInner(PublishedObject&);

Expand Down
9 changes: 9 additions & 0 deletions quiche/quic/moqt/moqt_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "quiche/quic/moqt/moqt_messages.h"
#include "quiche/quic/moqt/moqt_priority.h"
#include "quiche/common/platform/api/quiche_mem_slice.h"
#include "quiche/common/quiche_callbacks.h"

namespace moqt {

Expand Down Expand Up @@ -47,6 +48,8 @@ class MoqtObjectListener {
// cancelled by deleting the object.
class MoqtFetchTask {
public:
using ObjectsAvailableCallback = quiche::MultiUseCallback<void()>;

virtual ~MoqtFetchTask() = default;

// Potential results of a GetNextObject() call.
Expand All @@ -65,6 +68,12 @@ class MoqtFetchTask {
// Returns the next object received via the fetch, if available.
virtual GetNextObjectResult GetNextObject(PublishedObject& output) = 0;

// Sets the callback that is called when GetNextObject() has previously
// returned kPending, but now a new object (or potentially an error or an
// end-of-fetch) is available.
virtual void SetObjectAvailableCallback(
ObjectsAvailableCallback callback) = 0;

// Returns the error if fetch has completely failed, and OK otherwise.
virtual absl::Status GetStatus() = 0;

Expand Down

0 comments on commit 01046c6

Please sign in to comment.