Index: chrome/browser/extensions/activity_log/activity_log.h |
diff --git a/chrome/browser/extensions/activity_log/activity_log.h b/chrome/browser/extensions/activity_log/activity_log.h |
index 84ffd397f6cf95a39659e5a262e7176a0f5189d1..b149822f9530e0bad4d00c3dde67f2fed6976d9e 100644 |
--- a/chrome/browser/extensions/activity_log/activity_log.h |
+++ b/chrome/browser/extensions/activity_log/activity_log.h |
@@ -10,17 +10,15 @@ |
#include <vector> |
#include "base/callback.h" |
-#include "base/memory/singleton.h" |
#include "base/observer_list_threadsafe.h" |
#include "base/synchronization/lock.h" |
#include "base/threading/thread.h" |
#include "chrome/browser/extensions/activity_log/activity_actions.h" |
#include "chrome/browser/extensions/activity_log/activity_log_policy.h" |
+#include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
#include "chrome/browser/extensions/install_observer.h" |
#include "chrome/browser/extensions/tab_helper.h" |
#include "chrome/common/extensions/dom_action_types.h" |
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h" |
-#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" |
#include "extensions/browser/api_activity_monitor.h" |
class Profile; |
@@ -39,7 +37,9 @@ class InstallTracker; |
// A utility for tracing interesting activity for each extension. |
// It writes to an ActivityDatabase on a separate thread to record the activity. |
-class ActivityLog : public BrowserContextKeyedService, |
+// Each profile has different extensions, so we keep a different database for |
+// each profile. |
+class ActivityLog : public ProfileKeyedAPI, |
public ApiActivityMonitor, |
public TabHelper::ScriptExecutionObserver, |
public InstallObserver { |
@@ -51,8 +51,10 @@ class ActivityLog : public BrowserContextKeyedService, |
virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0; |
}; |
- // ActivityLog is a singleton, so don't instantiate it with the constructor; |
- // use GetInstance instead. |
+ static ProfileKeyedAPIFactory<ActivityLog>* GetFactoryInstance(); |
+ |
+ // ActivityLog is a BrowserContextKeyedService, so don't instantiate it with |
+ // the constructor; use GetInstance instead. |
static ActivityLog* GetInstance(content::BrowserContext* context); |
// Add/remove observer: the activityLogPrivate API only listens when the |
@@ -127,8 +129,8 @@ class ActivityLog : public BrowserContextKeyedService, |
void DeleteDatabase(); |
private: |
- friend class ActivityLogFactory; |
friend class ActivityLogTest; |
+ friend class ProfileKeyedAPIFactory<ActivityLog>; |
friend class RenderViewActivityLogTest; |
explicit ActivityLog(Profile* profile); |
@@ -165,6 +167,11 @@ class ActivityLog : public BrowserContextKeyedService, |
void ChooseDatabasePolicy(); |
void SetDatabasePolicy(ActivityLogPolicy::PolicyType policy_type); |
+ // ProfileKeyedAPI implementation. |
+ static const char* service_name() { return "ActivityLog"; } |
+ static const bool kServiceRedirectedInIncognito = true; |
James Cook
2014/02/27 00:37:34
Not for this CL, but... The fact that these consta
Yoyo Zhou
2014/02/27 01:05:21
Only one is different in ProfileKeyedAPI, but it's
|
+ static const bool kServiceIsCreatedWithBrowserContext = false; |
+ |
typedef ObserverListThreadSafe<Observer> ObserverList; |
scoped_refptr<ObserverList> observers_; |
@@ -215,31 +222,8 @@ class ActivityLog : public BrowserContextKeyedService, |
DISALLOW_COPY_AND_ASSIGN(ActivityLog); |
}; |
-// Each profile has different extensions, so we keep a different database for |
-// each profile. |
-class ActivityLogFactory : public BrowserContextKeyedServiceFactory { |
- public: |
- static ActivityLog* GetForBrowserContext(content::BrowserContext* context) { |
- return static_cast<ActivityLog*>( |
- GetInstance()->GetServiceForBrowserContext(context, true)); |
- } |
- |
- static ActivityLogFactory* GetInstance(); |
- |
- private: |
- friend struct DefaultSingletonTraits<ActivityLogFactory>; |
- ActivityLogFactory(); |
- virtual ~ActivityLogFactory(); |
- |
- virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
- content::BrowserContext* profile) const OVERRIDE; |
- |
- virtual content::BrowserContext* GetBrowserContextToUse( |
- content::BrowserContext* context) const OVERRIDE; |
- |
- DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
-}; |
- |
+template <> |
+void ProfileKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies(); |
} // namespace extensions |