OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ |
6 #define CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ | 6 #define CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ |
7 | 7 |
8 #include "base/lock.h" | 8 #include "base/lock.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 std::string extension_id; | 35 std::string extension_id; |
36 | 36 |
37 // How many times the extension successfully invoked a write | 37 // How many times the extension successfully invoked a write |
38 // operation through the bookmarks API since the last CommitMessage. | 38 // operation through the bookmarks API since the last CommitMessage. |
39 uint32 bookmark_write_count; | 39 uint32 bookmark_write_count; |
40 }; | 40 }; |
41 | 41 |
42 typedef std::map<std::string, Record> Records; | 42 typedef std::map<std::string, Record> Records; |
43 | 43 |
44 // Creates an ExtensionsActivityMonitor to monitor extensions activities on | 44 // Creates an ExtensionsActivityMonitor to monitor extensions activities on |
45 // |ui_loop|. | 45 // ChromeThread::UI. |
46 explicit ExtensionsActivityMonitor(MessageLoop* ui_loop); | 46 ExtensionsActivityMonitor(); |
47 ~ExtensionsActivityMonitor(); | 47 ~ExtensionsActivityMonitor(); |
48 | 48 |
49 // Fills |buffer| with snapshot of current records in constant time by | 49 // Fills |buffer| with snapshot of current records in constant time by |
50 // swapping. This is done mutually exclusively w.r.t methods of this class. | 50 // swapping. This is done mutually exclusively w.r.t methods of this class. |
51 void GetAndClearRecords(Records* buffer); | 51 void GetAndClearRecords(Records* buffer); |
52 | 52 |
53 // Add |records| piece-wise (by extension id) to the set of active records. | 53 // Add |records| piece-wise (by extension id) to the set of active records. |
54 // This is done mutually exclusively w.r.t the methods of this class. | 54 // This is done mutually exclusively w.r.t the methods of this class. |
55 void PutRecords(const Records& records); | 55 void PutRecords(const Records& records); |
56 | 56 |
57 // NotificationObserver implementation. Called on |ui_loop_|. | 57 // NotificationObserver implementation. Called on |ui_loop_|. |
58 virtual void Observe(NotificationType type, | 58 virtual void Observe(NotificationType type, |
59 const NotificationSource& source, | 59 const NotificationSource& source, |
60 const NotificationDetails& details); | 60 const NotificationDetails& details); |
61 private: | 61 private: |
62 Records records_; | 62 Records records_; |
63 mutable Lock records_lock_; | 63 mutable Lock records_lock_; |
64 | 64 |
65 // Kept for convenience. | |
66 MessageLoop* const ui_loop_; | |
67 | |
68 // Used only from UI loop. | 65 // Used only from UI loop. |
69 NotificationRegistrar registrar_; | 66 NotificationRegistrar registrar_; |
70 }; | 67 }; |
71 | 68 |
72 } // namespace browser_sync | 69 } // namespace browser_sync |
73 | 70 |
74 #endif // CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ | 71 #endif // CHROME_BROWSER_SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ |
OLD | NEW |