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_ACTIVITY_LOG_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // An abstract class for processing and summarizing activity log data. | 32 // An abstract class for processing and summarizing activity log data. |
33 // Subclasses will generally store data in an SQLite database (the | 33 // Subclasses will generally store data in an SQLite database (the |
34 // ActivityLogDatabasePolicy subclass includes some helper methods to assist | 34 // ActivityLogDatabasePolicy subclass includes some helper methods to assist |
35 // with this case), but this is not absolutely required. | 35 // with this case), but this is not absolutely required. |
36 // | 36 // |
37 // Implementations should support: | 37 // Implementations should support: |
38 // (1) Receiving Actions to process, and summarizing, compression, and storing | 38 // (1) Receiving Actions to process, and summarizing, compression, and storing |
39 // these as appropriate. | 39 // these as appropriate. |
40 // (2) Reading Actions back from storage. | 40 // (2) Reading Actions back from storage. |
| 41 // (3) Cleaning of URLs |
41 // | 42 // |
42 // Implementations based on a database should likely implement | 43 // Implementations based on a database should likely implement |
43 // ActivityDatabase::Delegate, which provides hooks on database events and | 44 // ActivityDatabase::Delegate, which provides hooks on database events and |
44 // allows the database to periodically request that actions (which the policy | 45 // allows the database to periodically request that actions (which the policy |
45 // is responsible for queueing) be flushed to storage. | 46 // is responsible for queueing) be flushed to storage. |
46 // | 47 // |
47 // Since every policy implementation might summarize data differently, the | 48 // Since every policy implementation might summarize data differently, the |
48 // database implementation is policy-specific and therefore completely | 49 // database implementation is policy-specific and therefore completely |
49 // encapsulated in the policy class. All the member functions can be called | 50 // encapsulated in the policy class. All the member functions can be called |
50 // on the UI thread. | 51 // on the UI thread. |
(...skipping 29 matching lines...) Expand all Loading... |
80 // TODO(felt,dbabic) This is overly specific to the current implementation of | 81 // TODO(felt,dbabic) This is overly specific to the current implementation of |
81 // the FullStreamUIPolicy. We should refactor it to use a more generic read | 82 // the FullStreamUIPolicy. We should refactor it to use a more generic read |
82 // function, for example one that takes a dictionary of query parameters | 83 // function, for example one that takes a dictionary of query parameters |
83 // (extension_id, time range, etc.). | 84 // (extension_id, time range, etc.). |
84 virtual void ReadData( | 85 virtual void ReadData( |
85 const std::string& extension_id, | 86 const std::string& extension_id, |
86 const int day, | 87 const int day, |
87 const base::Callback | 88 const base::Callback |
88 <void(scoped_ptr<Action::ActionVector>)>& callback) = 0; | 89 <void(scoped_ptr<Action::ActionVector>)>& callback) = 0; |
89 | 90 |
| 91 // Clean the relevant URL data. The cleaning may need to be different for |
| 92 // different policies. If restrict_urls is empty then all URLs are removed. |
| 93 virtual void RemoveURLs(const std::vector<GURL>& restrict_urls) = 0; |
| 94 |
90 // For unit testing only. | 95 // For unit testing only. |
91 void SetClockForTesting(scoped_ptr<base::Clock> clock); | 96 void SetClockForTesting(scoped_ptr<base::Clock> clock); |
92 | 97 |
93 // A collection of methods that are useful for implementing policies. These | 98 // A collection of methods that are useful for implementing policies. These |
94 // are all static methods; the ActivityLogPolicy::Util class cannot be | 99 // are all static methods; the ActivityLogPolicy::Util class cannot be |
95 // instantiated. This is nested within ActivityLogPolicy to make calling | 100 // instantiated. This is nested within ActivityLogPolicy to make calling |
96 // these methods more convenient from within a policy, but they are public. | 101 // these methods more convenient from within a policy, but they are public. |
97 class Util { | 102 class Util { |
98 public: | 103 public: |
99 // Serialize a Value as a JSON string. Returns an empty string if value is | 104 // Serialize a Value as a JSON string. Returns an empty string if value is |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 209 |
205 private: | 210 private: |
206 // See the comments for the ActivityDatabase class for a discussion of how | 211 // See the comments for the ActivityDatabase class for a discussion of how |
207 // database cleanup runs. | 212 // database cleanup runs. |
208 ActivityDatabase* db_; | 213 ActivityDatabase* db_; |
209 }; | 214 }; |
210 | 215 |
211 } // namespace extensions | 216 } // namespace extensions |
212 | 217 |
213 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 218 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
OLD | NEW |