summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 21:45:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 21:45:42 +0000
commit237e6d03c2c9371665dd9ff73407e0ae3f8c3ade (patch)
treef8d6d213207f68ab55e5339f2c0729904f318ccf /chrome/browser/history
parent47af65f00a6d9606b6d31a09e4562d59a83f2598 (diff)
downloadchromium_src-237e6d03c2c9371665dd9ff73407e0ae3f8c3ade.zip
chromium_src-237e6d03c2c9371665dd9ff73407e0ae3f8c3ade.tar.gz
chromium_src-237e6d03c2c9371665dd9ff73407e0ae3f8c3ade.tar.bz2
Attempt at fixing unit_test crash on mac bots. The main egregious
error I noticed is that ProfileManagerTest was leaking two history services. I don't know how this would cause the crash though. I also added the thread_ checks to HistoryService as it's possible for the HistoryService to be used after Cleanup (processing notifications). And I removed the registration of the listener in History() as it doesn't appear to be needed, and if needed results in listening to too much. BUG=61982 TEST=none Review URL: http://codereview.chromium.org/4534001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/history.cc16
-rw-r--r--chrome/browser/history/history.h3
2 files changed, 11 insertions, 8 deletions
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 3a5ae85..53a5420 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -129,11 +129,6 @@ HistoryService::HistoryService()
bookmark_service_(NULL),
no_db_(false),
needs_top_sites_migration_(false) {
- // Is NULL when running generate_profile.
- if (NotificationService::current()) {
- registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
- Source<Profile>(profile_));
- }
}
HistoryService::HistoryService(Profile* profile)
@@ -143,6 +138,7 @@ HistoryService::HistoryService(Profile* profile)
bookmark_service_(NULL),
no_db_(false),
needs_top_sites_migration_(false) {
+ DCHECK(profile_);
registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
Source<Profile>(profile_));
registrar_.Add(this, NotificationType::TEMPLATE_URL_REMOVED,
@@ -613,6 +609,9 @@ HistoryService::Handle HistoryService::QueryMostVisitedURLs(
void HistoryService::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
+ if (!thread_)
+ return;
+
switch (type.value) {
case NotificationType::HISTORY_URLS_DELETED: {
// Update the visited link system for deleted URLs. We will update the
@@ -745,6 +744,9 @@ void HistoryService::BroadcastNotifications(
if (!g_browser_process)
return;
+ if (!thread_)
+ return;
+
// The source of all of our notifications is the profile. Note that this
// pointer is NULL in unit tests.
Source<Profile> source(profile_);
@@ -781,7 +783,7 @@ void HistoryService::OnDBLoaded() {
NotificationService::current()->Notify(NotificationType::HISTORY_LOADED,
Source<Profile>(profile_),
Details<HistoryService>(this));
- if (profile_ && history::TopSites::IsEnabled()) {
+ if (thread_ && profile_ && history::TopSites::IsEnabled()) {
// We don't want to force creation of TopSites.
history::TopSites* ts = profile_->GetTopSitesWithoutCreating();
if (ts)
@@ -791,7 +793,7 @@ void HistoryService::OnDBLoaded() {
void HistoryService::StartTopSitesMigration() {
needs_top_sites_migration_ = true;
- if (history::TopSites::IsEnabled()) {
+ if (thread_ && profile_ && history::TopSites::IsEnabled()) {
// We don't want to force creation of TopSites.
history::TopSites* ts = profile_->GetTopSitesWithoutCreating();
if (ts)
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 2794565..2aa59ad 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -826,7 +826,8 @@ class HistoryService : public CancelableRequestProvider,
// when done. We use this internal consumer for this purpose.
CancelableRequestConsumer internal_consumer_;
- // The thread used by the history service to run complicated operations
+ // The thread used by the history service to run complicated operations.
+ // |thread_| is NULL once |Cleanup| is NULL.
base::Thread* thread_;
// This class has most of the implementation and runs on the 'thread_'.