| 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 ActivityDatabase::Delegate { |
| 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 {} | |
| 34 | |
| 35 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. | 31 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. |
| 36 // It assumes that the callback can return a sorted vector of actions. Some | 32 // 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 | 33 // policies might not do that. For instance, imagine a trivial policy that |
| 38 // just counts the frequency of certain actions within some time period, | 34 // just counts the frequency of certain actions within some time period, |
| 39 // this call would be meaningless, as it couldn't return anything useful. | 35 // this call would be meaningless, as it couldn't return anything useful. |
| 40 virtual void ReadData( | 36 virtual void ReadData( |
| 41 const std::string& extension_id, | 37 const std::string& extension_id, |
| 42 const int day, | 38 const int day, |
| 43 const base::Callback | 39 const base::Callback |
| 44 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) | 40 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) |
| 45 const OVERRIDE; | 41 const OVERRIDE; |
| 46 | 42 |
| 47 virtual void SetSaveStateOnRequestOnly() OVERRIDE; | |
| 48 | |
| 49 // Returns the actual key for a given key type | 43 // Returns the actual key for a given key type |
| 50 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; | 44 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; |
| 51 | 45 |
| 46 virtual void Close() OVERRIDE; |
| 47 |
| 52 protected: | 48 protected: |
| 49 // Only ever run by OnDatabaseClose() below; see the comments on the |
| 50 // ActivityDatabase class for an overall discussion of how cleanup works. |
| 51 virtual ~FullStreamUIPolicy() {} |
| 52 |
| 53 // The ActivityDatabase::PolicyDelegate interface. These are always called |
| 54 // from the database thread. |
| 55 virtual bool OnDatabaseInit(sql::Connection* db) OVERRIDE; |
| 56 virtual void OnDatabaseClose() OVERRIDE; |
| 57 |
| 53 // Concatenates arguments | 58 // Concatenates arguments |
| 54 virtual std::string ProcessArguments(ActionType action_type, | 59 virtual std::string ProcessArguments(ActionType action_type, |
| 55 const std::string& name, | 60 const std::string& name, |
| 56 const base::ListValue* args) const; | 61 const base::ListValue* args) const; |
| 57 | 62 |
| 58 virtual void ProcessWebRequestModifications( | 63 virtual void ProcessWebRequestModifications( |
| 59 base::DictionaryValue& details, | 64 base::DictionaryValue& details, |
| 60 std::string& details_string) const; | 65 std::string& details_string) const; |
| 61 | 66 |
| 62 // We initialize this on the same thread as the ActivityLog and policy, but | 67 // See the comments for the ActivityDatabase class for a discussion of how |
| 63 // then subsequent operations occur on the DB thread. Instead of destructing | 68 // cleanup runs. |
| 64 // the ActivityDatabase, we call its Close() method on the DB thread and it | |
| 65 // commits suicide. | |
| 66 ActivityDatabase* db_; | 69 ActivityDatabase* db_; |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 } // namespace extensions | 72 } // namespace extensions |
| 70 | 73 |
| 71 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 74 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| OLD | NEW |