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_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // each observer's OnIncomingNotification method on these | 28 // each observer's OnIncomingNotification method on these |
29 // notifications (on the sync task runner). | 29 // notifications (on the sync task runner). |
30 class ChromeSyncNotificationBridge : public content::NotificationObserver { | 30 class ChromeSyncNotificationBridge : public content::NotificationObserver { |
31 public: | 31 public: |
32 // Must be created and destroyed on the UI thread. | 32 // Must be created and destroyed on the UI thread. |
33 ChromeSyncNotificationBridge( | 33 ChromeSyncNotificationBridge( |
34 const Profile* profile, | 34 const Profile* profile, |
35 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner); | 35 const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner); |
36 virtual ~ChromeSyncNotificationBridge(); | 36 virtual ~ChromeSyncNotificationBridge(); |
37 | 37 |
38 // Must be called on the UI thread. | |
39 void UpdateEnabledTypes(const syncer::ModelTypeSet enabled_types); | |
40 | |
41 // Must be called on the sync task runner. | 38 // Must be called on the sync task runner. |
| 39 void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types); |
| 40 // Marked virtual for tests. |
42 virtual void AddObserver(syncer::SyncNotifierObserver* observer); | 41 virtual void AddObserver(syncer::SyncNotifierObserver* observer); |
43 virtual void RemoveObserver(syncer::SyncNotifierObserver* observer); | 42 virtual void RemoveObserver(syncer::SyncNotifierObserver* observer); |
44 | 43 |
45 // NotificationObserver implementation. Called on UI thread. | 44 // NotificationObserver implementation. Called on UI thread. |
46 virtual void Observe(int type, | 45 virtual void Observe(int type, |
47 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
48 const content::NotificationDetails& details) OVERRIDE; | 47 const content::NotificationDetails& details) OVERRIDE; |
49 | 48 |
50 private: | 49 private: |
51 // Inner class to hold all the bits used on |sync_task_runner_|. | 50 // Inner class to hold all the bits used on |sync_task_runner_|. |
52 class Core; | 51 class Core; |
53 | 52 |
54 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; | 53 const scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; |
55 | 54 |
56 // Created on the UI thread, used only on |sync_task_runner_|. | 55 // Created on the UI thread, used only on |sync_task_runner_|. |
57 const scoped_refptr<Core> core_; | 56 const scoped_refptr<Core> core_; |
58 | 57 |
59 // Used only on the UI thread. | 58 // Used only on the UI thread. |
60 content::NotificationRegistrar registrar_; | 59 content::NotificationRegistrar registrar_; |
61 syncer::ModelTypeSet enabled_types_; | |
62 }; | 60 }; |
63 | 61 |
64 } // namespace browser_sync | 62 } // namespace browser_sync |
65 | 63 |
66 #endif // CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ | 64 #endif // CHROME_BROWSER_SYNC_GLUE_CHROME_SYNC_NOTIFICATION_BRIDGE_H_ |
OLD | NEW |