 Chromium Code Reviews
 Chromium Code Reviews Issue 15573003:
  New architecture of the activity logging: Policies for summarization (and compression)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 15573003:
  New architecture of the activity logging: Policies for summarization (and compression)  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 b934d97e3ee82d31ebf71258f2a37eb638ecac00..484d78c3e43b219b6d1f7e60947342eb1375fcf6 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 ProfileKeyedService, | 
| 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,9 @@ class ActivityLog : public ProfileKeyedService, | 
| <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); | 
| + static void SetDefaultPolicy(ActivityLogPolicy::PolicyType policy_type) { | 
| 
felt
2013/05/24 18:43:38
Can you add a comment describing what this is used
 
dbabic
2013/05/28 21:11:49
Done.
 | 
| + policy_type_ = policy_type; | 
| + } | 
| private: | 
| friend class ActivityLogFactory; | 
| @@ -167,62 +162,24 @@ class ActivityLog : public ProfileKeyedService, | 
| 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_; |