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 | 9 |
10 #include "chrome/browser/extensions/activity_log/activity_database.h" | 10 #include "chrome/browser/extensions/activity_log/activity_database.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // 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 |
33 // 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 |
34 // just counts the frequency of certain actions within some time period, | 34 // just counts the frequency of certain actions within some time period, |
35 // 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. |
36 virtual void ReadData( | 36 virtual void ReadData( |
37 const std::string& extension_id, | 37 const std::string& extension_id, |
38 const int day, | 38 const int day, |
39 const base::Callback | 39 const base::Callback |
40 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; | 40 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; |
41 | 41 |
| 42 // Clean the URL data stored for this policy. |
| 43 virtual void RemoveURLs(const std::vector<GURL>& restrict_urls) OVERRIDE; |
| 44 |
42 virtual void Close() OVERRIDE; | 45 virtual void Close() OVERRIDE; |
43 | 46 |
44 // Database table schema. | 47 // Database table schema. |
45 static const char* kTableName; | 48 static const char* kTableName; |
46 static const char* kTableContentFields[]; | 49 static const char* kTableContentFields[]; |
47 static const char* kTableFieldTypes[]; | 50 static const char* kTableFieldTypes[]; |
48 static const int kTableFieldCount; | 51 static const int kTableFieldCount; |
49 | 52 |
50 protected: | 53 protected: |
51 // Only ever run by OnDatabaseClose() below; see the comments on the | 54 // Only ever run by OnDatabaseClose() below; see the comments on the |
52 // ActivityDatabase class for an overall discussion of how cleanup works. | 55 // ActivityDatabase class for an overall discussion of how cleanup works. |
53 virtual ~FullStreamUIPolicy(); | 56 virtual ~FullStreamUIPolicy(); |
54 | 57 |
55 // The ActivityDatabase::Delegate interface. These are always called from | 58 // The ActivityDatabase::Delegate interface. These are always called from |
56 // the database thread. | 59 // the database thread. |
57 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; | 60 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; |
58 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; | 61 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; |
59 virtual void OnDatabaseFailure() OVERRIDE; | 62 virtual void OnDatabaseFailure() OVERRIDE; |
60 virtual void OnDatabaseClose() OVERRIDE; | 63 virtual void OnDatabaseClose() OVERRIDE; |
61 | 64 |
62 // Strips arguments if needed by policy. May return the original object (if | 65 // Strips arguments if needed by policy. May return the original object (if |
63 // unmodified), or a copy (if modifications were made). The implementation | 66 // unmodified), or a copy (if modifications were made). The implementation |
64 // in FullStreamUIPolicy returns the action unmodified. | 67 // in FullStreamUIPolicy returns the action unmodified. |
65 virtual scoped_refptr<Action> ProcessArguments( | 68 virtual scoped_refptr<Action> ProcessArguments( |
66 scoped_refptr<Action> action) const; | 69 scoped_refptr<Action> action) const; |
67 | 70 |
| 71 // The implementation of RemoveURLs; this must only run on the database |
| 72 // thread. |
| 73 virtual void DoRemoveURLs(const std::vector<GURL>& restrict_urls); |
| 74 |
68 // Tracks any pending updates to be written to the database, if write | 75 // Tracks any pending updates to be written to the database, if write |
69 // batching is turned on. Should only be accessed from the database thread. | 76 // batching is turned on. Should only be accessed from the database thread. |
70 Action::ActionVector queued_actions_; | 77 Action::ActionVector queued_actions_; |
71 | 78 |
72 private: | 79 private: |
73 // Adds an Action to queued_actions_; this should be invoked only on the | 80 // Adds an Action to queued_actions_; this should be invoked only on the |
74 // database thread. | 81 // database thread. |
75 void QueueAction(scoped_refptr<Action> action); | 82 void QueueAction(scoped_refptr<Action> action); |
76 | 83 |
77 // The implementation of ReadData; this must only run on the database thread. | 84 // The implementation of ReadData; this must only run on the database thread. |
78 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, | 85 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, |
79 const int days_ago); | 86 const int days_ago); |
80 }; | 87 }; |
81 | 88 |
82 } // namespace extensions | 89 } // namespace extensions |
83 | 90 |
84 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 91 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
OLD | NEW |