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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile Created 8 years, 8 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..dcb6fa45a1676cb0eed9189585f4a23799947247
--- /dev/null
+++ b/chrome/browser/webdata/web_data_service_factory.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/webdata/web_data_service_factory.h"
+
+#include "base/file_path.h"
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/common/chrome_constants.h"
+
+WebDataServiceFactory::WebDataServiceFactory()
+ : RefcountedProfileKeyedServiceFactory(
+ "WebDataService",
+ ProfileDependencyManager::GetInstance()) {
+ // WebDataServiceFactory has no dependecies.
+}
+
+WebDataServiceFactory::~WebDataServiceFactory() {}
+
+// static
+scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile(
+ Profile* profile, Profile::ServiceAccessType access_type) {
+ DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
+ return static_cast<WebDataService*>(
+ GetInstance()->GetServiceForProfile(profile, true).get());
+}
+
+// static
+scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists(
+ Profile* profile, Profile::ServiceAccessType access_type) {
+ DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
+ return static_cast<WebDataService*>(
+ GetInstance()->GetServiceForProfile(profile, false).get());
+}
+
+// static
+WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
+ return Singleton<WebDataServiceFactory>::get();
+}
+
+bool WebDataServiceFactory::ServiceRedirectedInIncognito() {
+ return false;
+}
+
+scoped_refptr<RefcountedProfileKeyedService>
+WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
+ DCHECK(profile);
+
+ FilePath path = profile->GetPath();
+ path = path.Append(chrome::kWebDataFilename);
+
+ scoped_refptr<WebDataService> wds(new WebDataService());
+ if (!wds->Init(profile->GetPath()))
+ NOTREACHED();
+ return wds.get();
+}
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/browser/webdata/web_data_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698