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