blob: 62d408b2ed27f74155355e3997ba88240fb0b102 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This class listens for notifications from the Google Push notifications
// service, and signals when they arrive. It checks all incoming stanzas to
// see if they look like notifications, and filters out those which are not
// valid.
//
// The task is deleted automatically by the buzz::XmppClient. This occurs in the
// destructor of TaskRunner, which is a superclass of buzz::XmppClient.
#ifndef JINGLE_NOTIFIER_PUSH_NOTIFICATIONS_LISTENER_LISTEN_TASK_H_
#define JINGLE_NOTIFIER_PUSH_NOTIFICATIONS_LISTENER_LISTEN_TASK_H_
#include "base/compiler_specific.h"
#include "talk/xmpp/xmpptask.h"
namespace buzz {
class XmlElement;
}
namespace notifier {
struct Notification;
class PushNotificationsListenTask : public buzz::XmppTask {
public:
class Delegate {
public:
virtual void OnNotificationReceived(const Notification& notification) = 0;
protected:
virtual ~Delegate();
};
PushNotificationsListenTask(buzz::XmppTaskParentInterface* parent,
Delegate* delegate);
virtual ~PushNotificationsListenTask();
// Overriden from buzz::XmppTask.
virtual int ProcessStart() OVERRIDE;
virtual int ProcessResponse() OVERRIDE;
virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE;
private:
bool IsValidNotification(const buzz::XmlElement* stanza);
Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(PushNotificationsListenTask);
};
typedef PushNotificationsListenTask::Delegate
PushNotificationsListenTaskDelegate;
} // namespace notifier
#endif // JINGLE_NOTIFIER_PUSH_NOTIFICATIONS_LISTENER_LISTEN_TASK_H_
|