#ifndef CHROME_BROWSER_FEED_WEB_FEED_PAGE_INFORMATION_FETCHER_H_
#define CHROME_BROWSER_FEED_WEB_FEED_PAGE_INFORMATION_FETCHER_H_
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_functions.h"
#include "components/feed/core/v2/public/types.h"
namespace content {
class WebContents;
}
namespace feed {
class WebFeedPageInformationFetcher
: public base::RefCounted<WebFeedPageInformationFetcher> {
public:
struct PageInformation {
GURL url;
raw_ptr<content::WebContents> web_contents = nullptr;
};
static void Start(const PageInformation& page_info,
const WebFeedPageInformationRequestReason reason,
base::OnceCallback<void(WebFeedPageInformation)> callback);
WebFeedPageInformationFetcher(
const PageInformation& initial_page_info,
base::OnceCallback<void(WebFeedPageInformation)> callback);
private:
friend class base::RefCounted<WebFeedPageInformationFetcher>;
~WebFeedPageInformationFetcher();
void CallCallbackIfReady();
void OnCanonicalUrlFetched(const std::optional<::GURL>& url);
void OnRssFetched(std::vector<GURL> rss_urls);
WebFeedPageInformation page_info_;
base::OnceCallback<void(WebFeedPageInformation)> callback_;
bool rss_fetched_ = false;
bool url_fetched_ = false;
};
}
#endif