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

Side by Side Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed return NULL; to NOTREACHED() 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/webdata/web_data_service_factory.h"
6
7 #include "base/file_path.h"
8 #include "chrome/browser/profiles/profile_dependency_manager.h"
9 #include "chrome/browser/webdata/web_data_service.h"
10 #include "chrome/common/chrome_constants.h"
11
12 WebDataServiceFactory::WebDataServiceFactory()
13 : RefcountedProfileKeyedServiceFactory(
14 "WebDataService",
15 ProfileDependencyManager::GetInstance()) {
16 // WebDataServiceFactory has no dependecies.
17 }
18
19 WebDataServiceFactory::~WebDataServiceFactory() {}
20
21 // static
22 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile(
23 Profile* profile, Profile::ServiceAccessType access_type) {
24 if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) {
Peter Kasting 2012/04/02 23:21:13 Nit: Use DCHECK() as requested previously: DCH
GeorgeY 2012/04/03 20:13:29 Done.
25 NOTREACHED();
26 }
27 return static_cast<WebDataService*>(
28 GetInstance()->GetServiceForProfile(profile, true).get());
29 }
30
31 // static
32 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists(
33 Profile* profile, Profile::ServiceAccessType access_type) {
34 if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) {
35 NOTREACHED();
36 }
37 return static_cast<WebDataService*>(
38 GetInstance()->GetServiceForProfile(profile, false).get());
39 }
40
41 // static
42 WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
43 return Singleton<WebDataServiceFactory>::get();
44 }
45
46 bool WebDataServiceFactory::ServiceRedirectedInIncognito() {
47 return false;
48 }
49
50 scoped_refptr<RefcountedProfileKeyedService>
51 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
52 DCHECK(profile);
53
54 FilePath path = profile->GetPath();
55 path = path.Append(chrome::kWebDataFilename);
56
57 scoped_refptr<WebDataService> wds(new WebDataService());
58 if (!wds->Init(profile->GetPath())) {
Peter Kasting 2012/04/02 23:21:13 Nit: {} unnecessary
GeorgeY 2012/04/03 20:13:29 Done.
59 NOTREACHED();
60 }
61 return wds.get();
62 }
OLDNEW
« 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