Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: chrome/browser/prerender/prerender_tracker.h

Issue 11348357: Add observer interface to PrerenderContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_tracker.h
diff --git a/chrome/browser/prerender/prerender_tracker.h b/chrome/browser/prerender/prerender_tracker.h
index f4bc1088ec4faef8b36da6f930d2873417888059..95447b699e67ad925fefd487e3bc2b11b861b728 100644
--- a/chrome/browser/prerender/prerender_tracker.h
+++ b/chrome/browser/prerender/prerender_tracker.h
@@ -7,11 +7,13 @@
#include <map>
#include <set>
+#include <utility>
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/synchronization/lock.h"
#include "base/threading/non_thread_safe.h"
+#include "chrome/browser/prerender/prerender_contents.h"
#include "chrome/browser/prerender/prerender_final_status.h"
#include "googleurl/src/gurl.h"
@@ -23,10 +25,13 @@ 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 base::NonThreadSafe,
+ public PrerenderContents::Observer {
public:
PrerenderTracker();
- ~PrerenderTracker();
+ virtual ~PrerenderTracker();
+
+ void AddPrerenderContents(PrerenderContents* prerender_contents);
// Attempts to set the status of the specified RenderViewHost to
// FINAL_STATUS_USED. Returns true on success. Returns false if it has
@@ -83,13 +88,12 @@ class PrerenderTracker {
// 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,
- PrerenderManager* prerender_manager);
+ virtual void OnPrerenderStart(PrerenderContents* prerender_contents) OVERRIDE;
// Must be called when a RenderView stops prerendering, either because the
// RenderView was used or prerendering was cancelled and it is being
// destroyed.
- void OnPrerenderingFinished(int child_id, int route_id);
+ virtual void OnPrerenderStop(PrerenderContents* prerender_contents) OVERRIDE;
// Attempts to set the FinalStatus of the specified RenderView to
// |desired_final_status|. If non-NULL, |actual_final_status| is set to the
@@ -120,6 +124,10 @@ class PrerenderTracker {
static PrerenderTracker* GetDefault();
+ // Set of prerender_contents being observed by this tracker. Can only access
+ // on UI thread.
+ std::set<prerender::PrerenderContents*> observing_set_;
+
// |final_status_map_lock_| protects access to |final_status_map_|.
mutable base::Lock final_status_map_lock_;
// Map containing child/route id pairs and their final statuses. Must only be

Powered by Google App Engine
This is Rietveld 408576698