summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/automation_tab_tracker.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 04:27:05 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 04:27:05 +0000
commitdd5684a027e4a3b2d74cb9eeebfb039171008503 (patch)
treeb3013ab636f6fd3b86c335dd51f15e57ca35e9c3 /chrome/browser/automation/automation_tab_tracker.h
parent5d244865ed539d1bf8236fbda2b316d20a24231d (diff)
downloadchromium_src-dd5684a027e4a3b2d74cb9eeebfb039171008503.zip
chromium_src-dd5684a027e4a3b2d74cb9eeebfb039171008503.tar.gz
chromium_src-dd5684a027e4a3b2d74cb9eeebfb039171008503.tar.bz2
Change all classes that use the NOTIFY_NAV_ENTRY_COMMITTED notification to use the notification registrar. This is a speculative fix for a crash I happened to catch in a debugger where the pointer was invalid when dispatching this notifcation. It could be one of these consumers is leaking it's registered observer (the TabContents is the most suspicious one).
Review URL: http://codereview.chromium.org/16519 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_tab_tracker.h')
-rw-r--r--chrome/browser/automation/automation_tab_tracker.h42
1 files changed, 20 insertions, 22 deletions
diff --git a/chrome/browser/automation/automation_tab_tracker.h b/chrome/browser/automation/automation_tab_tracker.h
index 9e0c63c..1033ad0 100644
--- a/chrome/browser/automation/automation_tab_tracker.h
+++ b/chrome/browser/automation/automation_tab_tracker.h
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__
-#define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__
+#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_
+#define CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_
#include "chrome/browser/automation/automation_resource_tracker.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/navigation_controller.h"
+#include "chrome/common/notification_registrar.h"
class AutomationTabTracker
: public AutomationResourceTracker<NavigationController*> {
@@ -22,28 +23,24 @@ public:
virtual void AddObserver(NavigationController* resource) {
// This tab could either be a regular tab or an external tab
- // Register for both notifications
- NotificationService::current()->AddObserver(
- this, NOTIFY_TAB_CLOSING, Source<NavigationController>(resource));
- NotificationService::current()->AddObserver(
- this, NOTIFY_EXTERNAL_TAB_CLOSED,
- Source<NavigationController>(resource));
+ // Register for both notifications.
+ registrar_.Add(this, NOTIFY_TAB_CLOSING,
+ Source<NavigationController>(resource));
+ registrar_.Add(this, NOTIFY_EXTERNAL_TAB_CLOSED,
+ Source<NavigationController>(resource));
// We also want to know about navigations so we can keep track of the last
// navigation time.
- NotificationService::current()->AddObserver(
- this, NOTIFY_NAV_ENTRY_COMMITTED,
- Source<NavigationController>(resource));
+ registrar_.Add(this, NOTIFY_NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(resource));
}
virtual void RemoveObserver(NavigationController* resource) {
- NotificationService::current()->RemoveObserver(
- this, NOTIFY_TAB_CLOSING, Source<NavigationController>(resource));
- NotificationService::current()->RemoveObserver(
- this, NOTIFY_EXTERNAL_TAB_CLOSED,
- Source<NavigationController>(resource));
- NotificationService::current()->RemoveObserver(
- this, NOTIFY_NAV_ENTRY_COMMITTED,
- Source<NavigationController>(resource));
+ registrar_.Remove(this, NOTIFY_TAB_CLOSING,
+ Source<NavigationController>(resource));
+ registrar_.Remove(this, NOTIFY_EXTERNAL_TAB_CLOSED,
+ Source<NavigationController>(resource));
+ registrar_.Remove(this, NOTIFY_NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(resource));
}
virtual void Observe(NotificationType type,
@@ -80,11 +77,12 @@ public:
}
private:
+ NotificationRegistrar registrar_;
+
// Last time a navigation occurred.
- std::map<NavigationController*, base::Time> last_navigation_times_;
+ std::map<NavigationController*, base::Time> last_navigation_times_;
DISALLOW_COPY_AND_ASSIGN(AutomationTabTracker);
};
-#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H__
-
+#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_TAB_TRACKER_H_