#ifndef NET_DISK_CACHE_SIMPLE_POST_OPERATION_WAITER_H_
#define NET_DISK_CACHE_SIMPLE_POST_OPERATION_WAITER_H_
#include <stdint.h>
#include <unordered_map>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/ref_counted.h"
#include "net/base/cache_type.h"
namespace disk_cache {
class SimplePostOperationWaiterTable
: public base::RefCounted<SimplePostOperationWaiterTable> {
friend class base::RefCounted<SimplePostOperationWaiterTable>;
public:
SimplePostOperationWaiterTable();
SimplePostOperationWaiterTable(const SimplePostOperationWaiterTable&) =
delete;
SimplePostOperationWaiterTable& operator=(
const SimplePostOperationWaiterTable&) = delete;
void OnOperationStart(uint64_t entry_hash);
void OnOperationComplete(uint64_t entry_hash);
std::vector<base::OnceClosure>* Find(uint64_t entry_hash);
bool Has(uint64_t entry_hash) {
return entries_pending_operation_.contains(entry_hash);
}
private:
~SimplePostOperationWaiterTable();
std::unordered_map<uint64_t, std::vector<base::OnceClosure>>
entries_pending_operation_;
};
}
#endif