summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 01:44:25 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 01:44:25 +0000
commit483414a22ae60ffcc24e0517be4a44c05375325e (patch)
tree7f6c729951b873205c676a6ed7fe85f88964ca73 /remoting/jingle_glue
parent729c1e9326c854bc63acee30e0dff09061b46b26 (diff)
downloadchromium_src-483414a22ae60ffcc24e0517be4a44c05375325e.zip
chromium_src-483414a22ae60ffcc24e0517be4a44c05375325e.tar.gz
chromium_src-483414a22ae60ffcc24e0517be4a44c05375325e.tar.bz2
Switch host to the new signaling code.
BUG=110485 Review URL: http://codereview.chromium.org/9365025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r--remoting/jingle_glue/jingle_signaling_connector.cc111
-rw-r--r--remoting/jingle_glue/jingle_signaling_connector.h64
2 files changed, 0 insertions, 175 deletions
diff --git a/remoting/jingle_glue/jingle_signaling_connector.cc b/remoting/jingle_glue/jingle_signaling_connector.cc
deleted file mode 100644
index 913633a..0000000
--- a/remoting/jingle_glue/jingle_signaling_connector.cc
+++ /dev/null
@@ -1,111 +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/jingle_signaling_connector.h"
-
-#include "base/logging.h"
-#include "base/stl_util.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"
-
-namespace remoting {
-
-namespace {
-
-// GTalk sometimes generates service-unavailable error messages with
-// incorrect namespace. This method fixes such messages.
-// TODO(sergeyu): Fix this on the server side.
-void FixErrorStanza(buzz::XmlElement* stanza) {
- if (!stanza->FirstNamed(buzz::QN_ERROR)) {
- buzz::XmlElement* error = stanza->FirstNamed(buzz::QName("", "error"));
- error->SetName(buzz::QN_ERROR);
- }
-}
-
-} // namespace
-
-JingleSignalingConnector::JingleSignalingConnector(
- SignalStrategy* signal_strategy,
- cricket::SessionManager* session_manager)
- : signal_strategy_(signal_strategy),
- session_manager_(session_manager) {
-
- session_manager_->SignalOutgoingMessage.connect(
- this, &JingleSignalingConnector::OnOutgoingMessage);
-
- signal_strategy_->AddListener(this);
-
- // Assume that signaling is ready from the beginning.
- session_manager_->SignalRequestSignaling.connect(
- session_manager_, &cricket::SessionManager::OnSignalingReady);
-}
-
-JingleSignalingConnector::~JingleSignalingConnector() {
- signal_strategy_->RemoveListener(this);
- STLDeleteContainerPairSecondPointers(pending_requests_.begin(),
- pending_requests_.end());
-}
-
-void JingleSignalingConnector::OnSignalStrategyStateChange(
- SignalStrategy::State state) {
-}
-
-bool JingleSignalingConnector::OnSignalStrategyIncomingStanza(
- const buzz::XmlElement* stanza) {
- if (session_manager_->IsSessionMessage(stanza)) {
- session_manager_->OnIncomingMessage(stanza);
- return true;
- }
-
- if (stanza->Name() == buzz::QN_IQ) {
- std::string type = stanza->Attr(buzz::QN_TYPE);
- std::string id = stanza->Attr(buzz::QN_ID);
- if ((type == "error" || type == "result") && !id.empty()) {
- IqRequestsMap::iterator it = pending_requests_.find(id);
- if (it != pending_requests_.end()) {
- if (type == "result") {
- session_manager_->OnIncomingResponse(it->second, stanza);
- } else {
- scoped_ptr<buzz::XmlElement> stanza_copy(
- new buzz::XmlElement(*stanza));
- FixErrorStanza(stanza_copy.get());
- session_manager_->OnFailedSend(it->second, stanza_copy.get());
- }
- delete it->second;
- pending_requests_.erase(it);
- return true;
- }
- }
- }
-
- return false;
-}
-
-void JingleSignalingConnector::OnOutgoingMessage(
- cricket::SessionManager* session_manager,
- const buzz::XmlElement* stanza) {
- DCHECK_EQ(session_manager, session_manager_);
- scoped_ptr<buzz::XmlElement> stanza_copy(new buzz::XmlElement(*stanza));
-
- if (stanza_copy->Name() == buzz::QN_IQ) {
- std::string type = stanza_copy->Attr(buzz::QN_TYPE);
- if (type == "set" || type == "get") {
- std::string id = stanza_copy->Attr(buzz::QN_ID);
-
- // Add ID attribute for set and get stanzas if it is not there.
- if (id.empty()) {
- id = signal_strategy_->GetNextId();
- stanza_copy->SetAttr(buzz::QN_ID, id);
- }
-
- // Save the outgoing request for OnIncomingResponse().
- pending_requests_[id] = new buzz::XmlElement(*stanza);
- }
- }
-
- signal_strategy_->SendStanza(stanza_copy.release());
-}
-
-} // namespace remoting
diff --git a/remoting/jingle_glue/jingle_signaling_connector.h b/remoting/jingle_glue/jingle_signaling_connector.h
deleted file mode 100644
index f26fb32..0000000
--- a/remoting/jingle_glue/jingle_signaling_connector.h
+++ /dev/null
@@ -1,64 +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_JINGLE_SIGNALING_CONNECTOR_H_
-#define REMOTING_JINGLE_GLUE_JINGLE_SIGNALING_CONNECTOR_H_
-
-#include <map>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "remoting/jingle_glue/signal_strategy.h"
-#include "third_party/libjingle/source/talk/base/sigslot.h"
-
-namespace buzz {
-class XmlElement;
-} // namespace buzz
-
-namespace cricket {
-class SessionManager;
-} // namespace cricket
-
-namespace remoting {
-
-class IqRequest;
-
-// This class handles proxying the Jingle establishment messages between the
-// client and the server when proxying XMPP through Javascript.
-//
-// The |request| object is used to send and receive IQ stanzas from the XMPP
-// network. The |session_manager| controls sending and receiving of stanzas
-// after Run() is invoked.
-//
-// This class is not threadsafe, and should only be used on the thread it is
-// created on.
-class JingleSignalingConnector : public SignalStrategy::Listener,
- public sigslot::has_slots<> {
- public:
- JingleSignalingConnector(SignalStrategy* signal_strategy,
- cricket::SessionManager* session_manager);
- virtual ~JingleSignalingConnector();
-
- // SignalStrategy::Listener interface.
- virtual void OnSignalStrategyStateChange(
- SignalStrategy::State state) OVERRIDE;
- virtual bool OnSignalStrategyIncomingStanza(
- const buzz::XmlElement* stanza) OVERRIDE;
-
- private:
- typedef std::map<std::string, buzz::XmlElement*> IqRequestsMap;
-
- void OnOutgoingMessage(cricket::SessionManager* manager,
- const buzz::XmlElement* stanza);
-
- SignalStrategy* signal_strategy_;
- cricket::SessionManager* session_manager_;
- IqRequestsMap pending_requests_;
-
- DISALLOW_COPY_AND_ASSIGN(JingleSignalingConnector);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_JINGLE_GLUE_JINGLE_SIGNALING_CONNECTOR_H_