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

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

Issue 11348357: Add observer interface to PrerenderContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediation 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_contents.h
diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h
index 8db24c7e6735c6abd795968666a6354eda771629..b41e02c4a27bc67a930e9d62de1c5cf4384679c8 100644
--- a/chrome/browser/prerender/prerender_contents.h
+++ b/chrome/browser/prerender/prerender_contents.h
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/prerender/prerender_final_status.h"
@@ -45,7 +46,6 @@ namespace prerender {
class PrerenderHandle;
class PrerenderManager;
class PrerenderRenderViewHostObserver;
-class PrerenderTracker;
class PrerenderContents : public content::NotificationObserver,
public content::WebContentsObserver {
@@ -61,7 +61,6 @@ class PrerenderContents : public content::NotificationObserver,
// prerender_tracker, and profile are stored as weak pointers.
virtual PrerenderContents* CreatePrerenderContents(
PrerenderManager* prerender_manager,
- PrerenderTracker* prerender_tracker,
Profile* profile,
const GURL& url,
const content::Referrer& referrer,
@@ -72,6 +71,19 @@ class PrerenderContents : public content::NotificationObserver,
DISALLOW_COPY_AND_ASSIGN(Factory);
};
+ class Observer {
+ public:
+ // Signals that the prerender has started running.
+ virtual void OnPrerenderStart(PrerenderContents* contents) = 0;
+
+ // Signals that the prerender has stopped running.
+ virtual void OnPrerenderStop(PrerenderContents* contents) = 0;
+
+ protected:
+ Observer();
+ virtual ~Observer() = 0;
+ };
+
// A container for extra data on pending prerenders.
struct PendingPrerenderInfo {
public:
@@ -116,6 +128,10 @@ class PrerenderContents : public content::NotificationObserver,
virtual ~PrerenderContents();
+ // All observers of a PrerenderContents are removed after the OnPrerenderStop
+ // event is sent, so there is no need for a RemoveObserver() method.
+ void AddObserver(Observer* observer);
+
// For MatchComplete correctness, create a dummy replacement prerender
// contents to stand in for this prerender contents that (which we are about
// to destroy).
@@ -137,8 +153,7 @@ class PrerenderContents : public content::NotificationObserver,
virtual void StartPrerendering(
int creator_child_id,
const gfx::Size& size,
- content::SessionStorageNamespace* session_storage_namespace,
- bool is_control_group);
+ content::SessionStorageNamespace* session_storage_namespace);
// Verifies that the prerendering is not using too many resources, and kills
// it if not.
@@ -147,6 +162,8 @@ class PrerenderContents : public content::NotificationObserver,
content::RenderViewHost* GetRenderViewHostMutable();
const content::RenderViewHost* GetRenderViewHost() const;
+ PrerenderManager* prerender_manager() { return prerender_manager_; }
+
string16 title() const { return title_; }
int32 page_id() const { return page_id_; }
GURL icon_url() const { return icon_url_; }
@@ -173,7 +190,7 @@ class PrerenderContents : public content::NotificationObserver,
// Set the final status for how the PrerenderContents was used. This
// should only be called once, and should be called before the prerender
// contents are destroyed.
- void set_final_status(FinalStatus final_status);
+ void SetFinalStatus(FinalStatus final_status);
FinalStatus final_status() const { return final_status_; }
Origin origin() const { return origin_; }
@@ -256,13 +273,16 @@ class PrerenderContents : public content::NotificationObserver,
protected:
PrerenderContents(PrerenderManager* prerender_manager,
- PrerenderTracker* prerender_tracker,
Profile* profile,
const GURL& url,
const content::Referrer& referrer,
Origin origin,
uint8 experiment_id);
+ // These call out to methods on our Observers, using our observer_list_.
mmenke 2012/12/07 19:21:17 Think it's worth mentioning again that NotifyPrere
gavinp 2012/12/08 17:27:48 Done.
+ void NotifyPrerenderStart();
+ void NotifyPrerenderStop();
+
// Called whenever a RenderViewHost is created for prerendering. Only called
// once the RenderViewHost has a RenderView and RenderWidgetHostView.
virtual void OnRenderViewHostCreated(
@@ -302,12 +322,11 @@ class PrerenderContents : public content::NotificationObserver,
// Returns the ProcessMetrics for the render process, if it exists.
base::ProcessMetrics* MaybeGetProcessMetrics();
+ ObserverList<Observer> observer_list_;
+
// The prerender manager owning this object.
PrerenderManager* prerender_manager_;
- // The prerender tracker tracking prerenders.
- PrerenderTracker* prerender_tracker_;
-
// The URL being prerendered.
GURL prerender_url_;

Powered by Google App Engine
This is Rietveld 408576698