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

Unified Diff: chrome/browser/extensions/activity_log/activity_log.cc

Issue 168253002: Cleanup many APIs to use ProfileKeyedAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
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..e555258a00b6de6da38db07bd5797a0c0dc6e721 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,48 +336,27 @@ 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);
-}
-
-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)
+ActivityLog::ActivityLog(content::BrowserContext* context)
: database_policy_(NULL),
database_policy_type_(ActivityLogPolicy::POLICY_INVALID),
uma_policy_(NULL),
- profile_(profile),
+ profile_(Profile::FromBrowserContext(context)),
db_enabled_(false),
testing_mode_(false),
has_threads_(true),
@@ -419,7 +398,7 @@ ActivityLog::ActivityLog(Profile* profile)
// checks. However, UmaPolicy can't even compile on Android because it uses
// BrowserList and related classes that aren't compiled for Android.
#if !defined(OS_ANDROID)
- if (!profile->IsOffTheRecord())
+ if (!profile_->IsOffTheRecord())
uma_policy_ = new UmaPolicy(profile_);
#endif
@@ -716,4 +695,10 @@ void ActivityLog::DeleteDatabase() {
database_policy_->DeleteDatabase();
}
+template <>
+void ProfileKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() {
+ DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+ DependsOn(InstallTrackerFactory::GetInstance());
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698