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

Unified Diff: content/browser/tab_contents/tab_contents_observer.cc

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months 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: content/browser/tab_contents/tab_contents_observer.cc
===================================================================
--- content/browser/tab_contents/tab_contents_observer.cc (revision 80315)
+++ content/browser/tab_contents/tab_contents_observer.cc (working copy)
@@ -7,6 +7,24 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
+TabContentsObserver::Registrar::Registrar(TabContentsObserver* observer)
+ : observer_(observer), tab_(NULL) {
+}
+
+TabContentsObserver::Registrar::~Registrar() {
+ if (tab_)
+ tab_->RemoveObserver(observer_);
+}
+
+void TabContentsObserver::Registrar::Observe(TabContents* tab) {
+ observer_->SetTabContents(tab);
+ if (tab_)
+ tab_->RemoveObserver(observer_);
+ tab_ = tab;
+ if (tab_)
+ tab_->AddObserver(observer_);
+}
+
void TabContentsObserver::NavigateToPendingEntry() {
}
@@ -35,12 +53,15 @@
void TabContentsObserver::StopNavigation() {
}
-TabContentsObserver::TabContentsObserver(TabContents* tab_contents)
- : tab_contents_(tab_contents),
- routing_id_(tab_contents->render_view_host()->routing_id()) {
+TabContentsObserver::TabContentsObserver(TabContents* tab_contents) {
+ SetTabContents(tab_contents);
tab_contents_->AddObserver(this);
}
+TabContentsObserver::TabContentsObserver()
+ : tab_contents_(NULL), routing_id_(MSG_ROUTING_NONE) {
+}
+
TabContentsObserver::~TabContentsObserver() {
if (tab_contents_)
tab_contents_->RemoveObserver(this);
@@ -62,6 +83,12 @@
return tab_contents_->render_view_host()->Send(message);
}
+void TabContentsObserver::SetTabContents(TabContents* tab_contents) {
+ tab_contents_ = tab_contents;
+ if (tab_contents_)
+ routing_id_ = tab_contents->render_view_host()->routing_id();
+}
+
void TabContentsObserver::TabContentsDestroyed() {
// Do cleanup so that 'this' can safely be deleted from
// OnTabContentsDestroyed.

Powered by Google App Engine
This is Rietveld 408576698