Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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/feature_engagement_tracker/feature_engagement_tracker_f actory.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/singleton.h" | |
| 10 #include "base/sequenced_task_runner.h" | |
| 11 #include "base/threading/sequenced_worker_pool.h" | |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/common/chrome_constants.h" | |
| 14 #include "components/feature_engagement_tracker/public/feature_engagement_tracke r.h" | |
| 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
| 16 #include "content/public/browser/browser_context.h" | |
| 17 #include "content/public/browser/browser_thread.h" | |
| 18 | |
| 19 // static | |
| 20 FeatureEngagementTrackerFactory* | |
| 21 FeatureEngagementTrackerFactory::GetInstance() { | |
| 22 return base::Singleton<FeatureEngagementTrackerFactory>::get(); | |
| 23 } | |
| 24 | |
| 25 // static | |
| 26 feature_engagement_tracker::FeatureEngagementTracker* | |
| 27 FeatureEngagementTrackerFactory::GetForBrowserContext( | |
| 28 content::BrowserContext* context) { | |
| 29 return static_cast<feature_engagement_tracker::FeatureEngagementTracker*>( | |
| 30 GetInstance()->GetServiceForBrowserContext(context, true)); | |
| 31 } | |
| 32 | |
| 33 FeatureEngagementTrackerFactory::FeatureEngagementTrackerFactory() | |
| 34 : BrowserContextKeyedServiceFactory( | |
| 35 "feature_engagement_tracker::FeatureEngagementTracker", | |
| 36 BrowserContextDependencyManager::GetInstance()) {} | |
| 37 | |
| 38 FeatureEngagementTrackerFactory::~FeatureEngagementTrackerFactory() = default; | |
| 39 | |
| 40 KeyedService* FeatureEngagementTrackerFactory::BuildServiceInstanceFor( | |
| 41 content::BrowserContext* context) const { | |
| 42 Profile* profile = Profile::FromBrowserContext(context); | |
| 43 | |
| 44 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | |
| 45 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | |
| 46 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | |
| 47 | |
| 48 base::FilePath storage_dir = profile->GetPath().Append( | |
| 49 chrome::kFeatureEngagementTrackerStorageDirname); | |
| 50 | |
| 51 return feature_engagement_tracker::FeatureEngagementTracker::Create( | |
| 52 storage_dir, background_task_runner); | |
| 53 } | |
| 54 | |
| 55 content::BrowserContext* | |
| 56 FeatureEngagementTrackerFactory::GetBrowserContextToUse( | |
| 57 content::BrowserContext* context) const { | |
| 58 return context; | |
|
David Trainor- moved to gerrit
2017/03/29 18:00:03
Do we want a separate one for on and off the recor
nyquist
2017/03/30 22:58:54
Redirecting incognito to main context for now.
| |
| 59 } | |
| OLD | NEW |