Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 PARAM_KEY_URL_TITLE, | 65 PARAM_KEY_URL_TITLE, |
| 66 PARAM_KEY_DETAILS_STRING, | 66 PARAM_KEY_DETAILS_STRING, |
| 67 PARAM_KEY_EXTRA, | 67 PARAM_KEY_EXTRA, |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Parameters are the profile and the thread that will be used to execute | 70 // Parameters are the profile and the thread that will be used to execute |
| 71 // the callback when ReadData is called. | 71 // the callback when ReadData is called. |
| 72 // TODO(felt,dbabic) Since only ReadData uses thread_id, it would be | 72 // TODO(felt,dbabic) Since only ReadData uses thread_id, it would be |
| 73 // cleaner to pass thread_id as a param of ReadData directly. | 73 // cleaner to pass thread_id as a param of ReadData directly. |
| 74 explicit ActivityLogPolicy(Profile* profile); | 74 explicit ActivityLogPolicy(Profile* profile); |
| 75 virtual ~ActivityLogPolicy(); | 75 |
| 76 virtual void Close() = 0; | |
| 76 | 77 |
| 77 // Updates the internal state of the model summarizing actions and possibly | 78 // Updates the internal state of the model summarizing actions and possibly |
| 78 // writes to the database. Implements the default policy storing internal | 79 // writes to the database. Implements the default policy storing internal |
| 79 // state to memory every 5 min. | 80 // state to memory every 5 min. |
| 80 virtual void ProcessAction( | 81 virtual void ProcessAction( |
| 81 ActionType action_type, | 82 ActionType action_type, |
| 82 const std::string& extension_id, | 83 const std::string& extension_id, |
| 83 const std::string& name, // action name | 84 const std::string& name, // action name |
| 84 const GURL& gurl, // target URL | 85 const GURL& gurl, // target URL |
| 85 const base::ListValue* args, // arguments | 86 const base::ListValue* args, // arguments |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 108 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) | 109 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) |
| 109 const {} | 110 const {} |
| 110 | 111 |
| 111 // For testing purposes --- disables periodic state saving, making the | 112 // For testing purposes --- disables periodic state saving, making the |
| 112 // behavior reproducible. | 113 // behavior reproducible. |
| 113 virtual void SetSaveStateOnRequestOnly(); | 114 virtual void SetSaveStateOnRequestOnly(); |
| 114 | 115 |
| 115 virtual std::string GetKey(KeyType key_id) const; | 116 virtual std::string GetKey(KeyType key_id) const; |
| 116 | 117 |
| 117 protected: | 118 protected: |
| 119 // An ActivityLogPolicy is not directly destroyed. Instead, call Close() | |
| 120 // which will cause the object to be deleted when it is safe. | |
| 121 virtual ~ActivityLogPolicy(); | |
| 122 | |
| 118 // The Schedule methods dispatch the calls to the database on a | 123 // The Schedule methods dispatch the calls to the database on a |
| 119 // separate thread. We dispatch to the UI thread if the DB thread doesn't | 124 // separate thread. We dispatch to the UI thread if the DB thread doesn't |
| 120 // exist, which should only happen in tests where there is no DB thread. | 125 // exist, which should only happen in tests where there is no DB thread. |
| 121 template<typename DatabaseType, typename DatabaseFunc> | 126 template<typename DatabaseType, typename DatabaseFunc> |
| 122 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { | 127 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { |
| 123 content::BrowserThread::PostTask( | 128 content::BrowserThread::PostTask( |
| 124 content::BrowserThread::DB, | 129 content::BrowserThread::DB, |
| 125 FROM_HERE, | 130 FROM_HERE, |
| 126 base::Bind(func, base::Unretained(db))); | 131 base::Bind(func, base::Unretained(db))); |
| 127 } | 132 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 138 typename ArgA, typename ArgB> | 143 typename ArgA, typename ArgB> |
| 139 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { | 144 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { |
| 140 content::BrowserThread::PostTask( | 145 content::BrowserThread::PostTask( |
| 141 content::BrowserThread::DB, | 146 content::BrowserThread::DB, |
| 142 FROM_HERE, | 147 FROM_HERE, |
| 143 base::Bind(func, base::Unretained(db), a, b)); | 148 base::Bind(func, base::Unretained(db), a, b)); |
| 144 } | 149 } |
| 145 | 150 |
| 146 base::FilePath profile_base_path_; | 151 base::FilePath profile_base_path_; |
| 147 base::RepeatingTimer<ActivityLogPolicy> timer_; | 152 base::RepeatingTimer<ActivityLogPolicy> timer_; |
| 153 | |
| 154 private: | |
| 155 DISALLOW_COPY_AND_ASSIGN(ActivityLogPolicy); | |
|
felt
2013/07/09 22:14:51
yikes. is this missing in other policy files too?
mvrable
2013/07/09 23:03:22
Yes, it was missing in the ActivityLogPolicy subcl
felt
2013/07/10 00:14:36
If it's inherited, then nevermind. Thanks for catc
| |
| 148 }; | 156 }; |
| 149 | 157 |
| 150 } // namespace extensions | 158 } // namespace extensions |
| 151 | 159 |
| 152 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 160 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
| OLD | NEW |