OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This class listens for notifications from the Google Push notifications | 5 // This class listens for notifications from the Google Push notifications |
6 // service, and signals when they arrive. It checks all incoming stanzas to | 6 // service, and signals when they arrive. It checks all incoming stanzas to |
7 // see if they look like notifications, and filters out those which are not | 7 // see if they look like notifications, and filters out those which are not |
8 // valid. | 8 // valid. |
9 // | 9 // |
10 // The task is deleted automatically by the buzz::XmppClient. This occurs in the | 10 // The task is deleted automatically by the buzz::XmppClient. This occurs in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class PushNotificationsListenTask : public buzz::XmppTask { | 26 class PushNotificationsListenTask : public buzz::XmppTask { |
27 public: | 27 public: |
28 class Delegate { | 28 class Delegate { |
29 public: | 29 public: |
30 virtual ~Delegate() {} | 30 virtual ~Delegate() {} |
31 virtual void OnNotificationReceived( | 31 virtual void OnNotificationReceived( |
32 const Notification& notification) = 0; | 32 const Notification& notification) = 0; |
33 }; | 33 }; |
34 | 34 |
35 explicit PushNotificationsListenTask(Task* parent, Delegate* delegate); | 35 PushNotificationsListenTask(Task* parent, Delegate* delegate); |
36 virtual ~PushNotificationsListenTask(); | 36 virtual ~PushNotificationsListenTask(); |
37 | 37 |
38 // Overriden from buzz::XmppTask. | 38 // Overriden from buzz::XmppTask. |
39 virtual int ProcessStart(); | 39 virtual int ProcessStart(); |
40 virtual int ProcessResponse(); | 40 virtual int ProcessResponse(); |
41 virtual bool HandleStanza(const buzz::XmlElement* stanza); | 41 virtual bool HandleStanza(const buzz::XmlElement* stanza); |
42 | 42 |
43 private: | 43 private: |
44 bool IsValidNotification(const buzz::XmlElement* stanza); | 44 bool IsValidNotification(const buzz::XmlElement* stanza); |
45 | 45 |
46 Delegate* delegate_; | 46 Delegate* delegate_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(PushNotificationsListenTask); | 48 DISALLOW_COPY_AND_ASSIGN(PushNotificationsListenTask); |
49 }; | 49 }; |
50 | 50 |
51 typedef PushNotificationsListenTask::Delegate | 51 typedef PushNotificationsListenTask::Delegate |
52 PushNotificationsListenTaskDelegate; | 52 PushNotificationsListenTaskDelegate; |
53 | 53 |
54 } // namespace notifier | 54 } // namespace notifier |
55 | 55 |
56 #endif // JINGLE_NOTIFIER_PUSH_NOTIFICATIONS_LISTENER_LISTEN_TASK_H_ | 56 #endif // JINGLE_NOTIFIER_PUSH_NOTIFICATIONS_LISTENER_LISTEN_TASK_H_ |
57 | 57 |
OLD | NEW |