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 JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ | 5 #ifndef JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ |
6 #define JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ | 6 #define JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "jingle/notifier/listener/push_client.h" | 16 #include "jingle/notifier/listener/push_client.h" |
| 17 #include "jingle/notifier/listener/push_client_observer.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
20 } // namespace base | 21 } // namespace base |
21 | 22 |
22 namespace notifier { | 23 namespace notifier { |
23 | 24 |
24 // This class implements a PushClient that doesn't block; it delegates | 25 // This class implements a PushClient that doesn't block; it delegates |
25 // to another blocking PushClient on a separate thread. | 26 // to another blocking PushClient on a separate thread. |
26 // | 27 // |
(...skipping 18 matching lines...) Expand all Loading... |
45 virtual void RemoveObserver(PushClientObserver* observer) OVERRIDE; | 46 virtual void RemoveObserver(PushClientObserver* observer) OVERRIDE; |
46 virtual void UpdateSubscriptions( | 47 virtual void UpdateSubscriptions( |
47 const SubscriptionList& subscriptions) OVERRIDE; | 48 const SubscriptionList& subscriptions) OVERRIDE; |
48 virtual void UpdateCredentials( | 49 virtual void UpdateCredentials( |
49 const std::string& email, const std::string& token) OVERRIDE; | 50 const std::string& email, const std::string& token) OVERRIDE; |
50 virtual void SendNotification(const Notification& notification) OVERRIDE; | 51 virtual void SendNotification(const Notification& notification) OVERRIDE; |
51 | 52 |
52 private: | 53 private: |
53 class Core; | 54 class Core; |
54 | 55 |
55 void OnNotificationStateChange(bool notifications_enabled); | 56 void OnNotificationsEnabled(); |
| 57 void OnNotificationsDisabled(NotificationsDisabledReason reason); |
56 void OnIncomingNotification(const Notification& notification); | 58 void OnIncomingNotification(const Notification& notification); |
57 | 59 |
58 base::NonThreadSafe non_thread_safe_; | 60 base::NonThreadSafe non_thread_safe_; |
59 base::WeakPtrFactory<NonBlockingPushClient> weak_ptr_factory_; | 61 base::WeakPtrFactory<NonBlockingPushClient> weak_ptr_factory_; |
60 const scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; | 62 const scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; |
61 const scoped_refptr<Core> core_; | 63 const scoped_refptr<Core> core_; |
62 | 64 |
63 ObserverList<PushClientObserver> observers_; | 65 ObserverList<PushClientObserver> observers_; |
64 | 66 |
65 DISALLOW_COPY_AND_ASSIGN(NonBlockingPushClient); | 67 DISALLOW_COPY_AND_ASSIGN(NonBlockingPushClient); |
66 }; | 68 }; |
67 | 69 |
68 } // namespace notifier | 70 } // namespace notifier |
69 | 71 |
70 #endif // JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ | 72 #endif // JINGLE_NOTIFIER_LISTENER_NON_BLOCKING_PUSH_CLIENT_H_ |
OLD | NEW |