Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
sdefresne
2015/01/08 10:41:01
nit: you'll only land this is 2015, so please use
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
| |
| 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/history/top_sites_factory.h" | |
| 6 | |
| 7 #include "chrome/browser/history/top_sites_impl.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/common/chrome_constants.h" | |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 11 | |
| 12 using namespace history; | |
|
sdefresne
2015/01/08 10:41:01
nit: we prefer not to use "using namespace" unless
Bernhard Bauer
2015/01/08 10:45:14
Good catch! The Google C++ style guide is actually
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
| |
| 13 | |
| 14 // static | |
| 15 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile( | |
| 16 Profile* profile) { | |
| 17 return static_cast<history::TopSites*>( | |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true).get()); | |
| 19 } | |
| 20 | |
| 21 // static | |
| 22 scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists( | |
| 23 Profile* profile) { | |
| 24 return static_cast<history::TopSites*>( | |
| 25 GetInstance()->GetServiceForBrowserContext(profile, false).get()); | |
| 26 } | |
| 27 | |
| 28 // static | |
| 29 TopSitesFactory* TopSitesFactory::GetInstance() { | |
| 30 return Singleton<TopSitesFactory>::get(); | |
| 31 } | |
| 32 | |
| 33 scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( | |
| 34 content::BrowserContext* profile) const { | |
|
sdefresne
2015/01/08 10:41:01
nit: s/profile/context/
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
| |
| 35 TopSitesImpl* top_sites = new TopSitesImpl(static_cast<Profile*>(profile)); | |
| 36 top_sites->Init(profile->GetPath().Append(chrome::kTopSitesFilename)); | |
| 37 return make_scoped_refptr<history::TopSites>(top_sites); | |
|
Bernhard Bauer
2015/01/08 10:22:05
Does a simple make_scoped_refptr() work? If it doe
Jitu( very slow this week)
2015/01/12 11:30:07
I think
return make_scoped_refptr(top_sites) work
Bernhard Bauer
2015/01/12 14:32:23
That would be a possible alternative, but what you
| |
| 38 } | |
| 39 | |
| 40 TopSitesFactory::TopSitesFactory() | |
| 41 : RefcountedBrowserContextKeyedServiceFactory( | |
| 42 "TopSitesService", | |
|
sdefresne
2015/01/08 10:41:01
nit: the value passed there is usually the name of
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
Jitu( very slow this week)
2015/01/12 11:30:07
Done.
| |
| 43 BrowserContextDependencyManager::GetInstance()) { | |
| 44 } | |
| 45 | |
| 46 TopSitesFactory::~TopSitesFactory() { | |
| 47 } | |
| OLD | NEW |