summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue/xmpp_proxy.h
blob: 34bb9741dca9f0fc390ae2628b98faf9dd5ea82c (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
// Copyright (c) 2011 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.

// The XmppProxy is a shim interface that allows a class from layers above
// the protocol to insert custom logic for dispatching the XMPP requests
// necessary for creating a jingle connection.
//
// The primary motivator for this is to allow libjingle to be sandboxed in the
// client by proxying the XMPP requests up through javascript into a
// javascript-based XMPP connection back into the GoogleTalk network.  It's
// essentially a clean hack.

#ifndef REMOTING_JINGLE_GLUE_XMPP_PROXY_H_
#define REMOTING_JINGLE_GLUE_XMPP_PROXY_H_

#include <string>

#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"

namespace remoting {

class XmppProxy : public base::RefCountedThreadSafe<XmppProxy> {
 public:
  XmppProxy() {}

  class ResponseCallback : public base::SupportsWeakPtr<ResponseCallback> {
   public:
    ResponseCallback() {}
    virtual ~ResponseCallback() {}
    virtual void OnIq(const std::string& response_xml) = 0;

   private:
    DISALLOW_COPY_AND_ASSIGN(ResponseCallback);
  };

  // These two must be called on the callback's message_loop. Callback will
  // always been run on the callback_loop.
  virtual void AttachCallback(base::WeakPtr<ResponseCallback> callback) = 0;
  virtual void DetachCallback() = 0;

  virtual void SendIq(const std::string& iq_request_xml) = 0;

 protected:
  friend class base::RefCountedThreadSafe<XmppProxy>;
  virtual ~XmppProxy() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(XmppProxy);
};

}  // namespace remoting

#endif  // REMOTING_JINGLE_GLUE_XMPP_PROXY_H_