Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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/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; | |
| 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 TopSitesFactory::TopSitesFactory() | |
| 34 : RefcountedBrowserContextKeyedServiceFactory( | |
| 35 "TopSitesService", | |
| 36 BrowserContextDependencyManager::GetInstance()) { | |
| 37 } | |
| 38 | |
| 39 TopSitesFactory::~TopSitesFactory() { | |
| 40 } | |
| 41 | |
| 42 scoped_refptr<RefcountedKeyedService> | |
|
Bernhard Bauer
2015/01/06 11:10:30
Can you move this above the constructor and destru
Jitu( very slow this week)
2015/01/08 09:38:25
Done.
| |
| 43 TopSitesFactory::BuildServiceInstanceFor( | |
| 44 content::BrowserContext* profile) const { | |
| 45 TopSitesImpl* top_sites = new TopSitesImpl(static_cast<Profile*>(profile)); | |
| 46 top_sites->Init(profile->GetPath().Append(chrome::kTopSitesFilename)); | |
| 47 return scoped_refptr<history::TopSites>(top_sites); | |
| 48 } | |
| OLD | NEW |