OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // A notifier that uses p2p notifications based on XMPP push | 5 // A notifier that uses p2p notifications based on XMPP push |
6 // notifications. Used only for sync integration tests. | 6 // notifications. Used only for sync integration tests. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ | 8 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ |
9 #define CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ | 9 #define CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "chrome/browser/sync/notifier/sync_notifier.h" | 15 #include "chrome/browser/sync/notifier/sync_notifier.h" |
16 #include "chrome/browser/sync/syncable/model_type.h" | 16 #include "chrome/browser/sync/syncable/model_type.h" |
17 #include "jingle/notifier/listener/talk_mediator.h" | 17 #include "jingle/notifier/listener/talk_mediator.h" |
18 | 18 |
| 19 class MessageLoop; |
| 20 |
19 namespace notifier { | 21 namespace notifier { |
20 struct NotifierOptions; | 22 struct NotifierOptions; |
21 } // namespace | 23 } // namespace |
22 | 24 |
23 namespace sync_notifier { | 25 namespace sync_notifier { |
24 | 26 |
25 class P2PNotifier | 27 class P2PNotifier |
26 : public SyncNotifier, | 28 : public SyncNotifier, |
27 public notifier::TalkMediator::Delegate { | 29 public notifier::TalkMediator::Delegate { |
28 public: | 30 public: |
(...skipping 13 matching lines...) Expand all Loading... |
42 // TalkMediator::Delegate implementation. | 44 // TalkMediator::Delegate implementation. |
43 virtual void OnNotificationStateChange(bool notifications_enabled); | 45 virtual void OnNotificationStateChange(bool notifications_enabled); |
44 virtual void OnIncomingNotification( | 46 virtual void OnIncomingNotification( |
45 const notifier::Notification& notification); | 47 const notifier::Notification& notification); |
46 virtual void OnOutgoingNotification(); | 48 virtual void OnOutgoingNotification(); |
47 | 49 |
48 private: | 50 private: |
49 // Call OnIncomingNotification() on observers if we have a non-empty | 51 // Call OnIncomingNotification() on observers if we have a non-empty |
50 // set of enabled types. | 52 // set of enabled types. |
51 void MaybeEmitNotification(); | 53 void MaybeEmitNotification(); |
| 54 void CheckOrSetValidThread(); |
52 | 55 |
53 ObserverList<SyncNotifierObserver> observer_list_; | 56 ObserverList<SyncNotifierObserver> observer_list_; |
54 | 57 |
55 // The actual notification listener. | 58 // The actual notification listener. |
56 scoped_ptr<notifier::TalkMediator> talk_mediator_; | 59 scoped_ptr<notifier::TalkMediator> talk_mediator_; |
57 // Whether we called Login() on |talk_mediator_| yet. | 60 // Whether we called Login() on |talk_mediator_| yet. |
58 bool logged_in_; | 61 bool logged_in_; |
59 // Whether |talk_mediator_| has notified us that notifications are | 62 // Whether |talk_mediator_| has notified us that notifications are |
60 // enabled. | 63 // enabled. |
61 bool notifications_enabled_; | 64 bool notifications_enabled_; |
62 | 65 |
63 syncable::ModelTypeSet enabled_types_; | 66 syncable::ModelTypeSet enabled_types_; |
| 67 MessageLoop* construction_message_loop_; |
| 68 MessageLoop* method_message_loop_; |
64 }; | 69 }; |
65 | 70 |
66 } | 71 } // namespace sync_notifier |
67 #endif // CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ | 72 #endif // CHROME_BROWSER_SYNC_NOTIFIER_P2P_NOTIFIER_H_ |
OLD | NEW |