| 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 130f75775bd07e5169b1869790f56ea03c79381f..84b77d12f8f9c4efc06854676252063e0ffeded1 100644
|
| --- a/chrome/browser/extensions/activity_log/activity_log.h
|
| +++ b/chrome/browser/extensions/activity_log/activity_log.h
|
| @@ -9,28 +9,26 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| -#include "base/bind.h"
|
| -#include "base/bind_helpers.h"
|
| #include "base/callback.h"
|
| -#include "base/hash_tables.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_database.h"
|
| +#include "chrome/browser/extensions/activity_log/activity_log_policy.h"
|
| #include "chrome/browser/extensions/tab_helper.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "components/browser_context_keyed_service/browser_context_dependency_manager.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 "content/public/browser/browser_thread.h"
|
|
|
| class Profile;
|
| using content::BrowserThread;
|
|
|
| namespace extensions {
|
| class Extension;
|
| +class ActivityLogPolicy;
|
|
|
| // A utility for tracing interesting activity for each extension.
|
| // It writes to an ActivityDatabase on a separate thread to record the activity.
|
| @@ -95,7 +93,7 @@ class ActivityLog : public BrowserContextKeyedService,
|
| void LogBlockedAction(const Extension* extension,
|
| const std::string& blocked_call, // e.g., tabs.get
|
| ListValue* args, // argument values
|
| - const BlockedAction::Reason reason, // why it's blocked
|
| + BlockedAction::Reason reason, // why it's blocked
|
| const std::string& extra); // extra logging info
|
|
|
| // Log an interaction between an extension and a URL.
|
| @@ -127,12 +125,15 @@ class ActivityLog : public BrowserContextKeyedService,
|
| <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>&
|
| callback);
|
|
|
| - // An error has happened; we want to rollback and close the db.
|
| - // Needs to be public so the error delegate can call it.
|
| - void KillActivityLogDatabase();
|
| -
|
| - // For unit tests only.
|
| - void SetArgumentLoggingForTesting(bool log_arguments);
|
| + // At the moment, ActivityLog will use only one policy for summarization
|
| + // (POLICY_NOARGS by default). This static member function can be used
|
| + // to change the default type, but has to be called before the first
|
| + // GetInstance call.
|
| + // TODO(dbabic,felt) ActivityLog should support multiple policies at the
|
| + // same time, so this will need to be changed later.
|
| + static void SetDefaultPolicy(ActivityLogPolicy::PolicyType policy_type) {
|
| + policy_type_ = policy_type;
|
| + }
|
|
|
| private:
|
| friend class ActivityLogFactory;
|
| @@ -167,62 +168,24 @@ class ActivityLog : public BrowserContextKeyedService,
|
| int32 page_id,
|
| const GURL& on_url) OVERRIDE;
|
|
|
| - // The callback when initializing the database.
|
| - void OnDBInitComplete();
|
| -
|
| static const char* ActivityToString(Activity activity);
|
|
|
| - // The Schedule methods dispatch the calls to the database on a
|
| - // separate thread. We dispatch to the UI thread if the DB thread doesn't
|
| - // exist, which should only happen in tests where there is no DB thread.
|
| - template<typename DatabaseFunc>
|
| - void ScheduleAndForget(DatabaseFunc func) {
|
| - BrowserThread::PostTask(dispatch_thread_,
|
| - FROM_HERE,
|
| - base::Bind(func, base::Unretained(db_)));
|
| - }
|
| -
|
| - template<typename DatabaseFunc, typename ArgA>
|
| - void ScheduleAndForget(DatabaseFunc func, ArgA a) {
|
| - BrowserThread::PostTask(dispatch_thread_,
|
| - FROM_HERE,
|
| - base::Bind(func, base::Unretained(db_), a));
|
| - }
|
| -
|
| - template<typename DatabaseFunc, typename ArgA, typename ArgB>
|
| - void ScheduleAndForget(DatabaseFunc func, ArgA a, ArgB b) {
|
| - BrowserThread::PostTask(dispatch_thread_,
|
| - FROM_HERE,
|
| - base::Bind(func, base::Unretained(db_), a, b));
|
| - }
|
| -
|
| typedef ObserverListThreadSafe<Observer> ObserverList;
|
| typedef std::map<const Extension*, scoped_refptr<ObserverList> >
|
| ObserverMap;
|
| // A map of extensions to activity observers for that extension.
|
| ObserverMap observers_;
|
|
|
| - // The database wrapper that does the actual database I/O.
|
| - // We initialize this on the same thread as the ActivityLog, but then
|
| - // subsequent operations occur on the DB thread. Instead of destructing the
|
| - // ActivityDatabase, we call its Close() method on the DB thread and it
|
| - // commits suicide.
|
| - extensions::ActivityDatabase* db_;
|
| -
|
| - // Normally the DB thread. In some cases (tests), it might not exist
|
| - // we dispatch to the UI thread.
|
| - BrowserThread::ID dispatch_thread_;
|
| + // The policy object takes care of data summarization, compression, and
|
| + // logging
|
| + extensions::ActivityLogPolicy* policy_;
|
|
|
| // Whether to log activity to stdout or the UI. These are set by switches.
|
| bool log_activity_to_stdout_;
|
| bool log_activity_to_ui_;
|
|
|
| - // testing_mode_ controls whether to log API call arguments. By default, we
|
| - // don't log most arguments to avoid saving too much data. In testing mode,
|
| - // argument collection is enabled. We also whitelist some arguments for
|
| - // collection regardless of whether this bool is true.
|
| - bool testing_mode_;
|
| - base::hash_set<std::string> arg_whitelist_api_;
|
| + // TODO(dbabic,felt) change this into a list of policy types later.
|
| + static ActivityLogPolicy::PolicyType policy_type_;
|
|
|
| Profile* profile_;
|
|
|
|
|