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_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // The callback when initializing the database. | 159 // The callback when initializing the database. |
160 void OnDBInitComplete(); | 160 void OnDBInitComplete(); |
161 | 161 |
162 static const char* ActivityToString(Activity activity); | 162 static const char* ActivityToString(Activity activity); |
163 | 163 |
164 // The Schedule methods dispatch the calls to the database on a | 164 // The Schedule methods dispatch the calls to the database on a |
165 // separate thread. | 165 // separate thread. |
166 template<typename DatabaseFunc> | 166 template<typename DatabaseFunc> |
167 void ScheduleAndForget(DatabaseFunc func) { | 167 void ScheduleAndForget(DatabaseFunc func) { |
168 if (db_.get()) | 168 if (db_) |
169 BrowserThread::PostTask(BrowserThread::DB, | 169 BrowserThread::PostTask(BrowserThread::DB, |
170 FROM_HERE, | 170 FROM_HERE, |
171 base::Bind(func, db_.get())); | 171 base::Bind(func, db_.get())); |
172 } | 172 } |
173 | 173 |
174 template<typename DatabaseFunc, typename ArgA> | 174 template<typename DatabaseFunc, typename ArgA> |
175 void ScheduleAndForget(DatabaseFunc func, ArgA a) { | 175 void ScheduleAndForget(DatabaseFunc func, ArgA a) { |
176 if (db_.get()) | 176 if (db_) |
177 BrowserThread::PostTask(BrowserThread::DB, | 177 BrowserThread::PostTask(BrowserThread::DB, |
178 FROM_HERE, | 178 FROM_HERE, |
179 base::Bind(func, db_.get(), a)); | 179 base::Bind(func, db_.get(), a)); |
180 } | 180 } |
181 | 181 |
182 template<typename DatabaseFunc, typename ArgA, typename ArgB> | 182 template<typename DatabaseFunc, typename ArgA, typename ArgB> |
183 void ScheduleAndForget(DatabaseFunc func, ArgA a, ArgB b) { | 183 void ScheduleAndForget(DatabaseFunc func, ArgA a, ArgB b) { |
184 if (db_.get()) | 184 if (db_) |
185 BrowserThread::PostTask(BrowserThread::DB, | 185 BrowserThread::PostTask(BrowserThread::DB, |
186 FROM_HERE, | 186 FROM_HERE, |
187 base::Bind(func, db_.get(), a, b)); | 187 base::Bind(func, db_.get(), a, b)); |
188 } | 188 } |
189 | 189 |
190 typedef ObserverListThreadSafe<Observer> ObserverList; | 190 typedef ObserverListThreadSafe<Observer> ObserverList; |
191 typedef std::map<const Extension*, scoped_refptr<ObserverList> > | 191 typedef std::map<const Extension*, scoped_refptr<ObserverList> > |
192 ObserverMap; | 192 ObserverMap; |
193 // A map of extensions to activity observers for that extension. | 193 // A map of extensions to activity observers for that extension. |
194 ObserverMap observers_; | 194 ObserverMap observers_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; | 234 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; |
235 | 235 |
236 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 236 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
237 }; | 237 }; |
238 | 238 |
239 | 239 |
240 } // namespace extensions | 240 } // namespace extensions |
241 | 241 |
242 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 242 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
OLD | NEW |