Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / remoting / client / plugin / pepper_xmpp_proxy.cc
blobf289092f975e97b9a68854e428b6d3dc95bc9c6d
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 #include "remoting/client/plugin/pepper_xmpp_proxy.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop_proxy.h"
11 namespace remoting {
13 PepperXmppProxy::PepperXmppProxy(
14 const SendIqCallback& send_iq_callback,
15 base::SingleThreadTaskRunner* plugin_task_runner,
16 base::SingleThreadTaskRunner* callback_task_runner)
17 : send_iq_callback_(send_iq_callback),
18 plugin_task_runner_(plugin_task_runner),
19 callback_task_runner_(callback_task_runner) {
20 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
23 PepperXmppProxy::~PepperXmppProxy() {
26 void PepperXmppProxy::AttachCallback(
27 base::WeakPtr<ResponseCallback> callback) {
28 DCHECK(callback_task_runner_->BelongsToCurrentThread());
29 callback_ = callback;
32 void PepperXmppProxy::DetachCallback() {
33 DCHECK(callback_task_runner_->BelongsToCurrentThread());
34 callback_.reset();
37 void PepperXmppProxy::SendIq(const std::string& request_xml) {
38 if (!plugin_task_runner_->BelongsToCurrentThread()) {
39 plugin_task_runner_->PostTask(FROM_HERE, base::Bind(
40 &PepperXmppProxy::SendIq, this, request_xml));
41 return;
44 send_iq_callback_.Run(request_xml);
47 void PepperXmppProxy::OnIq(const std::string& response_xml) {
48 if (!callback_task_runner_->BelongsToCurrentThread()) {
49 callback_task_runner_->PostTask(
50 FROM_HERE, base::Bind(&PepperXmppProxy::OnIq, this, response_xml));
51 return;
54 if (callback_)
55 callback_->OnIq(response_xml);
58 } // namespace remoting