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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const std::string& page_url, | 46 const std::string& page_url, |
47 const std::string& arg_url, | 47 const std::string& arg_url, |
48 const base::Callback | 48 const base::Callback |
49 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; | 49 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; |
50 | 50 |
51 virtual void Close() OVERRIDE; | 51 virtual void Close() OVERRIDE; |
52 | 52 |
53 // Clean the URL data stored for this policy. | 53 // Clean the URL data stored for this policy. |
54 virtual void RemoveURLs(const std::vector<GURL>& restrict_urls) OVERRIDE; | 54 virtual void RemoveURLs(const std::vector<GURL>& restrict_urls) OVERRIDE; |
55 | 55 |
| 56 // Delete everything in the database. |
| 57 virtual void DeleteDatabase() OVERRIDE; |
| 58 |
56 // Database table schema. | 59 // Database table schema. |
57 static const char* kTableName; | 60 static const char* kTableName; |
58 static const char* kTableContentFields[]; | 61 static const char* kTableContentFields[]; |
59 static const char* kTableFieldTypes[]; | 62 static const char* kTableFieldTypes[]; |
60 static const int kTableFieldCount; | 63 static const int kTableFieldCount; |
61 | 64 |
62 protected: | 65 protected: |
63 // Only ever run by OnDatabaseClose() below; see the comments on the | 66 // Only ever run by OnDatabaseClose() below; see the comments on the |
64 // ActivityDatabase class for an overall discussion of how cleanup works. | 67 // ActivityDatabase class for an overall discussion of how cleanup works. |
65 virtual ~FullStreamUIPolicy(); | 68 virtual ~FullStreamUIPolicy(); |
66 | 69 |
67 // The ActivityDatabase::Delegate interface. These are always called from | 70 // The ActivityDatabase::Delegate interface. These are always called from |
68 // the database thread. | 71 // the database thread. |
69 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; | 72 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; |
70 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; | 73 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; |
71 virtual void OnDatabaseFailure() OVERRIDE; | 74 virtual void OnDatabaseFailure() OVERRIDE; |
72 virtual void OnDatabaseClose() OVERRIDE; | 75 virtual void OnDatabaseClose() OVERRIDE; |
73 | 76 |
74 // Strips arguments if needed by policy. May return the original object (if | 77 // Strips arguments if needed by policy. May return the original object (if |
75 // unmodified), or a copy (if modifications were made). The implementation | 78 // unmodified), or a copy (if modifications were made). The implementation |
76 // in FullStreamUIPolicy returns the action unmodified. | 79 // in FullStreamUIPolicy returns the action unmodified. |
77 virtual scoped_refptr<Action> ProcessArguments( | 80 virtual scoped_refptr<Action> ProcessArguments( |
78 scoped_refptr<Action> action) const; | 81 scoped_refptr<Action> action) const; |
79 | 82 |
80 // The implementation of RemoveURLs; this must only run on the database | 83 // The implementation of RemoveURLs; this must only run on the database |
81 // thread. | 84 // thread. |
82 virtual void DoRemoveURLs(const std::vector<GURL>& restrict_urls); | 85 void DoRemoveURLs(const std::vector<GURL>& restrict_urls); |
| 86 |
| 87 // The implementation of DeleteDatabase; this must only run on the database |
| 88 // thread. |
| 89 void DoDeleteDatabase(); |
83 | 90 |
84 // Tracks any pending updates to be written to the database, if write | 91 // Tracks any pending updates to be written to the database, if write |
85 // batching is turned on. Should only be accessed from the database thread. | 92 // batching is turned on. Should only be accessed from the database thread. |
86 Action::ActionVector queued_actions_; | 93 Action::ActionVector queued_actions_; |
87 | 94 |
88 private: | 95 private: |
89 // Adds an Action to queued_actions_; this should be invoked only on the | 96 // Adds an Action to queued_actions_; this should be invoked only on the |
90 // database thread. | 97 // database thread. |
91 void QueueAction(scoped_refptr<Action> action); | 98 void QueueAction(scoped_refptr<Action> action); |
92 | 99 |
93 // The implementation of ReadData; this must only run on the database thread. | 100 // The implementation of ReadData; this must only run on the database thread. |
94 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, | 101 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, |
95 const int days_ago); | 102 const int days_ago); |
96 | 103 |
97 // Internal method to read data from the database; called on the database | 104 // Internal method to read data from the database; called on the database |
98 // thread. | 105 // thread. |
99 scoped_ptr<Action::ActionVector> DoReadFilteredData( | 106 scoped_ptr<Action::ActionVector> DoReadFilteredData( |
100 const std::string& extension_id, | 107 const std::string& extension_id, |
101 const Action::ActionType type, | 108 const Action::ActionType type, |
102 const std::string& api_name, | 109 const std::string& api_name, |
103 const std::string& page_url, | 110 const std::string& page_url, |
104 const std::string& arg_url); | 111 const std::string& arg_url); |
105 }; | 112 }; |
106 | 113 |
107 } // namespace extensions | 114 } // namespace extensions |
108 | 115 |
109 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 116 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
OLD | NEW |