Chromium Code Reviews| Index: chrome/browser/extensions/activity_log/activity_log.cc |
| diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc |
| index 710e82b0b24a734ccfdd7768771429bd3f949d71..893dea2c39288c300980c21caa7d0007a97fe587 100644 |
| --- a/chrome/browser/extensions/activity_log/activity_log.cc |
| +++ b/chrome/browser/extensions/activity_log/activity_log.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/command_line.h" |
| #include "base/json/json_string_value_serializer.h" |
| +#include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -29,7 +30,6 @@ |
| #include "chrome/common/chrome_constants.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| -#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_contents.h" |
| #include "extensions/browser/extension_system.h" |
| @@ -336,42 +336,21 @@ void ExtractUrls(scoped_refptr<Action> action, Profile* profile) { |
| namespace extensions { |
| -// ActivityLogFactory |
| +// SET THINGS UP. -------------------------------------------------------------- |
| -ActivityLogFactory* ActivityLogFactory::GetInstance() { |
| - return Singleton<ActivityLogFactory>::get(); |
| -} |
| +static base::LazyInstance<ProfileKeyedAPIFactory<ActivityLog> > g_factory = |
| + LAZY_INSTANCE_INITIALIZER; |
| -BrowserContextKeyedService* ActivityLogFactory::BuildServiceInstanceFor( |
| - content::BrowserContext* profile) const { |
| - return new ActivityLog(static_cast<Profile*>(profile)); |
| -} |
| - |
| -content::BrowserContext* ActivityLogFactory::GetBrowserContextToUse( |
| - content::BrowserContext* context) const { |
| - return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
|
James Cook
2014/02/19 02:37:43
I'll bet this is the way it is because there's som
Yoyo Zhou
2014/02/19 02:49:05
Good call. But actually I think we don't use Activ
|
| -} |
| - |
| -ActivityLogFactory::ActivityLogFactory() |
| - : BrowserContextKeyedServiceFactory( |
| - "ActivityLog", |
| - BrowserContextDependencyManager::GetInstance()) { |
| - DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| - DependsOn(InstallTrackerFactory::GetInstance()); |
| +ProfileKeyedAPIFactory<ActivityLog>* ActivityLog::GetFactoryInstance() { |
| + return g_factory.Pointer(); |
| } |
| // static |
| ActivityLog* ActivityLog::GetInstance(content::BrowserContext* context) { |
| - return ActivityLogFactory::GetForBrowserContext(context); |
| + return ActivityLog::GetFactoryInstance()->GetForProfile( |
| + Profile::FromBrowserContext(context)); |
| } |
| -ActivityLogFactory::~ActivityLogFactory() { |
| -} |
| - |
| -// ActivityLog |
| - |
| -// SET THINGS UP. -------------------------------------------------------------- |
| - |
| // Use GetInstance instead of directly creating an ActivityLog. |
| ActivityLog::ActivityLog(Profile* profile) |
| : database_policy_(NULL), |
| @@ -716,4 +695,10 @@ void ActivityLog::DeleteDatabase() { |
| database_policy_->DeleteDatabase(); |
| } |
| +template <> |
| +void ProfileKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { |
| + DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| + DependsOn(InstallTrackerFactory::GetInstance()); |
| +} |
| + |
| } // namespace extensions |