#ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
#define CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
#include <map>
#include <utility>
#include "base/memory/weak_ptr.h"
#include "url/gurl.h"
namespace prerender {
class PrerenderPendingSwapThrottle;
class PrerenderTracker {
public:
typedef std::pair<int, int> ChildRouteIdPair;
PrerenderTracker();
virtual ~PrerenderTracker();
bool IsPendingSwapRequestOnIOThread(int render_process_id,
int render_frame_id,
const GURL& url) const;
void AddPendingSwapThrottleOnIOThread(
int render_process_id, int render_frame_id, const GURL& url,
const base::WeakPtr<PrerenderPendingSwapThrottle>& throttle);
void AddPrerenderPendingSwap(
const ChildRouteIdPair& render_frame_route_id_pair,
const GURL& url);
void RemovePrerenderPendingSwap(
const ChildRouteIdPair& render_frame_route_id_pair,
bool swap_successful);
private:
void AddPrerenderPendingSwapOnIOThread(
const ChildRouteIdPair& render_frame_route_id_pair, const GURL& url);
void RemovePrerenderPendingSwapOnIOThread(
const ChildRouteIdPair& render_frame_route_id_pair,
bool swap_successful);
struct PendingSwapThrottleData {
explicit PendingSwapThrottleData(const GURL& swap_url);
~PendingSwapThrottleData();
GURL url;
base::WeakPtr<PrerenderPendingSwapThrottle> throttle;
};
typedef std::map<ChildRouteIdPair, PendingSwapThrottleData>
PendingSwapThrottleMap;
PendingSwapThrottleMap pending_swap_throttle_map_;
DISALLOW_COPY_AND_ASSIGN(PrerenderTracker);
};
}
#endif