Roll src/third_party/WebKit 787a07c:716df21 (svn 201034:201036)
[chromium-blink-merge.git] / remoting / signaling / push_notification_subscriber.h
blob19b8c09a0c1203e038b84e1d58d3bb7a6e998c5e
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_GCD_NOTIFICATION_SUBSCRIBER_H_
6 #define REMOTING_HOST_GCD_NOTIFICATION_SUBSCRIBER_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/signaling/signal_strategy.h"
15 namespace remoting {
17 class IqSender;
18 class IqRequest;
20 // An object that subscribes to push notifications using an XMPP
21 // channel. The notifications themselves are ignored, but creating a
22 // subscription is necessary, e.g., for GCD to see a device as online.
23 class PushNotificationSubscriber : public SignalStrategy::Listener {
24 public:
25 struct Subscription {
26 Subscription();
27 ~Subscription();
29 std::string channel;
30 std::string from;
33 typedef std::vector<Subscription> SubscriptionList;
35 PushNotificationSubscriber(SignalStrategy* signal_strategy,
36 const SubscriptionList& subscriptions);
37 ~PushNotificationSubscriber() override;
39 private:
40 // SignalStrategy::Listener interface.
41 void OnSignalStrategyStateChange(SignalStrategy::State state) override;
42 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override;
44 void Subscribe(const Subscription& subscription);
45 void OnSubscriptionResult(IqRequest* request,
46 const buzz::XmlElement* response);
48 SignalStrategy* signal_strategy_;
49 SubscriptionList subscriptions_;
50 scoped_ptr<IqSender> iq_sender_;
51 scoped_ptr<IqRequest> iq_request_;
53 DISALLOW_COPY_AND_ASSIGN(PushNotificationSubscriber);
56 } // namespace remoting
58 #endif // REMOTING_HOST_GCD_NOTIFICATION_SUBSCRIBER_H_