| 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_COUNTING_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; | 38 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; |
| 39 | 39 |
| 40 virtual void Close() OVERRIDE; | 40 virtual void Close() OVERRIDE; |
| 41 | 41 |
| 42 // Gets or sets the amount of time that old records are kept in the database. | 42 // Gets or sets the amount of time that old records are kept in the database. |
| 43 const base::TimeDelta& retention_time() const { return retention_time_; } | 43 const base::TimeDelta& retention_time() const { return retention_time_; } |
| 44 void set_retention_time(const base::TimeDelta& delta) { | 44 void set_retention_time(const base::TimeDelta& delta) { |
| 45 retention_time_ = delta; | 45 retention_time_ = delta; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Clean the URL data stored for this policy. |
| 49 virtual void RemoveURLs(const std::vector<GURL>&) OVERRIDE; |
| 50 |
| 48 // The main database table, and the name for a read-only view that | 51 // The main database table, and the name for a read-only view that |
| 49 // decompresses string values for easier parsing. | 52 // decompresses string values for easier parsing. |
| 50 static const char* kTableName; | 53 static const char* kTableName; |
| 51 static const char* kReadViewName; | 54 static const char* kReadViewName; |
| 52 | 55 |
| 53 protected: | 56 protected: |
| 54 // The ActivityDatabase::Delegate interface. These are always called from | 57 // The ActivityDatabase::Delegate interface. These are always called from |
| 55 // the database thread. | 58 // the database thread. |
| 56 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; | 59 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; |
| 57 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; | 60 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 | 80 |
| 78 // Internal method to read data from the database; called on the database | 81 // Internal method to read data from the database; called on the database |
| 79 // thread. | 82 // thread. |
| 80 scoped_ptr<Action::ActionVector> DoReadFilteredData( | 83 scoped_ptr<Action::ActionVector> DoReadFilteredData( |
| 81 const std::string& extension_id, | 84 const std::string& extension_id, |
| 82 const Action::ActionType type, | 85 const Action::ActionType type, |
| 83 const std::string& api_name, | 86 const std::string& api_name, |
| 84 const std::string& page_url, | 87 const std::string& page_url, |
| 85 const std::string& arg_url); | 88 const std::string& arg_url); |
| 86 | 89 |
| 90 // The implementation of RemoveURLs; this must only run on the database |
| 91 // thread. |
| 92 void DoRemoveURLs(const std::vector<GURL>& restrict_urls); |
| 93 |
| 87 // Cleans old records from the activity log database. | 94 // Cleans old records from the activity log database. |
| 88 bool CleanOlderThan(sql::Connection* db, const base::Time& cutoff); | 95 bool CleanOlderThan(sql::Connection* db, const base::Time& cutoff); |
| 89 | 96 |
| 90 // Cleans unused interned strings from the database. This should be run | 97 // Cleans unused interned strings from the database. This should be run |
| 91 // after deleting rows from the main log table to clean out stale values. | 98 // after deleting rows from the main log table to clean out stale values. |
| 92 bool CleanStringTables(sql::Connection* db); | 99 bool CleanStringTables(sql::Connection* db); |
| 93 | 100 |
| 94 // API calls for which complete arguments should be logged. | 101 // API calls for which complete arguments should be logged. |
| 95 std::set<std::string> api_arg_whitelist_; | 102 std::set<std::string> api_arg_whitelist_; |
| 96 | 103 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 123 | 130 |
| 124 friend class CountingPolicyTest; | 131 friend class CountingPolicyTest; |
| 125 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, EarlyFlush); | 132 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, EarlyFlush); |
| 126 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, MergingAndExpiring); | 133 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, MergingAndExpiring); |
| 127 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, StringTableCleaning); | 134 FRIEND_TEST_ALL_PREFIXES(CountingPolicyTest, StringTableCleaning); |
| 128 }; | 135 }; |
| 129 | 136 |
| 130 } // namespace extensions | 137 } // namespace extensions |
| 131 | 138 |
| 132 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ | 139 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_COUNTING_POLICY_H_ |
| OLD | NEW |