OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 // BrowserContextKeyedService | 149 // BrowserContextKeyedService |
150 virtual void Shutdown() OVERRIDE; | 150 virtual void Shutdown() OVERRIDE; |
151 | 151 |
152 private: | 152 private: |
153 friend class ActivityLogFactory; | 153 friend class ActivityLogFactory; |
154 | 154 |
155 explicit ActivityLog(Profile* profile); | 155 explicit ActivityLog(Profile* profile); |
156 virtual ~ActivityLog(); | 156 virtual ~ActivityLog(); |
157 | 157 |
| 158 // Reset the database in case of persistent catastrophic errors. |
| 159 void DatabaseErrorCallback(int error, sql::Statement* stmt); |
| 160 |
158 // We log callbacks and API calls very similarly, so we handle them the same | 161 // We log callbacks and API calls very similarly, so we handle them the same |
159 // way internally. | 162 // way internally. |
160 void LogAPIActionInternal( | 163 void LogAPIActionInternal( |
161 const std::string& extension_id, | 164 const std::string& extension_id, |
162 const std::string& api_call, | 165 const std::string& api_call, |
163 ListValue* args, | 166 ListValue* args, |
164 const std::string& extra, | 167 const std::string& extra, |
165 const APIAction::Type type); | 168 const APIAction::Type type); |
166 | 169 |
167 // TabHelper::ScriptExecutionObserver implementation. | 170 // TabHelper::ScriptExecutionObserver implementation. |
168 // Fires when a ContentScript is executed. | 171 // Fires when a ContentScript is executed. |
169 virtual void OnScriptsExecuted( | 172 virtual void OnScriptsExecuted( |
170 const content::WebContents* web_contents, | 173 const content::WebContents* web_contents, |
171 const ExecutingScriptsMap& extension_ids, | 174 const ExecutingScriptsMap& extension_ids, |
172 int32 page_id, | 175 int32 page_id, |
173 const GURL& on_url) OVERRIDE; | 176 const GURL& on_url) OVERRIDE; |
174 | 177 |
| 178 // The callback when initializing the database. |
| 179 void OnDBInitComplete(); |
| 180 |
175 // The Schedule methods dispatch the calls to the database on a | 181 // The Schedule methods dispatch the calls to the database on a |
176 // separate thread. We dispatch to the UI thread if the DB thread doesn't | 182 // separate thread. We dispatch to the UI thread if the DB thread doesn't |
177 // exist, which should only happen in tests where there is no DB thread. | 183 // exist, which should only happen in tests where there is no DB thread. |
178 template<typename DatabaseFunc> | 184 template<typename DatabaseFunc> |
179 void ScheduleAndForget(DatabaseFunc func) { | 185 void ScheduleAndForget(DatabaseFunc func) { |
180 if (!has_threads_) return; | 186 if (!has_threads_) return; |
181 BrowserThread::PostTask(BrowserThread::DB, | 187 BrowserThread::PostTask(BrowserThread::DB, |
182 FROM_HERE, | 188 FROM_HERE, |
183 base::Bind(func, base::Unretained(db_))); | 189 base::Bind(func, base::Unretained(db_))); |
184 } | 190 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 virtual content::BrowserContext* GetBrowserContextToUse( | 258 virtual content::BrowserContext* GetBrowserContextToUse( |
253 content::BrowserContext* context) const OVERRIDE; | 259 content::BrowserContext* context) const OVERRIDE; |
254 | 260 |
255 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 261 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
256 }; | 262 }; |
257 | 263 |
258 | 264 |
259 } // namespace extensions | 265 } // namespace extensions |
260 | 266 |
261 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 267 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
OLD | NEW |