summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 21:02:26 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-28 21:02:26 +0000
commit730bd1c0c25f2af8858a3e47c2c22f59bbd9efec (patch)
tree65f15ab9164e7eb75636b153c09642a56f9995ac /remoting/jingle_glue
parent2841c9057bd6fa9617d1ec44d46f2cc9a5b206f1 (diff)
downloadchromium_src-730bd1c0c25f2af8858a3e47c2c22f59bbd9efec.zip
chromium_src-730bd1c0c25f2af8858a3e47c2c22f59bbd9efec.tar.gz
chromium_src-730bd1c0c25f2af8858a3e47c2c22f59bbd9efec.tar.bz2
Remove StartSession/EndSession from SignalStrategy interface.
BUG=None TEST=remoting still works. Review URL: http://codereview.chromium.org/7277017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r--remoting/jingle_glue/javascript_signal_strategy.cc28
-rw-r--r--remoting/jingle_glue/javascript_signal_strategy.h4
-rw-r--r--remoting/jingle_glue/jingle_client.cc8
-rw-r--r--remoting/jingle_glue/jingle_client.h2
-rw-r--r--remoting/jingle_glue/mock_objects.h5
-rw-r--r--remoting/jingle_glue/signal_strategy.h9
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.cc28
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.h3
8 files changed, 29 insertions, 58 deletions
diff --git a/remoting/jingle_glue/javascript_signal_strategy.cc b/remoting/jingle_glue/javascript_signal_strategy.cc
index a754bb0..6dcceee 100644
--- a/remoting/jingle_glue/javascript_signal_strategy.cc
+++ b/remoting/jingle_glue/javascript_signal_strategy.cc
@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "remoting/jingle_glue/iq_request.h"
-#include "remoting/jingle_glue/jingle_signaling_connector.h"
#include "remoting/jingle_glue/xmpp_proxy.h"
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
@@ -20,7 +19,6 @@ JavascriptSignalStrategy::JavascriptSignalStrategy(const std::string& your_jid)
}
JavascriptSignalStrategy::~JavascriptSignalStrategy() {
- jingle_signaling_connector_.reset();
DCHECK(listener_ == NULL);
}
@@ -44,6 +42,15 @@ void JavascriptSignalStrategy::Init(StatusObserver* observer) {
observer->OnStateChange(StatusObserver::CONNECTED);
}
+void JavascriptSignalStrategy::Close() {
+ DCHECK(CalledOnValidThread());
+
+ if (xmpp_proxy_) {
+ xmpp_proxy_->DetachCallback();
+ xmpp_proxy_ = NULL;
+ }
+}
+
void JavascriptSignalStrategy::SetListener(Listener* listener) {
DCHECK(CalledOnValidThread());
@@ -60,23 +67,6 @@ void JavascriptSignalStrategy::SendStanza(buzz::XmlElement* stanza) {
delete stanza;
}
-void JavascriptSignalStrategy::StartSession(
- cricket::SessionManager* session_manager) {
- DCHECK(CalledOnValidThread());
-
- jingle_signaling_connector_.reset(
- new JingleSignalingConnector(this, session_manager));
-}
-
-void JavascriptSignalStrategy::EndSession() {
- DCHECK(CalledOnValidThread());
-
- if (xmpp_proxy_) {
- xmpp_proxy_->DetachCallback();
- }
- xmpp_proxy_ = NULL;
-}
-
IqRequest* JavascriptSignalStrategy::CreateIqRequest() {
DCHECK(CalledOnValidThread());
diff --git a/remoting/jingle_glue/javascript_signal_strategy.h b/remoting/jingle_glue/javascript_signal_strategy.h
index 3cebf05..d8d9768 100644
--- a/remoting/jingle_glue/javascript_signal_strategy.h
+++ b/remoting/jingle_glue/javascript_signal_strategy.h
@@ -30,10 +30,9 @@ class JavascriptSignalStrategy : public SignalStrategy,
// SignalStrategy interface.
virtual void Init(StatusObserver* observer) OVERRIDE;
+ virtual void Close() OVERRIDE;
virtual void SetListener(Listener* listener) OVERRIDE;
virtual void SendStanza(buzz::XmlElement* stanza) OVERRIDE;
- virtual void StartSession(cricket::SessionManager* session_manager) OVERRIDE;
- virtual void EndSession() OVERRIDE;
virtual IqRequest* CreateIqRequest() OVERRIDE;
// XmppProxy::ResponseCallback interface.
@@ -43,7 +42,6 @@ class JavascriptSignalStrategy : public SignalStrategy,
std::string your_jid_;
scoped_refptr<XmppProxy> xmpp_proxy_;
JavascriptIqRegistry iq_registry_;
- scoped_ptr<JingleSignalingConnector> jingle_signaling_connector_;
Listener* listener_;
diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc
index d363b27..b013c66 100644
--- a/remoting/jingle_glue/jingle_client.cc
+++ b/remoting/jingle_glue/jingle_client.cc
@@ -11,6 +11,7 @@
#include "remoting/jingle_glue/http_port_allocator.h"
#include "remoting/jingle_glue/iq_request.h"
#include "remoting/jingle_glue/jingle_info_request.h"
+#include "remoting/jingle_glue/jingle_signaling_connector.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
#include "third_party/libjingle/source/talk/base/ssladapter.h"
@@ -99,7 +100,8 @@ void JingleClient::DoInitialize() {
void JingleClient::DoStartSession() {
session_manager_.reset(
new cricket::SessionManager(port_allocator_.get()));
- signal_strategy_->StartSession(session_manager_.get());
+ jingle_signaling_connector_.reset(
+ new JingleSignalingConnector(signal_strategy_, session_manager_.get()));
// TODO(ajwong): Major hack to synchronize state change logic. Since the Xmpp
// connection starts first, it move the state to CONNECTED before we've gotten
@@ -129,10 +131,10 @@ void JingleClient::Close(const base::Closure& closed_task) {
void JingleClient::DoClose(const base::Closure& closed_task) {
DCHECK_EQ(message_loop_, MessageLoop::current());
+ jingle_signaling_connector_.reset();
session_manager_.reset();
if (signal_strategy_) {
- signal_strategy_->EndSession();
- // TODO(ajwong): SignalStrategy should drop all resources at EndSession().
+ signal_strategy_->Close();
signal_strategy_ = NULL;
}
diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h
index d0b140b5..6879ee7 100644
--- a/remoting/jingle_glue/jingle_client.h
+++ b/remoting/jingle_glue/jingle_client.h
@@ -38,6 +38,7 @@ class SessionManager;
namespace remoting {
class JingleInfoRequest;
+class JingleSignalingConnector;
class PortAllocatorSessionFactory;
class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
@@ -144,6 +145,7 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
scoped_ptr<cricket::SessionManager> session_manager_;
scoped_ptr<JingleInfoRequest> jingle_info_request_;
+ scoped_ptr<JingleSignalingConnector> jingle_signaling_connector_;
DISALLOW_COPY_AND_ASSIGN(JingleClient);
};
diff --git a/remoting/jingle_glue/mock_objects.h b/remoting/jingle_glue/mock_objects.h
index 8889f47..56ee59f 100644
--- a/remoting/jingle_glue/mock_objects.h
+++ b/remoting/jingle_glue/mock_objects.h
@@ -14,12 +14,9 @@ class MockSignalStrategy : public SignalStrategy {
virtual ~MockSignalStrategy();
MOCK_METHOD1(Init, void(StatusObserver*));
- MOCK_METHOD0(port_allocator, cricket::BasicPortAllocator*());
- MOCK_METHOD2(ConfigureAllocator, void(cricket::HttpPortAllocator*, Task*));
+ MOCK_METHOD0(Close, void());
MOCK_METHOD1(SetListener, void(Listener* listener));
MOCK_METHOD1(SendStanza, void(buzz::XmlElement* stanza));
- MOCK_METHOD1(StartSession, void(cricket::SessionManager*));
- MOCK_METHOD0(EndSession, void());
MOCK_METHOD0(CreateIqRequest, IqRequest*());
};
diff --git a/remoting/jingle_glue/signal_strategy.h b/remoting/jingle_glue/signal_strategy.h
index d4093b78..d59341e 100644
--- a/remoting/jingle_glue/signal_strategy.h
+++ b/remoting/jingle_glue/signal_strategy.h
@@ -13,10 +13,6 @@ namespace buzz {
class XmlElement;
} // namespace buzz
-namespace cricket {
-class SessionManager;
-} // namespace cricket
-
namespace remoting {
class IqRequest;
@@ -45,6 +41,7 @@ class SignalStrategy {
SignalStrategy() {}
virtual ~SignalStrategy() {}
virtual void Init(StatusObserver* observer) = 0;
+ virtual void Close() = 0;
// Set a listener that can listen to all incoming messages. Doesn't
// take ownership of the |listener|. Can be called with |listener|
@@ -55,10 +52,6 @@ class SignalStrategy {
// Sends a raw XMPP stanza. Takes ownership of the |stanza|.
virtual void SendStanza(buzz::XmlElement* stanza) = 0;
- // TODO(sergeyu): Do these methods belong to this interface?
- virtual void StartSession(cricket::SessionManager* session_manager) = 0;
- virtual void EndSession() = 0;
-
virtual IqRequest* CreateIqRequest() = 0;
private:
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc
index 28f5e59..0d09a1c 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.cc
+++ b/remoting/jingle_glue/xmpp_signal_strategy.cc
@@ -10,8 +10,6 @@
#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/p2p/client/sessionmanagertask.h"
-#include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h"
#include "third_party/libjingle/source/talk/xmpp/prexmppauth.h"
#include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h"
@@ -61,6 +59,15 @@ void XmppSignalStrategy::Init(StatusObserver* observer) {
xmpp_client_->Start();
}
+void XmppSignalStrategy::Close() {
+ if (xmpp_client_) {
+ xmpp_client_->engine()->RemoveStanzaHandler(this);
+ xmpp_client_->Disconnect();
+ // Client is deleted by TaskRunner.
+ xmpp_client_ = NULL;
+ }
+}
+
void XmppSignalStrategy::SetListener(Listener* listener) {
// Don't overwrite an listener without explicitly going
// through "NULL" first.
@@ -72,23 +79,6 @@ void XmppSignalStrategy::SendStanza(buzz::XmlElement* stanza) {
xmpp_client_->SendStanza(stanza);
}
-void XmppSignalStrategy::StartSession(
- cricket::SessionManager* session_manager) {
- cricket::SessionManagerTask* receiver =
- new cricket::SessionManagerTask(xmpp_client_, session_manager);
- receiver->EnableOutgoingMessages();
- receiver->Start();
-}
-
-void XmppSignalStrategy::EndSession() {
- if (xmpp_client_) {
- xmpp_client_->engine()->RemoveStanzaHandler(this);
- xmpp_client_->Disconnect();
- // Client is deleted by TaskRunner.
- xmpp_client_ = NULL;
- }
-}
-
IqRequest* XmppSignalStrategy::CreateIqRequest() {
return new XmppIqRequest(thread_->message_loop(), xmpp_client_);
}
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h
index b09a6fc..ae3f825 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.h
+++ b/remoting/jingle_glue/xmpp_signal_strategy.h
@@ -32,10 +32,9 @@ class XmppSignalStrategy : public SignalStrategy,
// SignalStrategy interface.
virtual void Init(StatusObserver* observer) OVERRIDE;
+ virtual void Close() OVERRIDE;
virtual void SetListener(Listener* listener) OVERRIDE;
virtual void SendStanza(buzz::XmlElement* stanza) OVERRIDE;
- virtual void StartSession(cricket::SessionManager* session_manager) OVERRIDE;
- virtual void EndSession() OVERRIDE;
virtual IqRequest* CreateIqRequest() OVERRIDE;
// buzz::XmppStanzaHandler interface.