#ifndef EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_
#define EXTENSIONS_BROWSER_CONTENT_HASH_FETCHER_H_
#include <map>
#include <set>
#include <string>
#include <utility>
#include "base/functional/callback.h"
#include "base/sequence_checker.h"
#include "extensions/browser/content_verifier/content_hash.h"
#include "extensions/common/extension_id.h"
namespace base {
class SequencedTaskRunner;
}
namespace network {
class SimpleURLLoader;
}
namespace extensions {
namespace internals {
class ContentHashFetcher {
public:
using HashFetcherCallback =
base::OnceCallback<void(ContentHash::FetchKey,
std::unique_ptr<std::string>,
ContentHash::FetchErrorCode)>;
ContentHashFetcher(ContentHash::FetchKey fetch_key);
ContentHashFetcher(const ContentHashFetcher&) = delete;
ContentHashFetcher& operator=(const ContentHashFetcher&) = delete;
void Start(HashFetcherCallback hash_fetcher_callback);
private:
friend class base::RefCounted<ContentHashFetcher>;
~ContentHashFetcher();
void OnSimpleLoaderComplete(std::unique_ptr<std::string> response_body);
ContentHash::FetchKey fetch_key_;
HashFetcherCallback hash_fetcher_callback_;
scoped_refptr<base::SequencedTaskRunner> response_task_runner_;
std::unique_ptr<network::SimpleURLLoader> simple_loader_;
SEQUENCE_CHECKER(sequence_checker_);
};
}
}
#endif