Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / remoting / client / plugin / pepper_xmpp_proxy.h
blob0c1bc79615a3fa6663bb780b70abe60a54a2aef5
1 // Copyright (c) 2012 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_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "remoting/jingle_glue/xmpp_proxy.h"
13 namespace base {
14 class SingleThreadTaskRunner;
15 } // namespace base
17 namespace remoting {
19 class PepperXmppProxy : public XmppProxy {
20 public:
21 typedef base::Callback<void(const std::string&)> SendIqCallback;
23 // |plugin_task_runner| is the thread on which |send_iq_callback| is
24 // called. Normally the callback will call JavaScript, so this has
25 // to be the task runner that corresponds to the plugin
26 // thread. |callback_task_runner| is used to call the callback
27 // registered with AttachCallback().
28 PepperXmppProxy(
29 const SendIqCallback& send_iq_callback,
30 base::SingleThreadTaskRunner* plugin_task_runner,
31 base::SingleThreadTaskRunner* callback_task_runner);
33 // Registered the callback class with this object.
35 // - This method has subtle thread semantics! -
37 // It must be called on the callback thread itself. The weak pointer also
38 // must be constructed on the callback thread. That means, you cannot just
39 // create a WeakPtr on, say the pepper thread, and then pass execution of
40 // this function callback with the weak pointer bound as a parameter. That
41 // will fail because the WeakPtr will have been created on the wrong thread.
42 virtual void AttachCallback(
43 base::WeakPtr<ResponseCallback> callback) OVERRIDE;
44 virtual void DetachCallback() OVERRIDE;
46 virtual void SendIq(const std::string& request_xml) OVERRIDE;
47 virtual void OnIq(const std::string& response_xml);
49 private:
50 virtual ~PepperXmppProxy();
52 SendIqCallback send_iq_callback_;
54 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_;
55 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_;
57 // Must only be access on callback_message_loop_.
58 base::WeakPtr<ResponseCallback> callback_;
60 DISALLOW_COPY_AND_ASSIGN(PepperXmppProxy);
63 } // namespace remoting
65 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_XMPP_PROXY_H_