summaryrefslogtreecommitdiffstats
path: root/chrome/test/testing_profile.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-24 18:35:49 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-24 18:35:49 +0000
commitd0742d72600ba1eb33aff7d0ed43c8a118dcd141 (patch)
tree7f06db3fb511be1fc590c8519a096b331cb9881d /chrome/test/testing_profile.cc
parent7ff65ca9f426a13726533d02f8edc6ce247064e2 (diff)
downloadchromium_src-d0742d72600ba1eb33aff7d0ed43c8a118dcd141.zip
chromium_src-d0742d72600ba1eb33aff7d0ed43c8a118dcd141.tar.gz
chromium_src-d0742d72600ba1eb33aff7d0ed43c8a118dcd141.tar.bz2
Refactors TopSites so that it's hopefully easier to maintain and
doesn't suffer the plethora of threading issues that exist with the current version. Here's the breakdown of what was refactored: . TopSitesCache: Contains the most visited urls and thumbnails. . TopSitesBackend: All mutations to topsites data end up calling into the backend on the UI thread. TopSitesBackend processes the method on the DB thread calling through to the TopSitesDatabase. . TopSites: uses two TopSitesCache. One that contains the raw history data, the other contains the processed data (pinned/blacklisted). The processed cache can be accessed on any thread. TopSites waits until history loads to know if it should migrate or use it's own db. I could probably make these execute in parallel, but for now this is how it works. This patch also makes it so the dom ui accesses the thumbnails on the IO thread. BUG=56382 TEST=Make sure all your thumbnails are correctly updated and you don't see problems. Review URL: http://codereview.chromium.org/3440018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/testing_profile.cc')
-rw-r--r--chrome/test/testing_profile.cc37
1 files changed, 28 insertions, 9 deletions
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 829fcc9..2b3624b 100644
--- a/chrome/test/testing_profile.cc
+++ b/chrome/test/testing_profile.cc
@@ -39,6 +39,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_pref_service.h"
+#include "chrome/test/ui_test_utils.h"
#include "net/base/cookie_monster.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_unittest.h"
@@ -194,13 +195,19 @@ TestingProfile::~TestingProfile() {
NotificationType::PROFILE_DESTROYED,
Source<Profile>(this),
NotificationService::NoDetails());
+ if (top_sites_.get()) {
+ top_sites_->Shutdown();
+ top_sites_ = NULL;
+ // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need
+ // to be run to properly shutdown. Run all pending tasks now. This is
+ // normally handled by browser_process shutdown.
+ if (MessageLoop::current())
+ MessageLoop::current()->RunAllPending();
+ }
DestroyHistoryService();
// FaviconService depends on HistoryServce so destroying it later.
DestroyFaviconService();
DestroyWebDataService();
- if (top_sites_.get())
- top_sites_->ClearProfile();
- history::TopSites::DeleteTopSites(top_sites_);
if (extensions_service_.get()) {
extensions_service_->DestroyingProfile();
extensions_service_ = NULL;
@@ -227,6 +234,17 @@ void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
history_service_->Init(GetPath(), bookmark_bar_model_.get(), no_db);
}
+void TestingProfile::CreateTopSites() {
+ if (top_sites_.get()) {
+ top_sites_->Shutdown();
+ top_sites_ = NULL;
+ }
+
+ top_sites_ = new history::TopSites(this);
+ FilePath file_name = temp_dir_.path().Append(chrome::kTopSitesFilename);
+ top_sites_->Init(file_name);
+}
+
void TestingProfile::DestroyFaviconService() {
if (!favicon_service_.get())
return;
@@ -303,6 +321,12 @@ void TestingProfile::BlockUntilBookmarkModelLoaded() {
DCHECK(bookmark_bar_model_->IsLoaded());
}
+void TestingProfile::BlockUntilTopSitesLoaded() {
+ if (!GetHistoryService(Profile::EXPLICIT_ACCESS))
+ GetTopSites()->HistoryLoaded();
+ ui_test_utils::WaitForNotification(NotificationType::TOP_SITES_LOADED);
+}
+
void TestingProfile::CreateTemplateURLFetcher() {
template_url_fetcher_.reset(new TemplateURLFetcher(this));
}
@@ -392,12 +416,7 @@ PrefService* TestingProfile::GetPrefs() {
}
history::TopSites* TestingProfile::GetTopSites() {
- if (!top_sites_.get()) {
- top_sites_ = new history::TopSites(this);
- FilePath file_name = temp_dir_.path().AppendASCII("TopSites.db");
- top_sites_->Init(file_name);
- }
- return top_sites_;
+ return top_sites_.get();
}
URLRequestContextGetter* TestingProfile::GetRequestContext() {