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

Unified Diff: chrome/browser/search_engines/template_url_service_test_util.cc

Issue 16154031: Un-refcount AutofillWebData and TokenWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 years, 6 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
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/browser/signin/token_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_service_test_util.cc
diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
index 34894ab0a29a0a1a8db1f1caeb924ae446976c0b..d5bfdcf2f7a962a5f9d4a78f7d8cf93bd41d14c5 100644
--- a/chrome/browser/search_engines/template_url_service_test_util.cc
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc
@@ -19,6 +19,8 @@
#include "chrome/test/automation/value_conversion_util.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/webdata/common/web_data_service_test_util.h"
+#include "components/webdata/common/web_database_service.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -54,6 +56,32 @@ static void WaitForThreadToProcessRequests(BrowserThread::ID identifier) {
} // namespace
+class MockWebDataServiceWrapperDB : public MockWebDataServiceWrapper {
+ public:
+ static BrowserContextKeyedService* Build(content::BrowserContext* profile) {
+ return new MockWebDataServiceWrapperDB(static_cast<Profile*>(profile));
+ }
+
+ explicit MockWebDataServiceWrapperDB(Profile* profile)
+ : MockWebDataServiceWrapper(NULL, NULL, NULL) {
+ base::FilePath profile_path = profile->GetPath();
+ base::FilePath path = profile_path.AppendASCII("TestWebDB");
+ web_database_ = new WebDatabaseService(path);
+ web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable()));
+ fake_web_data_ = new WebDataService(
+ web_database_, WebDataServiceBase::ProfileErrorCallback());
+ fake_web_data_->Init();
+ }
+
+ virtual void Shutdown() OVERRIDE {
+ fake_web_data_->ShutdownDatabase();
+ }
+
+ private:
+ scoped_refptr<WebDatabaseService> web_database_;
+ DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapperDB);
+};
+
// Trivial subclass of TemplateURLService that records the last invocation of
// SetKeywordSearchTermsForURL.
class TestingTemplateURLService : public TemplateURLService {
@@ -100,7 +128,9 @@ void TemplateURLServiceTestUtil::SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
profile_.reset(new TestingProfile(temp_dir_.path()));
db_thread_.Start();
- profile_->CreateWebDataService();
+
+ WebDataServiceFactory::GetInstance()->SetTestingFactory(
+ profile_.get(), MockWebDataServiceWrapperDB::Build);
TemplateURLService* service = static_cast<TemplateURLService*>(
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/browser/signin/token_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698