| Index: chrome/browser/prerender/prerender_tracker.h
|
| diff --git a/chrome/browser/prerender/prerender_tracker.h b/chrome/browser/prerender/prerender_tracker.h
|
| index f2630520c12ce1359013f12e3d4a86fd085ee46c..284a9210a628ffda248188aeff3f90718469ea1f 100644
|
| --- a/chrome/browser/prerender/prerender_tracker.h
|
| +++ b/chrome/browser/prerender/prerender_tracker.h
|
| @@ -9,22 +9,21 @@
|
| #include <map>
|
| #include <set>
|
|
|
| -#include "base/memory/singleton.h"
|
| #include "base/synchronization/lock.h"
|
| #include "chrome/browser/prerender/prerender_final_status.h"
|
| +#include "content/browser/renderer_host/resource_dispatcher_host.h"
|
|
|
| namespace prerender {
|
|
|
| class PrerenderManager;
|
| -struct RenderViewInfo;
|
|
|
| // PrerenderTracker is responsible for keeping track of all prerendering
|
| // RenderViews and their statuses. Its list is guaranteed to be up to date
|
| // and can be modified on any thread.
|
| -class PrerenderTracker {
|
| +class PrerenderTracker : public ResourceDispatcherHost::Observer {
|
| public:
|
| - // Returns the PrerenderTracker singleton.
|
| - static PrerenderTracker* GetInstance();
|
| + PrerenderTracker();
|
| + virtual ~PrerenderTracker();
|
|
|
| // Attempts to set the status of the specified RenderViewHost to
|
| // FINAL_STATUS_USED. Returns true on success. Returns false if it has
|
| @@ -53,18 +52,22 @@ class PrerenderTracker {
|
| bool TryCancelOnIOThread(int child_id, int route_id,
|
| FinalStatus final_status);
|
|
|
| - // Returns whether or not a RenderView is prerendering. Can only be called on
|
| - // the IO thread. Does not acquire a lock, so may claim a RenderView that has
|
| - // been displayed or destroyed is still prerendering.
|
| - // TODO(mmenke): Remove external use of this method and make it private.
|
| - bool IsPrerenderingOnIOThread(int child_id, int route_id) const;
|
| -
|
| // Gets the FinalStatus of the specified prerendered RenderView. Returns
|
| // |true| and sets |final_status| to the status of the RenderView if it
|
| // is found, returns false otherwise.
|
| bool GetFinalStatus(int child_id, int route_id,
|
| FinalStatus* final_status) const;
|
|
|
| + // ResourceDispatcherHost::Observer implementation.
|
| + virtual bool ShouldBeginRequest(
|
| + int child_id, int route_id,
|
| + const ResourceHostMsg_Request& request_data,
|
| + const content::ResourceContext& resource_context,
|
| + const GURL& referrer) OVERRIDE;
|
| +
|
| + virtual void MutateLoadFlags(int child_id, int route_id,
|
| + int* load_flags) OVERRIDE;
|
| +
|
| protected:
|
| friend class PrerenderContents;
|
|
|
| @@ -85,7 +88,13 @@ class PrerenderTracker {
|
| void OnPrerenderingFinished(int child_id, int route_id);
|
|
|
| private:
|
| - friend struct DefaultSingletonTraits<PrerenderTracker>;
|
| + struct RenderViewInfo {
|
| + explicit RenderViewInfo(PrerenderManager* prerender_manager);
|
| + ~RenderViewInfo();
|
| +
|
| + FinalStatus final_status;
|
| + base::WeakPtr<PrerenderManager> prerender_manager;
|
| + };
|
|
|
| typedef std::pair<int, int> ChildRouteIdPair;
|
|
|
| @@ -94,9 +103,6 @@ class PrerenderTracker {
|
| // Set of child/route id pairs that may be prerendering.
|
| typedef std::set<ChildRouteIdPair> PossiblyPrerenderingChildRouteIdPairs;
|
|
|
| - PrerenderTracker();
|
| - ~PrerenderTracker();
|
| -
|
| // Attempts to set the FinalStatus of the specified RenderView to
|
| // |final_status|. If the FinalStatus of the RenderView has already been
|
| // set, does nothing. Returns the resulting FinalStatus of that RenderView,
|
| @@ -110,6 +116,11 @@ class PrerenderTracker {
|
| void AddPrerenderOnIOThread(const ChildRouteIdPair& child_route_id_pair);
|
| void RemovePrerenderOnIOThread(const ChildRouteIdPair& child_route_id_pair);
|
|
|
| + // Returns whether or not a RenderView is prerendering. Can only be called on
|
| + // the IO thread. Does not acquire a lock, so may claim a RenderView that has
|
| + // been displayed or destroyed is still prerendering.
|
| + bool IsPrerenderingOnIOThread(int child_id, int route_id) const;
|
| +
|
| // Tasks posted to the IO Thread to call the above functions.
|
| static void AddPrerenderOnIOThreadTask(
|
| const ChildRouteIdPair& child_route_id_pair);
|
|
|