summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 03:03:07 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-21 03:03:07 +0000
commitae671ec0bed00353c498fc5b096d3b1c18a8bd23 (patch)
tree15b5914f2e51d9b4c95fe513d302f12dc0567730 /remoting
parent4f2c9c3f70ac0779bc6b42216ff2411541cc7763 (diff)
downloadchromium_src-ae671ec0bed00353c498fc5b096d3b1c18a8bd23.zip
chromium_src-ae671ec0bed00353c498fc5b096d3b1c18a8bd23.tar.gz
chromium_src-ae671ec0bed00353c498fc5b096d3b1c18a8bd23.tar.bz2
Merge IqRequest implementations.
Removed XmppIqRequest and renamed JavascriptIqRequest to IqRequest. BUG=None TEST=None Review URL: http://codereview.chromium.org/8345031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/jingle_glue/fake_signal_strategy.cc2
-rw-r--r--remoting/jingle_glue/fake_signal_strategy.h4
-rw-r--r--remoting/jingle_glue/iq_request.cc90
-rw-r--r--remoting/jingle_glue/iq_request.h63
-rw-r--r--remoting/jingle_glue/javascript_iq_request.cc97
-rw-r--r--remoting/jingle_glue/javascript_iq_request.h73
-rw-r--r--remoting/jingle_glue/javascript_signal_strategy.cc2
-rw-r--r--remoting/jingle_glue/javascript_signal_strategy.h4
-rw-r--r--remoting/jingle_glue/jingle_signaling_connector.cc2
-rw-r--r--remoting/jingle_glue/jingle_signaling_connector.h5
-rw-r--r--remoting/jingle_glue/xmpp_iq_request.cc60
-rw-r--r--remoting/jingle_glue/xmpp_iq_request.h49
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.cc16
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.h7
-rw-r--r--remoting/remoting.gyp4
15 files changed, 164 insertions, 314 deletions
diff --git a/remoting/jingle_glue/fake_signal_strategy.cc b/remoting/jingle_glue/fake_signal_strategy.cc
index be95819..0f7fb77 100644
--- a/remoting/jingle_glue/fake_signal_strategy.cc
+++ b/remoting/jingle_glue/fake_signal_strategy.cc
@@ -78,7 +78,7 @@ std::string FakeSignalStrategy::GetNextId() {
IqRequest* FakeSignalStrategy::CreateIqRequest() {
DCHECK(CalledOnValidThread());
- return new JavascriptIqRequest(this, &iq_registry_);
+ return new IqRequest(this, &iq_registry_);
}
void FakeSignalStrategy::OnIncomingMessage(buzz::XmlElement* stanza) {
diff --git a/remoting/jingle_glue/fake_signal_strategy.h b/remoting/jingle_glue/fake_signal_strategy.h
index 553313e..37aad4a 100644
--- a/remoting/jingle_glue/fake_signal_strategy.h
+++ b/remoting/jingle_glue/fake_signal_strategy.h
@@ -10,7 +10,7 @@
#include "base/task.h"
#include "base/threading/non_thread_safe.h"
-#include "remoting/jingle_glue/javascript_iq_request.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "remoting/jingle_glue/signal_strategy.h"
namespace remoting {
@@ -40,7 +40,7 @@ class FakeSignalStrategy : public SignalStrategy,
std::string jid_;
FakeSignalStrategy* peer_;
Listener* listener_;
- JavascriptIqRegistry iq_registry_;
+ IqRegistry iq_registry_;
int last_id_;
diff --git a/remoting/jingle_glue/iq_request.cc b/remoting/jingle_glue/iq_request.cc
index 5de2e33..5177ee6 100644
--- a/remoting/jingle_glue/iq_request.cc
+++ b/remoting/jingle_glue/iq_request.cc
@@ -4,11 +4,75 @@
#include "remoting/jingle_glue/iq_request.h"
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+#include "remoting/jingle_glue/signal_strategy.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
#include "third_party/libjingle/source/talk/xmpp/constants.h"
namespace remoting {
+IqRegistry::IqRegistry() {
+}
+
+IqRegistry::~IqRegistry() {
+}
+
+void IqRegistry::RemoveAllRequests(IqRequest* request) {
+ IqRequestMap::iterator it = requests_.begin();
+ while (it != requests_.end()) {
+ IqRequestMap::iterator cur = it;
+ ++it;
+ if (cur->second == request) {
+ requests_.erase(cur);
+ }
+ }
+}
+
+bool IqRegistry::OnIncomingStanza(const buzz::XmlElement* stanza) {
+ // TODO(ajwong): Can we cleanup this dispatch at all? The send is from
+ // IqRequest but the return is in IqRegistry.
+
+ if (stanza->Name() != buzz::QN_IQ) {
+ LOG(WARNING) << "Received unexpected non-IQ packet" << stanza->Str();
+ return false;
+ }
+
+ if (!stanza->HasAttr(buzz::QN_ID)) {
+ LOG(WARNING) << "IQ packet missing id" << stanza->Str();
+ return false;
+ }
+
+ const std::string& id = stanza->Attr(buzz::QN_ID);
+
+ IqRequestMap::iterator it = requests_.find(id);
+ if (it == requests_.end()) {
+ return false;
+ }
+
+ // TODO(ajwong): We should look at the logic inside libjingle's
+ // XmppTask::MatchResponseIq() and make sure we're fully in sync.
+ // They check more fields and conditions than us.
+
+ // TODO(ajwong): This logic is weird. We add to the register in
+ // IqRequest::SendIq(), but remove in
+ // IqRegistry::OnIncomingStanza(). We should try to keep the
+ // registration/deregistration in one spot.
+ if (!it->second->callback_.is_null()) {
+ it->second->callback_.Run(stanza);
+ it->second->callback_.Reset();
+ } else {
+ VLOG(1) << "No callback, so dropping: " << stanza->Str();
+ }
+ requests_.erase(it);
+ return true;
+}
+
+void IqRegistry::RegisterRequest(IqRequest* request, const std::string& id) {
+ DCHECK(requests_.find(id) == requests_.end());
+ requests_[id] = request;
+}
+
// static
buzz::XmlElement* IqRequest::MakeIqStanza(const std::string& type,
const std::string& addressee,
@@ -21,4 +85,30 @@ buzz::XmlElement* IqRequest::MakeIqStanza(const std::string& type,
return stanza;
}
+IqRequest::IqRequest()
+ : signal_strategy_(NULL),
+ registry_(NULL) {
+}
+
+IqRequest::IqRequest(SignalStrategy* signal_strategy, IqRegistry* registry)
+ : signal_strategy_(signal_strategy),
+ registry_(registry) {
+}
+
+IqRequest::~IqRequest() {
+ if (registry_)
+ registry_->RemoveAllRequests(this);
+}
+
+void IqRequest::SendIq(buzz::XmlElement* stanza) {
+ std::string id = signal_strategy_->GetNextId();
+ stanza->AddAttr(buzz::QN_ID, id);
+ registry_->RegisterRequest(this, id);
+ signal_strategy_->SendStanza(stanza);
+}
+
+void IqRequest::set_callback(const ReplyCallback& callback) {
+ callback_ = callback;
+}
+
} // namespace remoting
diff --git a/remoting/jingle_glue/iq_request.h b/remoting/jingle_glue/iq_request.h
index 6fbef97..d94e4d2 100644
--- a/remoting/jingle_glue/iq_request.h
+++ b/remoting/jingle_glue/iq_request.h
@@ -5,10 +5,14 @@
#ifndef REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
#define REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
+#include <map>
#include <string>
#include "base/callback.h"
+#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
+#include "remoting/jingle_glue/iq_request.h"
namespace buzz {
class XmlElement;
@@ -16,11 +20,46 @@ class XmlElement;
namespace remoting {
-// IqRequest class can be used to send an IQ stanza and then receive reply
-// stanza for that request. It sends outgoing stanza when SendIq() is called,
-// after that it forwards incoming reply stanza to the callback set with
-// set_callback(). If each call to SendIq() will yield one invocation of the
-// callback with the response.
+class IqRequest;
+class SignalStrategy;
+
+// IqRegistry handles routing of iq responses to corresponding
+// IqRequest objects. Created in SignalStrategy and should not be used
+// directly.
+//
+// TODO(sergeyu): Separate IqRegistry and IqRequest from
+// SignalStrategy and remove CreateIqRequest() method from SignalStrategy.
+class IqRegistry {
+ public:
+ IqRegistry();
+ ~IqRegistry();
+
+ // Dispatches the response to the IqRequest callback immediately.
+ //
+ // Does not take ownership of stanza.
+ void DispatchResponse(buzz::XmlElement* stanza);
+
+ // Registers |request| with the specified |id|.
+ void RegisterRequest(IqRequest* request, const std::string& id);
+
+ // Removes all entries in the registry that refer to |request|.
+ void RemoveAllRequests(IqRequest* request);
+
+ void SetDefaultHandler(IqRequest* default_request);
+
+ // Called by SignalStrategy implementation. Returns true if the
+ // stanza was handled and should not be processed further.
+ bool OnIncomingStanza(const buzz::XmlElement* stanza);
+
+ private:
+ typedef std::map<std::string, IqRequest*> IqRequestMap;
+
+ IqRequestMap requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(IqRegistry);
+};
+
+// This call must only be used on the thread it was created on.
class IqRequest {
public:
typedef base::Callback<void(const buzz::XmlElement*)> ReplyCallback;
@@ -29,18 +68,24 @@ class IqRequest {
const std::string& addressee,
buzz::XmlElement* iq_body);
- IqRequest() {}
- virtual ~IqRequest() {}
+ IqRequest(); // Should be used for tests only.
+ IqRequest(SignalStrategy* signal_strategy, IqRegistry* registry);
+ virtual ~IqRequest();
// Sends Iq stanza. Takes ownership of |stanza|.
- virtual void SendIq(buzz::XmlElement* stanza) = 0;
+ virtual void SendIq(buzz::XmlElement* stanza);
// Sets callback that is called when reply stanza is received.
- virtual void set_callback(const ReplyCallback& callback) = 0;
+ virtual void set_callback(const ReplyCallback& callback);
private:
+ friend class IqRegistry;
FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
+ ReplyCallback callback_;
+ SignalStrategy* signal_strategy_;
+ IqRegistry* registry_;
+
DISALLOW_COPY_AND_ASSIGN(IqRequest);
};
diff --git a/remoting/jingle_glue/javascript_iq_request.cc b/remoting/jingle_glue/javascript_iq_request.cc
deleted file mode 100644
index 62366cf..0000000
--- a/remoting/jingle_glue/javascript_iq_request.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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.
-
-#include "remoting/jingle_glue/javascript_iq_request.h"
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-#include "remoting/jingle_glue/signal_strategy.h"
-#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
-#include "third_party/libjingle/source/talk/xmpp/constants.h"
-
-namespace remoting {
-
-JavascriptIqRegistry::JavascriptIqRegistry() {
-}
-
-JavascriptIqRegistry::~JavascriptIqRegistry() {
-}
-
-void JavascriptIqRegistry::RemoveAllRequests(JavascriptIqRequest* request) {
- IqRequestMap::iterator it = requests_.begin();
- while (it != requests_.end()) {
- IqRequestMap::iterator cur = it;
- ++it;
- if (cur->second == request) {
- requests_.erase(cur);
- }
- }
-}
-
-void JavascriptIqRegistry::OnIncomingStanza(const buzz::XmlElement* stanza) {
- // TODO(ajwong): Can we cleanup this dispatch at all? The send is from
- // JavascriptIqRequest but the return is in JavascriptIqRegistry.
-
- if (stanza->Name() != buzz::QN_IQ) {
- LOG(WARNING) << "Received unexpected non-IQ packet" << stanza->Str();
- return;
- }
-
- if (!stanza->HasAttr(buzz::QN_ID)) {
- LOG(WARNING) << "IQ packet missing id" << stanza->Str();
- return;
- }
-
- const std::string& id = stanza->Attr(buzz::QN_ID);
-
- IqRequestMap::iterator it = requests_.find(id);
- if (it == requests_.end()) {
- VLOG(1) << "Dropping IQ packet with no request id: " << stanza->Str();
- } else {
- // TODO(ajwong): We should look at the logic inside libjingle's
- // XmppTask::MatchResponseIq() and make sure we're fully in sync.
- // They check more fields and conditions than us.
-
- // TODO(ajwong): This logic is weird. We add to the register in
- // JavascriptIqRequest::SendIq(), but remove in
- // JavascriptIqRegistry::OnIq(). We should try to keep the
- // registration/deregistration in one spot.
- if (!it->second->callback_.is_null()) {
- it->second->callback_.Run(stanza);
- it->second->callback_.Reset();
- } else {
- VLOG(1) << "No callback, so dropping: " << stanza->Str();
- }
- requests_.erase(it);
- }
-}
-
-void JavascriptIqRegistry::RegisterRequest(
- JavascriptIqRequest* request, const std::string& id) {
- DCHECK(requests_.find(id) == requests_.end());
- requests_[id] = request;
-}
-
-JavascriptIqRequest::JavascriptIqRequest(SignalStrategy* signal_strategy,
- JavascriptIqRegistry* registry)
- : signal_strategy_(signal_strategy),
- registry_(registry) {
-}
-
-JavascriptIqRequest::~JavascriptIqRequest() {
- registry_->RemoveAllRequests(this);
-}
-
-void JavascriptIqRequest::SendIq(buzz::XmlElement* stanza) {
- std::string id = signal_strategy_->GetNextId();
- stanza->AddAttr(buzz::QN_ID, id);
- registry_->RegisterRequest(this, id);
- signal_strategy_->SendStanza(stanza);
-}
-
-void JavascriptIqRequest::set_callback(const ReplyCallback& callback) {
- callback_ = callback;
-}
-
-} // namespace remoting
diff --git a/remoting/jingle_glue/javascript_iq_request.h b/remoting/jingle_glue/javascript_iq_request.h
deleted file mode 100644
index f94fc33..0000000
--- a/remoting/jingle_glue/javascript_iq_request.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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.
-
-#ifndef REMOTING_JINGLE_GLUE_JAVASCRIPT_IQ_REQUEST_H_
-#define REMOTING_JINGLE_GLUE_JAVASCRIPT_IQ_REQUEST_H_
-
-#include <map>
-
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "remoting/jingle_glue/iq_request.h"
-
-namespace remoting {
-
-class JavascriptIqRequest;
-class SignalStrategy;
-
-class JavascriptIqRegistry {
- public:
- JavascriptIqRegistry();
- virtual ~JavascriptIqRegistry();
-
- // Dispatches the response to the IqRequest callback immediately.
- //
- // Does not take ownership of stanza.
- void DispatchResponse(buzz::XmlElement* stanza);
-
- // Registers |request| with the specified |id|.
- void RegisterRequest(JavascriptIqRequest* request, const std::string& id);
-
- // Removes all entries in the registry that refer to |request|. Useful when
- // |request| is about to be destructed.
- void RemoveAllRequests(JavascriptIqRequest* request);
-
- void SetDefaultHandler(JavascriptIqRequest* default_request);
-
- // Called by JavascriptSignalStrategy.
- void OnIncomingStanza(const buzz::XmlElement* stanza);
-
- private:
- typedef std::map<std::string, JavascriptIqRequest*> IqRequestMap;
-
- IqRequestMap requests_;
- JavascriptIqRequest* default_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(JavascriptIqRegistry);
-};
-
-// This call must only be used on the thread it was created on.
-class JavascriptIqRequest : public IqRequest {
- public:
- JavascriptIqRequest(SignalStrategy* signal_strategy,
- JavascriptIqRegistry* registry);
- virtual ~JavascriptIqRequest();
-
- // IqRequest interface.
- virtual void SendIq(buzz::XmlElement* iq_body) OVERRIDE;
- virtual void set_callback(const ReplyCallback& callback) OVERRIDE;
-
- private:
- friend class JavascriptIqRegistry;
-
- ReplyCallback callback_;
- SignalStrategy* signal_strategy_;
- JavascriptIqRegistry* registry_;
-
- FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_JAVASCRIPT_IQ_REQUEST_H_
diff --git a/remoting/jingle_glue/javascript_signal_strategy.cc b/remoting/jingle_glue/javascript_signal_strategy.cc
index bb423d6..cd14fbb 100644
--- a/remoting/jingle_glue/javascript_signal_strategy.cc
+++ b/remoting/jingle_glue/javascript_signal_strategy.cc
@@ -78,7 +78,7 @@ std::string JavascriptSignalStrategy::GetNextId() {
IqRequest* JavascriptSignalStrategy::CreateIqRequest() {
DCHECK(CalledOnValidThread());
- return new JavascriptIqRequest(this, &iq_registry_);
+ return new IqRequest(this, &iq_registry_);
}
void JavascriptSignalStrategy::OnIq(const std::string& stanza_str) {
diff --git a/remoting/jingle_glue/javascript_signal_strategy.h b/remoting/jingle_glue/javascript_signal_strategy.h
index 81b6e0c..18cb1cb 100644
--- a/remoting/jingle_glue/javascript_signal_strategy.h
+++ b/remoting/jingle_glue/javascript_signal_strategy.h
@@ -11,7 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
-#include "remoting/jingle_glue/javascript_iq_request.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "remoting/jingle_glue/xmpp_proxy.h"
namespace remoting {
@@ -41,7 +41,7 @@ class JavascriptSignalStrategy : public SignalStrategy,
private:
std::string your_jid_;
scoped_refptr<XmppProxy> xmpp_proxy_;
- JavascriptIqRegistry iq_registry_;
+ IqRegistry iq_registry_;
Listener* listener_;
diff --git a/remoting/jingle_glue/jingle_signaling_connector.cc b/remoting/jingle_glue/jingle_signaling_connector.cc
index 8fe2a15..6f8a7cf 100644
--- a/remoting/jingle_glue/jingle_signaling_connector.cc
+++ b/remoting/jingle_glue/jingle_signaling_connector.cc
@@ -6,7 +6,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
-#include "remoting/jingle_glue/javascript_iq_request.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h"
#include "third_party/libjingle/source/talk/xmpp/constants.h"
#include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
diff --git a/remoting/jingle_glue/jingle_signaling_connector.h b/remoting/jingle_glue/jingle_signaling_connector.h
index c45c269..2aa41bc 100644
--- a/remoting/jingle_glue/jingle_signaling_connector.h
+++ b/remoting/jingle_glue/jingle_signaling_connector.h
@@ -22,7 +22,7 @@ class SessionManager;
namespace remoting {
-class JavascriptIqRequest;
+class IqRequest;
// This class handles proxying the Jingle establishment messages between the
// client and the server when proxying XMPP through Javascript.
@@ -33,9 +33,6 @@ class JavascriptIqRequest;
//
// This class is not threadsafe, and should only be used on the thread it is
// created on.
-//
-// TODO(sergeyu): This class should not depend on JavascriptIqRequest:
-// it should work with SignalStrategy instead.
class JingleSignalingConnector : public SignalStrategy::Listener,
public sigslot::has_slots<> {
public:
diff --git a/remoting/jingle_glue/xmpp_iq_request.cc b/remoting/jingle_glue/xmpp_iq_request.cc
deleted file mode 100644
index 7e07665..0000000
--- a/remoting/jingle_glue/xmpp_iq_request.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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.
-
-#include "remoting/jingle_glue/xmpp_iq_request.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "third_party/libjingle/source/talk/xmpp/constants.h"
-#include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
-
-namespace remoting {
-
-XmppIqRequest::XmppIqRequest(MessageLoop* message_loop,
- buzz::XmppClient* xmpp_client)
- : message_loop_(message_loop),
- xmpp_client_(xmpp_client),
- cookie_(NULL) {
- DCHECK(xmpp_client_);
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-}
-
-XmppIqRequest::~XmppIqRequest() {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
- Unregister();
-}
-
-void XmppIqRequest::SendIq(buzz::XmlElement* stanza) {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- // Unregister the handler if it is already registered.
- Unregister();
-
- stanza->AddAttr(buzz::QN_ID, xmpp_client_->NextId());
- xmpp_client_->engine()->SendIq(stanza, this, &cookie_);
-}
-
-void XmppIqRequest::set_callback(const ReplyCallback& callback) {
- callback_ = callback;
-}
-
-void XmppIqRequest::Unregister() {
- if (cookie_) {
- // No need to unregister the handler if the client has been destroyed.
- if (xmpp_client_) {
- xmpp_client_->engine()->RemoveIqHandler(cookie_, NULL);
- }
- cookie_ = NULL;
- }
-}
-
-void XmppIqRequest::IqResponse(buzz::XmppIqCookie cookie,
- const buzz::XmlElement* stanza) {
- if (!callback_.is_null()) {
- callback_.Run(stanza);
- callback_.Reset();
- }
-}
-
-} // namespace remoting
diff --git a/remoting/jingle_glue/xmpp_iq_request.h b/remoting/jingle_glue/xmpp_iq_request.h
deleted file mode 100644
index 8732c49..0000000
--- a/remoting/jingle_glue/xmpp_iq_request.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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.
-
-#ifndef REMOTING_JINGLE_GLUE_XMPP_IQ_REQUEST_H_
-#define REMOTING_JINGLE_GLUE_XMPP_IQ_REQUEST_H_
-
-#include "base/compiler_specific.h"
-#include "remoting/jingle_glue/iq_request.h"
-#include "third_party/libjingle/source/talk/base/sigslot.h"
-#include "third_party/libjingle/source/talk/xmpp/xmppengine.h"
-
-class MessageLoop;
-
-namespace buzz {
-class XmppClient;
-} // namespace buzz
-
-namespace remoting {
-
-class XmppIqRequest : public IqRequest, public buzz::XmppIqHandler {
- public:
- XmppIqRequest(MessageLoop* message_loop, buzz::XmppClient* xmpp_client);
- virtual ~XmppIqRequest();
-
- // IqRequest interface.
- virtual void SendIq(buzz::XmlElement* stanza) OVERRIDE;
- virtual void set_callback(const ReplyCallback& callback) OVERRIDE;
-
- // buzz::XmppIqHandler interface.
- virtual void IqResponse(buzz::XmppIqCookie cookie,
- const buzz::XmlElement* stanza) OVERRIDE;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
-
- void Unregister();
-
- // TODO(ajwong): This used to hold a reference to the jingle client...make
- // sure the lifetime names sense now.
- MessageLoop* message_loop_;
- buzz::XmppClient* xmpp_client_;
- buzz::XmppIqCookie cookie_;
- ReplyCallback callback_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_XMPP_IQ_REQUEST_H_
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc
index 63d372a..f68a885 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.cc
+++ b/remoting/jingle_glue/xmpp_signal_strategy.cc
@@ -6,8 +6,8 @@
#include "base/logging.h"
#include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "remoting/jingle_glue/jingle_thread.h"
-#include "remoting/jingle_glue/xmpp_iq_request.h"
#include "remoting/jingle_glue/xmpp_socket_adapter.h"
#include "third_party/libjingle/source/talk/base/asyncsocket.h"
#include "third_party/libjingle/source/talk/xmpp/prexmppauth.h"
@@ -20,12 +20,12 @@ XmppSignalStrategy::XmppSignalStrategy(JingleThread* jingle_thread,
const std::string& auth_token,
const std::string& auth_token_service)
: thread_(jingle_thread),
- listener_(NULL),
username_(username),
auth_token_(auth_token),
auth_token_service_(auth_token_service),
xmpp_client_(NULL),
- observer_(NULL) {
+ observer_(NULL),
+ listener_(NULL) {
}
XmppSignalStrategy::~XmppSignalStrategy() {
@@ -95,15 +95,13 @@ std::string XmppSignalStrategy::GetNextId() {
}
IqRequest* XmppSignalStrategy::CreateIqRequest() {
- // TODO(sergeyu): Handle the case when |xmpp_client_| is NULL.
- CHECK(xmpp_client_);
- return new XmppIqRequest(thread_->message_loop(), xmpp_client_);
+ return new IqRequest(this, &iq_registry_);
}
bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) {
- if (listener_)
- return listener_->OnIncomingStanza(stanza);
- return false;
+ if (listener_ && listener_->OnIncomingStanza(stanza))
+ return true;
+ return iq_registry_.OnIncomingStanza(stanza);
}
void XmppSignalStrategy::OnConnectionStateChanged(
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h
index 9deb5f0..41f6461 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.h
+++ b/remoting/jingle_glue/xmpp_signal_strategy.h
@@ -13,6 +13,7 @@
#include "remoting/jingle_glue/signal_strategy.h"
#include "base/compiler_specific.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "third_party/libjingle/source/talk/base/sigslot.h"
#include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
@@ -48,13 +49,15 @@ class XmppSignalStrategy : public SignalStrategy,
JingleThread* thread_;
- Listener* listener_;
-
std::string username_;
std::string auth_token_;
std::string auth_token_service_;
buzz::XmppClient* xmpp_client_;
+ IqRegistry iq_registry_;
+
StatusObserver* observer_;
+ Listener* listener_;
+
DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy);
};
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 3f14491..b17e7c5 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -608,8 +608,6 @@
'sources': [
'jingle_glue/iq_request.cc',
'jingle_glue/iq_request.h',
- 'jingle_glue/javascript_iq_request.cc',
- 'jingle_glue/javascript_iq_request.h',
'jingle_glue/javascript_signal_strategy.cc',
'jingle_glue/javascript_signal_strategy.h',
'jingle_glue/jingle_info_request.cc',
@@ -623,8 +621,6 @@
'jingle_glue/ssl_adapter.cc',
'jingle_glue/ssl_socket_adapter.cc',
'jingle_glue/ssl_socket_adapter.h',
- 'jingle_glue/xmpp_iq_request.cc',
- 'jingle_glue/xmpp_iq_request.h',
'jingle_glue/xmpp_proxy.h',
'jingle_glue/xmpp_signal_strategy.cc',
'jingle_glue/xmpp_signal_strategy.h',