diff options
author | skrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-29 19:12:41 +0000 |
---|---|---|
committer | skrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-29 19:12:41 +0000 |
commit | f0185941daa7ec11b8521b0a5e2fd710a42612ac (patch) | |
tree | f2289866b3d12b753377074230f5487e1a33e1bf /chrome/browser/search_engines | |
parent | 0973d960eed1ca6d852e0b4fb9acdfcf2db3adee (diff) | |
download | chromium_src-f0185941daa7ec11b8521b0a5e2fd710a42612ac.zip chromium_src-f0185941daa7ec11b8521b0a5e2fd710a42612ac.tar.gz chromium_src-f0185941daa7ec11b8521b0a5e2fd710a42612ac.tar.bz2 |
Change WDS to use the DB thread rather than its own thread.
This cleanup was requested by brettw and was started to make it easier for the sync service to post tasks to the WDS thread (now the DB thread). This simplifies the WDS a bit since it no longer has to manage its own thread, and can assume that the DB thread is running throughout its lifetime.
One change in behavior that is significant is that previous to this change, the WDS worker thread would always be joined when Shutdown() was called from Profile::~Profile(). Now the Shutdown() method schedules a task that can extend the lifetime of the WDS past the lifetime of the Profile instance.
Review URL: http://codereview.chromium.org/524003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines')
-rw-r--r-- | chrome/browser/search_engines/template_url_model_unittest.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_model_unittest.cc index 1c50fc1..7218951 100644 --- a/chrome/browser/search_engines/template_url_model_unittest.cc +++ b/chrome/browser/search_engines/template_url_model_unittest.cc @@ -4,6 +4,7 @@ #include "base/path_service.h" #include "base/thread.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/webdata/web_database.h" #include "chrome/test/testing_profile.h" @@ -34,6 +35,9 @@ class TemplateURLModelTestingProfile : public TestingProfile { TemplateURLModelTestingProfile() : TestingProfile() {} void SetUp() { + db_thread_.reset(new ChromeThread(ChromeThread::DB)); + db_thread_->Start(); + // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); test_dir_ = test_dir_.AppendASCII("TemplateURLModelTest"); @@ -50,6 +54,11 @@ class TemplateURLModelTestingProfile : public TestingProfile { void TearDown() { // Clean up the test directory. service_->Shutdown(); + // Note that we must ensure the DB thread is stopped after WDS + // shutdown (so it can commit pending transactions) but before + // deleting the test profile directory, otherwise we may not be + // able to delete it due to an open transaction. + db_thread_->Stop(); ASSERT_TRUE(file_util::Delete(test_dir_, true)); ASSERT_FALSE(file_util::PathExists(test_dir_)); } @@ -61,6 +70,7 @@ class TemplateURLModelTestingProfile : public TestingProfile { private: scoped_refptr<WebDataService> service_; FilePath test_dir_; + scoped_ptr<ChromeThread> db_thread_; }; // Trivial subclass of TemplateURLModel that records the last invocation of @@ -142,10 +152,9 @@ class TemplateURLModelTest : public testing::Test, // Blocks the caller until the service has finished servicing all pending // requests. void BlockTillServiceProcessesRequests() { - // Schedule a task on the background thread that is processed after all - // pending requests on the background thread. - profile_->GetWebDataService(Profile::EXPLICIT_ACCESS)->thread()-> - message_loop()->PostTask(FROM_HERE, new QuitTask2()); + // Schedule a task on the DB thread that is processed after all + // pending requests on the DB thread. + ChromeThread::PostTask(ChromeThread::DB, FROM_HERE, new QuitTask2()); // Run the current message loop. QuitTask2, when run, invokes Quit, // which unblocks this. MessageLoop::current()->Run(); @@ -756,4 +765,3 @@ TEST_F(TemplateURLModelTest, FailedInit) { ASSERT_TRUE(model_->GetDefaultSearchProvider()); } - |