Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "chrome/browser/extensions/activity_log/activity_database.h" | |
| 10 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" | 11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 | 16 |
| 16 class ActivityDatabase; | |
| 17 | |
| 18 // A policy for logging the full stream of actions, including all arguments. | 17 // A policy for logging the full stream of actions, including all arguments. |
| 19 // It's mostly intended to be used in testing and analysis. | 18 // It's mostly intended to be used in testing and analysis. |
| 20 class FullStreamUIPolicy : public ActivityLogPolicy { | 19 class FullStreamUIPolicy : public ActivityLogPolicy, |
| 20 public ActivityPolicyCallbacks { | |
|
felt
2013/07/09 22:14:51
Maybe the name should have both Database and Polic
mvrable
2013/07/09 23:03:22
ActivityLogPolicyDatabaseCallbacks? That's gettin
felt
2013/07/10 00:14:36
ActivityDatabasePolicyCallback? 3 characters short
mvrable
2013/07/10 17:49:17
I'm going to change this to ActivityDatabaseCallba
felt
2013/07/10 18:35:17
Thanks, sorry to be picky on this. :)
mvrable
2013/07/10 20:48:41
Not a problem, coming up with good names is import
| |
| 21 public: | 21 public: |
| 22 // For more info about these member functions, see the super class. | 22 // For more info about these member functions, see the super class. |
| 23 explicit FullStreamUIPolicy(Profile* profile); | 23 explicit FullStreamUIPolicy(Profile* profile); |
| 24 | 24 |
| 25 virtual ~FullStreamUIPolicy(); | |
| 26 | |
| 27 virtual void ProcessAction(ActionType action_type, | 25 virtual void ProcessAction(ActionType action_type, |
| 28 const std::string& extension_id, | 26 const std::string& extension_id, |
| 29 const std::string& name, const GURL& gurl, | 27 const std::string& name, const GURL& gurl, |
| 30 const base::ListValue* args, | 28 const base::ListValue* args, |
| 31 const base::DictionaryValue* details) OVERRIDE; | 29 const base::DictionaryValue* details) OVERRIDE; |
| 32 | 30 |
| 33 virtual void SaveState() OVERRIDE {} | 31 virtual void SaveState() OVERRIDE {} |
| 34 | 32 |
| 35 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. | 33 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. |
| 36 // It assumes that the callback can return a sorted vector of actions. Some | 34 // It assumes that the callback can return a sorted vector of actions. Some |
| 37 // policies might not do that. For instance, imagine a trivial policy that | 35 // policies might not do that. For instance, imagine a trivial policy that |
| 38 // just counts the frequency of certain actions within some time period, | 36 // just counts the frequency of certain actions within some time period, |
| 39 // this call would be meaningless, as it couldn't return anything useful. | 37 // this call would be meaningless, as it couldn't return anything useful. |
| 40 virtual void ReadData( | 38 virtual void ReadData( |
| 41 const std::string& extension_id, | 39 const std::string& extension_id, |
| 42 const int day, | 40 const int day, |
| 43 const base::Callback | 41 const base::Callback |
| 44 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) | 42 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) |
| 45 const OVERRIDE; | 43 const OVERRIDE; |
| 46 | 44 |
| 47 virtual void SetSaveStateOnRequestOnly() OVERRIDE; | 45 virtual void SetSaveStateOnRequestOnly() OVERRIDE; |
| 48 | 46 |
| 49 // Returns the actual key for a given key type | 47 // Returns the actual key for a given key type |
| 50 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; | 48 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; |
| 51 | 49 |
| 50 virtual void Close() OVERRIDE; | |
| 51 | |
| 52 protected: | 52 protected: |
| 53 virtual ~FullStreamUIPolicy() {} | |
| 54 | |
| 55 // The ActivityPolicyCallbacks interface. | |
| 56 virtual bool DatabaseInitCallback(sql::Connection* db) OVERRIDE; | |
| 57 virtual void DatabaseCloseCallback() OVERRIDE; | |
| 58 | |
| 53 // Concatenates arguments | 59 // Concatenates arguments |
| 54 virtual std::string ProcessArguments(ActionType action_type, | 60 virtual std::string ProcessArguments(ActionType action_type, |
| 55 const std::string& name, | 61 const std::string& name, |
| 56 const base::ListValue* args) const; | 62 const base::ListValue* args) const; |
| 57 | 63 |
| 58 virtual void ProcessWebRequestModifications( | 64 virtual void ProcessWebRequestModifications( |
| 59 base::DictionaryValue& details, | 65 base::DictionaryValue& details, |
| 60 std::string& details_string) const; | 66 std::string& details_string) const; |
| 61 | 67 |
| 62 // We initialize this on the same thread as the ActivityLog and policy, but | 68 // We initialize this on the same thread as the ActivityLog and policy, but |
| 63 // then subsequent operations occur on the DB thread. Instead of destructing | 69 // then subsequent operations occur on the DB thread. Instead of destructing |
| 64 // the ActivityDatabase, we call its Close() method on the DB thread and it | 70 // the ActivityDatabase, we call its Close() method on the DB thread and it |
| 65 // commits suicide. | 71 // commits suicide. |
| 66 ActivityDatabase* db_; | 72 ActivityDatabase* db_; |
| 73 | |
| 74 private: | |
| 75 friend class ActivityDatabaseTest; | |
| 76 | |
| 77 // Initializes the database tables. This is called by the ActivityDatabase, | |
| 78 // on the database thread, after opening the database. Returns true on | |
| 79 // success. | |
| 80 static bool InitializeTables(sql::Connection* db); | |
| 67 }; | 81 }; |
| 68 | 82 |
| 69 } // namespace extensions | 83 } // namespace extensions |
| 70 | 84 |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 85 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| OLD | NEW |