blob: d9ae4a03db921ea921012de513570db91b9e7c5a [file] [log] [blame]
// 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.
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "blimp/common/blob_cache/blob_cache.h"
#include "blimp/net/blimp_message_processor.h"
#include "blimp/net/blimp_net_export.h"
namespace blimp {
class BlobCache;
class BLIMP_NET_EXPORT BlobChannelReceiver {
class Delegate {
virtual ~Delegate() {}
// Sets the Receiver object which will take incoming blobs.
virtual void SetReceiver(BlobChannelReceiver* receiver) = 0;
virtual ~BlobChannelReceiver() {}
// Constructs a BlobChannelReceiverImpl object for use.
static std::unique_ptr<BlobChannelReceiver> Create(
std::unique_ptr<BlobCache> cache,
std::unique_ptr<Delegate> delegate);
// Gets a blob from the BlobChannel.
// Returns nullptr if the blob is not available in the channel.
// Can be accessed concurrently from any thread. Calling code must ensure that
// the object instance outlives all calls to Get().
virtual BlobDataPtr Get(const BlobId& id) = 0;
// Called by Delegate::OnBlobReceived() when a blob arrives over the channel.
virtual void OnBlobReceived(const BlobId& id, BlobDataPtr data) = 0;
} // namespace blimp