Remove SessionManagerPair.
SessionManagerPair is no longer needed. BUG=None TEST=None. Review URL: http://codereview.chromium.org/7291016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91244 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -101,7 +101,7 @@ class JingleSessionTest : public testing::Test {
|
||||
}
|
||||
|
||||
void CreateServerPair() {
|
||||
// SessionManagerPair must be initialized on the jingle thread.
|
||||
// Sessions must be initialized on the jingle thread.
|
||||
thread_.message_loop()->PostTask(
|
||||
FROM_HERE, NewRunnableMethod(
|
||||
this, &JingleSessionTest::DoCreateServerPair));
|
||||
|
@ -1,97 +0,0 @@
|
||||
// Copyright (c) 2010 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/protocol/session_manager_pair.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "remoting/jingle_glue/jingle_thread.h"
|
||||
#include "third_party/libjingle/source/talk/base/network.h"
|
||||
#include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
|
||||
#include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h"
|
||||
#include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
|
||||
#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
|
||||
|
||||
namespace remoting {
|
||||
|
||||
const char SessionManagerPair::kHostJid[] = "host1@gmail.com/123";
|
||||
const char SessionManagerPair::kClientJid[] = "host2@gmail.com/321";
|
||||
|
||||
SessionManagerPair::SessionManagerPair(JingleThread* thread)
|
||||
: message_loop_(thread->message_loop()) {
|
||||
}
|
||||
|
||||
SessionManagerPair::~SessionManagerPair() {}
|
||||
|
||||
void SessionManagerPair::Init() {
|
||||
DCHECK_EQ(message_loop_, MessageLoop::current());
|
||||
|
||||
network_manager_.reset(new talk_base::NetworkManager());
|
||||
socket_factory_.reset(new talk_base::BasicPacketSocketFactory(
|
||||
talk_base::Thread::Current()));
|
||||
|
||||
cricket::BasicPortAllocator* port_allocator =
|
||||
new cricket::BasicPortAllocator(network_manager_.get(),
|
||||
socket_factory_.get());
|
||||
port_allocator_.reset(port_allocator);
|
||||
|
||||
host_session_manager_.reset(new cricket::SessionManager(port_allocator));
|
||||
host_session_manager_->SignalOutgoingMessage.connect(
|
||||
this, &SessionManagerPair::ProcessMessage);
|
||||
host_session_manager_->SignalRequestSignaling.connect(
|
||||
host_session_manager_.get(), &cricket::SessionManager::OnSignalingReady);
|
||||
|
||||
client_session_manager_.reset(new cricket::SessionManager(port_allocator));
|
||||
client_session_manager_->SignalOutgoingMessage.connect(
|
||||
this, &SessionManagerPair::ProcessMessage);
|
||||
client_session_manager_->SignalRequestSignaling.connect(
|
||||
client_session_manager_.get(),
|
||||
&cricket::SessionManager::OnSignalingReady);
|
||||
}
|
||||
|
||||
cricket::SessionManager* SessionManagerPair::host_session_manager() {
|
||||
return host_session_manager_.get();
|
||||
}
|
||||
|
||||
cricket::SessionManager* SessionManagerPair::client_session_manager() {
|
||||
return client_session_manager_.get();
|
||||
}
|
||||
|
||||
void SessionManagerPair::ProcessMessage(cricket::SessionManager* manager,
|
||||
const buzz::XmlElement* stanza) {
|
||||
message_loop_->PostTask(
|
||||
FROM_HERE, NewRunnableMethod(this, &SessionManagerPair::DoProcessMessage,
|
||||
manager, new buzz::XmlElement(*stanza)));
|
||||
}
|
||||
|
||||
void SessionManagerPair::DoProcessMessage(cricket::SessionManager* manager,
|
||||
buzz::XmlElement* stanza) {
|
||||
DCHECK_EQ(message_loop_, MessageLoop::current());
|
||||
DCHECK(manager == host_session_manager_.get() ||
|
||||
manager == client_session_manager_.get());
|
||||
buzz::QName from_attr("", "from");
|
||||
buzz::QName to_attr("", "to");
|
||||
std::string to = stanza->Attr(to_attr);
|
||||
if (to == kHostJid) {
|
||||
DCHECK(manager == client_session_manager_.get());
|
||||
stanza->SetAttr(from_attr, kClientJid);
|
||||
DeliverMessage(host_session_manager_.get(), stanza);
|
||||
} else if (to == kClientJid) {
|
||||
DCHECK(manager == host_session_manager_.get());
|
||||
stanza->SetAttr(from_attr, kHostJid);
|
||||
DeliverMessage(client_session_manager_.get(), stanza);
|
||||
} else {
|
||||
LOG(ERROR) << "Dropping stanza sent to unknown jid " << to;
|
||||
}
|
||||
delete stanza;
|
||||
}
|
||||
|
||||
void SessionManagerPair::DeliverMessage(cricket::SessionManager* to,
|
||||
buzz::XmlElement* stanza) {
|
||||
if (to->IsSessionMessage(stanza)) {
|
||||
to->OnIncomingMessage(stanza);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace remoting
|
@ -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.
|
||||
|
||||
// SessionManagerPair class is used by unittests to create a pair of session
|
||||
// managers connected to each other. These session managers are then can be
|
||||
// passed to a pair of JingleChromotocolConnection objects, so that it is
|
||||
// possible to simulate connection between host and client.
|
||||
|
||||
#ifndef REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_
|
||||
#define REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_
|
||||
|
||||
#include <base/memory/ref_counted.h>
|
||||
#include <base/memory/scoped_ptr.h>
|
||||
|
||||
#include "third_party/libjingle/source/talk/base/sigslot.h"
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
namespace buzz {
|
||||
class XmlElement;
|
||||
} // namespace buzz
|
||||
|
||||
namespace cricket {
|
||||
class BasicPortAllocator;
|
||||
class SessionManager;
|
||||
} // namespace cricket
|
||||
|
||||
namespace talk_base {
|
||||
class NetworkManager;
|
||||
class PacketSocketFactory;
|
||||
} // namespace talk_base
|
||||
|
||||
namespace remoting {
|
||||
|
||||
class JingleThread;
|
||||
|
||||
class SessionManagerPair
|
||||
: public sigslot::has_slots<>,
|
||||
public base::RefCountedThreadSafe<SessionManagerPair>{
|
||||
public:
|
||||
static const char kHostJid[];
|
||||
static const char kClientJid[];
|
||||
|
||||
SessionManagerPair(JingleThread* thread);
|
||||
virtual ~SessionManagerPair();
|
||||
|
||||
void Init();
|
||||
|
||||
// The session managers are named 'host' and 'client' just for convenience.
|
||||
// Both can be used for client or host.
|
||||
cricket::SessionManager* host_session_manager();
|
||||
cricket::SessionManager* client_session_manager();
|
||||
|
||||
private:
|
||||
void ProcessMessage(cricket::SessionManager* manager,
|
||||
const buzz::XmlElement* stanza);
|
||||
void DoProcessMessage(cricket::SessionManager* manager,
|
||||
buzz::XmlElement* stanza);
|
||||
void DeliverMessage(cricket::SessionManager* to,
|
||||
buzz::XmlElement* stanza);
|
||||
|
||||
MessageLoop* message_loop_;
|
||||
scoped_ptr<talk_base::NetworkManager> network_manager_;
|
||||
scoped_ptr<talk_base::PacketSocketFactory> socket_factory_;
|
||||
scoped_ptr<cricket::BasicPortAllocator> port_allocator_;
|
||||
scoped_ptr<cricket::SessionManager> host_session_manager_;
|
||||
scoped_ptr<cricket::SessionManager> client_session_manager_;
|
||||
};
|
||||
|
||||
} // namespace remoting
|
||||
|
||||
#endif // REMOTING_PROTOCOL_MOCK_SESSION_MANAGER_H_
|
@ -731,8 +731,6 @@
|
||||
'protocol/rtp_video_reader_unittest.cc',
|
||||
'protocol/rtp_video_writer_unittest.cc',
|
||||
'protocol/secure_p2p_socket_unittest.cc',
|
||||
'protocol/session_manager_pair.cc',
|
||||
'protocol/session_manager_pair.h',
|
||||
'run_all_unittests.cc',
|
||||
],
|
||||
'conditions': [
|
||||
|
Reference in New Issue
Block a user