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

Unified Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 12491017: Make WebDataService no longer depend on ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit. Created 7 years, 9 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/webdata/web_data_service_factory.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_data_service_factory.cc
diff --git a/chrome/browser/webdata/web_data_service_factory.cc b/chrome/browser/webdata/web_data_service_factory.cc
index 4d546197f55cae108140c7facb2bb8fa82a8f948..1064866b17121028dd33842d175ab42c66444b27 100644
--- a/chrome/browser/webdata/web_data_service_factory.cc
+++ b/chrome/browser/webdata/web_data_service_factory.cc
@@ -7,9 +7,29 @@
#include "base/files/file_path.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/webdata/autofill_web_data_service_impl.h"
-#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_constants.h"
+WebDataServiceWrapper::WebDataServiceWrapper() {}
+
+WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
+ base::FilePath path = profile->GetPath();
+ path = path.Append(chrome::kWebDataFilename);
+ web_data_service_ = new WebDataService();
+ web_data_service_->Init(path);
+}
+
+WebDataServiceWrapper::~WebDataServiceWrapper() {
+}
+
+void WebDataServiceWrapper::Shutdown() {
+ web_data_service_->ShutdownOnUIThread();
+ web_data_service_ = NULL;
+}
+
+scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
+ return web_data_service_.get();
+}
+
// static
scoped_ptr<AutofillWebDataService> AutofillWebDataService::FromBrowserContext(
content::BrowserContext* context) {
@@ -38,7 +58,7 @@ scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
}
WebDataServiceFactory::WebDataServiceFactory()
- : RefcountedProfileKeyedServiceFactory(
+ : ProfileKeyedServiceFactory(
"WebDataService",
ProfileDependencyManager::GetInstance()) {
// WebDataServiceFactory has no dependecies.
@@ -53,8 +73,13 @@ scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile(
// DCHECK, we need to start taking it as a parameter to
// AutofillWebDataServiceImpl::FromBrowserContext (see above).
DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
- return static_cast<WebDataService*>(
- GetInstance()->GetServiceForProfile(profile, true).get());
+ WebDataServiceWrapper* wrapper =
+ static_cast<WebDataServiceWrapper*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+ if (wrapper)
+ return wrapper->GetWebData();
+ // |wrapper| can be NULL in Incognito mode.
+ return NULL;
}
// static
@@ -64,8 +89,13 @@ scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists(
// DCHECK, we need to start taking it as a parameter to
// AutofillWebDataServiceImpl::FromBrowserContext (see above).
DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
- return static_cast<WebDataService*>(
- GetInstance()->GetServiceForProfile(profile, false).get());
+ WebDataServiceWrapper* wrapper =
+ static_cast<WebDataServiceWrapper*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+ if (wrapper)
+ return wrapper->GetWebData();
+ // |wrapper| can be NULL in Incognito mode.
+ return NULL;
}
// static
@@ -77,16 +107,9 @@ bool WebDataServiceFactory::ServiceRedirectedInIncognito() const {
return true;
}
-scoped_refptr<RefcountedProfileKeyedService>
+ProfileKeyedService*
WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
- DCHECK(profile);
-
- base::FilePath path = profile->GetPath();
- path = path.Append(chrome::kWebDataFilename);
-
- scoped_refptr<WebDataService> wds(new WebDataService());
- wds->Init(path);
- return wds.get();
+ return new WebDataServiceWrapper(profile);
}
bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698