| 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..911b3bf72a292ef0854ceef92e68b8a7d86ca6ae 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/memory/weak_ptr.h"
|
| #include "base/synchronization/lock.h"
|
| #include "chrome/browser/prerender/prerender_final_status.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 {
|
| public:
|
| - // Returns the PrerenderTracker singleton.
|
| - static PrerenderTracker* GetInstance();
|
| + PrerenderTracker();
|
| + ~PrerenderTracker();
|
|
|
| // Attempts to set the status of the specified RenderViewHost to
|
| // FINAL_STATUS_USED. Returns true on success. Returns false if it has
|
| @@ -53,27 +52,20 @@ 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;
|
|
|
| + // 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;
|
| +
|
| protected:
|
| friend class PrerenderContents;
|
|
|
| - FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerUsed);
|
| - FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelled);
|
| - FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelledOnIO);
|
| - FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelledFast);
|
| - FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerMultiple);
|
| -
|
| // Must be called when a RenderView starts prerendering, before the first
|
| // navigation starts to avoid any races.
|
| void OnPrerenderingStarted(int child_id, int route_id,
|
| @@ -85,7 +77,20 @@ class PrerenderTracker {
|
| void OnPrerenderingFinished(int child_id, int route_id);
|
|
|
| private:
|
| - friend struct DefaultSingletonTraits<PrerenderTracker>;
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerNull);
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerUsed);
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelled);
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelledOnIO);
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerCancelledFast);
|
| + FRIEND_TEST_ALL_PREFIXES(PrerenderTrackerTest, PrerenderTrackerMultiple);
|
| +
|
| + struct RenderViewInfo {
|
| + explicit RenderViewInfo(PrerenderManager* prerender_manager);
|
| + ~RenderViewInfo();
|
| +
|
| + FinalStatus final_status;
|
| + base::WeakPtr<PrerenderManager> prerender_manager;
|
| + };
|
|
|
| typedef std::pair<int, int> ChildRouteIdPair;
|
|
|
| @@ -94,9 +99,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,
|
|
|