summaryrefslogtreecommitdiff
path: root/chromium/jingle/notifier/listener/send_ping_task.h
blob: 9cd8b2282392e70ed9b781f99434d973aab3fc36 (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
// 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.
//
// Methods for sending the update stanza to notify peers via xmpp.

#ifndef JINGLE_NOTIFIER_LISTENER_SEND_PING_TASK_H_
#define JINGLE_NOTIFIER_LISTENER_SEND_PING_TASK_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "talk/xmpp/xmpptask.h"

namespace buzz {
class XmlElement;
}  // namespace

namespace notifier {

class SendPingTask : public buzz::XmppTask {
 public:
  class Delegate {
   public:
    virtual void OnPingResponseReceived() = 0;

   protected:
    virtual ~Delegate();
  };

  SendPingTask(buzz::XmppTaskParentInterface* parent, Delegate* delegate);
  virtual ~SendPingTask();

  // Overridden from buzz::XmppTask.
  virtual int ProcessStart() OVERRIDE;
  virtual int ProcessResponse() OVERRIDE;
  virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE;

 private:
  static buzz::XmlElement* MakePingStanza(const std::string& task_id);

  FRIEND_TEST_ALL_PREFIXES(SendPingTaskTest, MakePingStanza);

  std::string ping_task_id_;
  Delegate* delegate_;

  DISALLOW_COPY_AND_ASSIGN(SendPingTask);
};

typedef SendPingTask::Delegate SendPingTaskDelegate;

}  // namespace notifier

#endif  // JINGLE_NOTIFIER_LISTENER_SEND_PING_TASK_H_