summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/client/client_context.cc8
-rw-r--r--remoting/client/client_context.h2
-rw-r--r--remoting/client/plugin/chromoting_instance.cc2
-rw-r--r--remoting/host/chromoting_host.cc4
-rw-r--r--remoting/jingle_glue/jingle_client.cc9
-rw-r--r--remoting/jingle_glue/jingle_client.h6
-rw-r--r--remoting/jingle_glue/jingle_client_unittest.cc11
-rw-r--r--remoting/protocol/connection_to_host.cc25
-rw-r--r--remoting/protocol/connection_to_host.h7
-rw-r--r--remoting/protocol/jingle_session.cc1
-rw-r--r--remoting/protocol/jingle_session_manager.cc32
-rw-r--r--remoting/protocol/jingle_session_manager.h11
-rw-r--r--remoting/protocol/jingle_session_unittest.cc4
-rw-r--r--remoting/protocol/protocol_test_client.cc6
14 files changed, 52 insertions, 76 deletions
diff --git a/remoting/client/client_context.cc b/remoting/client/client_context.cc
index bf136c9..5f6d139 100644
--- a/remoting/client/client_context.cc
+++ b/remoting/client/client_context.cc
@@ -37,10 +37,6 @@ JingleThread* ClientContext::jingle_thread() {
return &jingle_thread_;
}
-MessageLoop* ClientContext::jingle_message_loop() {
- return jingle_thread_.message_loop();
-}
-
MessageLoop* ClientContext::main_message_loop() {
return main_thread_.message_loop();
}
@@ -49,4 +45,8 @@ MessageLoop* ClientContext::decode_message_loop() {
return decode_thread_.message_loop();
}
+MessageLoop* ClientContext::network_message_loop() {
+ return jingle_thread_.message_loop();
+}
+
} // namespace remoting
diff --git a/remoting/client/client_context.h b/remoting/client/client_context.h
index 9baa3af..38c6088 100644
--- a/remoting/client/client_context.h
+++ b/remoting/client/client_context.h
@@ -23,10 +23,10 @@ class ClientContext {
void Stop();
JingleThread* jingle_thread();
- MessageLoop* jingle_message_loop();
MessageLoop* main_message_loop();
MessageLoop* decode_message_loop();
+ MessageLoop* network_message_loop();
private:
// A thread that handles Jingle network operations (used in
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 1a31af2..c1d7548 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -97,7 +97,7 @@ bool ChromotingInstance::Init(uint32_t argc,
// Create the chromoting objects.
host_connection_.reset(new protocol::ConnectionToHost(
- context_.jingle_thread(), network_manager, socket_factory,
+ context_.network_message_loop(), network_manager, socket_factory,
session_factory));
view_.reset(new PepperView(this, &context_));
view_proxy_ = new PepperViewProxy(this, view_.get());
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 0ebff52..ec9e8a2 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -117,7 +117,7 @@ void ChromotingHost::Start() {
new XmppSignalStrategy(context_->jingle_thread(), xmpp_login,
xmpp_auth_token,
xmpp_auth_service));
- jingle_client_ = new JingleClient(context_->jingle_thread(),
+ jingle_client_ = new JingleClient(context_->network_message_loop(),
signal_strategy_.get(),
NULL, NULL, NULL, this);
jingle_client_->Init();
@@ -236,7 +236,7 @@ void ChromotingHost::OnStateChange(JingleClient* jingle_client,
// Create and start session manager.
protocol::JingleSessionManager* server =
- new protocol::JingleSessionManager(context_->jingle_thread());
+ new protocol::JingleSessionManager(context_->network_message_loop());
// TODO(ajwong): Make this a command switch when we're more stable.
server->set_allow_local_ips(true);
diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc
index 87f8c58..79688a9 100644
--- a/remoting/jingle_glue/jingle_client.cc
+++ b/remoting/jingle_glue/jingle_client.cc
@@ -19,14 +19,14 @@
namespace remoting {
-JingleClient::JingleClient(JingleThread* thread,
+JingleClient::JingleClient(MessageLoop* message_loop,
SignalStrategy* signal_strategy,
talk_base::NetworkManager* network_manager,
talk_base::PacketSocketFactory* socket_factory,
PortAllocatorSessionFactory* session_factory,
Callback* callback)
: enable_nat_traversing_(false),
- thread_(thread),
+ message_loop_(message_loop),
state_(START),
initialized_(false),
closed_(false),
@@ -36,6 +36,7 @@ JingleClient::JingleClient(JingleThread* thread,
network_manager_(network_manager),
socket_factory_(socket_factory),
port_allocator_session_factory_(session_factory) {
+ DCHECK(message_loop_);
}
JingleClient::~JingleClient() {
@@ -120,7 +121,7 @@ void JingleClient::Close(Task* closed_task) {
// If the client is already closed then don't close again.
if (closed_) {
if (closed_task)
- thread_->message_loop()->PostTask(FROM_HERE, closed_task);
+ message_loop_->PostTask(FROM_HERE, closed_task);
return;
}
closed_task_.reset(closed_task);
@@ -156,7 +157,7 @@ IqRequest* JingleClient::CreateIqRequest() {
}
MessageLoop* JingleClient::message_loop() {
- return thread_->message_loop();
+ return message_loop_;
}
cricket::SessionManager* JingleClient::session_manager() {
diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h
index 646afac..1000c35 100644
--- a/remoting/jingle_glue/jingle_client.h
+++ b/remoting/jingle_glue/jingle_client.h
@@ -37,7 +37,6 @@ class SessionManager;
namespace remoting {
class JingleInfoRequest;
-class JingleThread;
class PortAllocatorSessionFactory;
class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
@@ -54,7 +53,7 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
// Physical sockets are used if |network_manager| and
// |socket_factory| are set to NULL. Otherwise ownership of these
// objects is given to JingleClient.
- JingleClient(JingleThread* thread,
+ JingleClient(MessageLoop* message_loop,
SignalStrategy* signal_strategy,
talk_base::NetworkManager* network_manager,
talk_base::PacketSocketFactory* socket_factory,
@@ -113,8 +112,7 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>,
// network.
bool enable_nat_traversing_;
- // JingleThread used for the connection. Set in the constructor.
- JingleThread* thread_;
+ MessageLoop* message_loop_;
// Current state of the object.
// Must be locked when accessing initialized_ or closed_.
diff --git a/remoting/jingle_glue/jingle_client_unittest.cc b/remoting/jingle_glue/jingle_client_unittest.cc
index 3a3f80a..9c50678 100644
--- a/remoting/jingle_glue/jingle_client_unittest.cc
+++ b/remoting/jingle_glue/jingle_client_unittest.cc
@@ -40,9 +40,11 @@ class JingleClientTest : public testing::Test {
protected:
virtual void SetUp() {
+ thread_.Start();
+
signal_strategy_.reset(new XmppSignalStrategy(&thread_, "", "", ""));
- client_ = new JingleClient(&thread_, signal_strategy_.get(), NULL,
- NULL, NULL, &callback_);
+ client_ = new JingleClient(thread_.message_loop(), signal_strategy_.get(),
+ NULL, NULL, NULL, &callback_);
// Fake initialization.
client_->initialized_ = true;
signal_strategy_->observer_ = client_;
@@ -58,8 +60,6 @@ TEST_F(JingleClientTest, OnStateChanged) {
EXPECT_CALL(callback_, OnStateChange(_, JingleClient::CONNECTING))
.Times(1);
- thread_.Start();
-
base::WaitableEvent state_changed_event(true, false);
thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction(
&JingleClientTest::ChangeState, signal_strategy_.get(),
@@ -74,7 +74,6 @@ TEST_F(JingleClientTest, OnStateChanged) {
TEST_F(JingleClientTest, Close) {
EXPECT_CALL(callback_, OnStateChange(_, _))
.Times(0);
- thread_.Start();
client_->Close();
// Verify that the channel doesn't call callback anymore.
thread_.message_loop()->PostTask(FROM_HERE, NewRunnableFunction(
@@ -85,7 +84,6 @@ TEST_F(JingleClientTest, Close) {
}
TEST_F(JingleClientTest, ClosedTask) {
- thread_.Start();
bool closed = false;
client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed,
&closed));
@@ -94,7 +92,6 @@ TEST_F(JingleClientTest, ClosedTask) {
}
TEST_F(JingleClientTest, DoubleClose) {
- thread_.Start();
bool closed1 = false;
client_->Close(NewRunnableFunction(&JingleClientTest::OnClosed,
&closed1));
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc
index 6f29bc6..b8f4340 100644
--- a/remoting/protocol/connection_to_host.cc
+++ b/remoting/protocol/connection_to_host.cc
@@ -9,7 +9,6 @@
#include "remoting/base/constants.h"
#include "remoting/jingle_glue/http_port_allocator.h"
#include "remoting/jingle_glue/javascript_signal_strategy.h"
-#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/auth_token_utils.h"
#include "remoting/protocol/client_message_dispatcher.h"
@@ -25,12 +24,12 @@ namespace remoting {
namespace protocol {
ConnectionToHost::ConnectionToHost(
- JingleThread* thread,
+ MessageLoop* message_loop,
talk_base::NetworkManager* network_manager,
talk_base::PacketSocketFactory* socket_factory,
PortAllocatorSessionFactory* session_factory)
: state_(STATE_EMPTY),
- thread_(thread),
+ message_loop_(message_loop),
network_manager_(network_manager),
socket_factory_(socket_factory),
port_allocator_session_factory_(session_factory),
@@ -51,10 +50,6 @@ HostStub* ConnectionToHost::host_stub() {
return host_stub_.get();
}
-MessageLoop* ConnectionToHost::message_loop() {
- return thread_->message_loop();
-}
-
void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy,
const std::string& your_jid,
const std::string& host_jid,
@@ -73,7 +68,7 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy,
strategy->AttachXmppProxy(xmpp_proxy);
signal_strategy_.reset(strategy);
jingle_client_ =
- new JingleClient(thread_, signal_strategy_.get(),
+ new JingleClient(message_loop_, signal_strategy_.get(),
network_manager_.release(), socket_factory_.release(),
port_allocator_session_factory_.release(), this);
jingle_client_->Init();
@@ -85,8 +80,8 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy,
}
void ConnectionToHost::Disconnect() {
- if (MessageLoop::current() != message_loop()) {
- message_loop()->PostTask(
+ if (MessageLoop::current() != message_loop_) {
+ message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(this, &ConnectionToHost::Disconnect));
return;
}
@@ -100,13 +95,13 @@ void ConnectionToHost::Disconnect() {
}
void ConnectionToHost::InitSession() {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
std::string jid = jingle_client_->GetFullJid();
// Initialize chromotocol |session_manager_|.
JingleSessionManager* session_manager =
- new JingleSessionManager(thread_);
+ new JingleSessionManager(message_loop_);
// TODO(ajwong): Make this a command switch when we're more stable.
session_manager->set_allow_local_ips(true);
session_manager->Init(
@@ -153,7 +148,7 @@ const SessionConfig* ConnectionToHost::config() {
// JingleClient::Callback interface.
void ConnectionToHost::OnStateChange(JingleClient* client,
JingleClient::State state) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
DCHECK(client);
DCHECK(event_callback_);
@@ -168,14 +163,14 @@ void ConnectionToHost::OnStateChange(JingleClient* client,
void ConnectionToHost::OnNewSession(Session* session,
SessionManager::IncomingSessionResponse* response) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
// Client always rejects incoming sessions.
*response = SessionManager::DECLINE;
}
void ConnectionToHost::OnSessionStateChange(
Session::State state) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
DCHECK(event_callback_);
switch (state) {
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index 6f0b8b2..554b760 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -64,7 +64,7 @@ class ConnectionToHost : public JingleClient::Callback {
// |network_manager| and |socket_factory| may be set to NULL.
//
// TODO(sergeyu): Constructor shouldn't need thread here.
- ConnectionToHost(JingleThread* thread,
+ ConnectionToHost(MessageLoop* network_message_loop,
talk_base::NetworkManager* network_manager,
talk_base::PacketSocketFactory* socket_factory,
PortAllocatorSessionFactory* session_factory);
@@ -104,9 +104,6 @@ class ConnectionToHost : public JingleClient::Callback {
State state() const;
private:
- // The message loop for the jingle thread this object works on.
- MessageLoop* message_loop();
-
// Called on the jingle thread after we've successfully to XMPP server. Starts
// P2P connection to the host.
void InitSession();
@@ -122,7 +119,7 @@ class ConnectionToHost : public JingleClient::Callback {
// Internal state of the connection.
State state_;
- JingleThread* thread_;
+ MessageLoop* message_loop_;
scoped_ptr<talk_base::NetworkManager> network_manager_;
scoped_ptr<talk_base::PacketSocketFactory> socket_factory_;
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index 3d89f14..aac0484 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -20,7 +20,6 @@
#include "net/socket/ssl_client_socket.h"
#include "net/socket/ssl_server_socket.h"
#include "remoting/base/constants.h"
-#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/socket_wrapper.h"
#include "third_party/libjingle/source/talk/base/thread.h"
diff --git a/remoting/protocol/jingle_session_manager.cc b/remoting/protocol/jingle_session_manager.cc
index 1191914..f665553 100644
--- a/remoting/protocol/jingle_session_manager.cc
+++ b/remoting/protocol/jingle_session_manager.cc
@@ -11,7 +11,6 @@
#include "base/rand_util.h"
#include "base/string_number_conversions.h"
#include "remoting/base/constants.h"
-#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/proto/auth.pb.h"
#include "third_party/libjingle/source/talk/p2p/base/constants.h"
#include "third_party/libjingle/source/talk/p2p/base/transport.h"
@@ -169,13 +168,12 @@ ContentDescription::ContentDescription(
ContentDescription::~ContentDescription() { }
-JingleSessionManager::JingleSessionManager(
- JingleThread* jingle_thread)
- : jingle_thread_(jingle_thread),
+JingleSessionManager::JingleSessionManager(MessageLoop* message_loop)
+ : message_loop_(message_loop),
cricket_session_manager_(NULL),
allow_local_ips_(false),
closed_(false) {
- DCHECK(jingle_thread_);
+ DCHECK(message_loop);
}
void JingleSessionManager::Init(
@@ -184,8 +182,8 @@ void JingleSessionManager::Init(
IncomingSessionCallback* incoming_session_callback,
crypto::RSAPrivateKey* private_key,
scoped_refptr<net::X509Certificate> certificate) {
- if (MessageLoop::current() != message_loop()) {
- message_loop()->PostTask(
+ if (MessageLoop::current() != message_loop_) {
+ message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(
this, &JingleSessionManager::Init,
local_jid, cricket_session_manager, incoming_session_callback,
@@ -209,8 +207,8 @@ JingleSessionManager::~JingleSessionManager() {
}
void JingleSessionManager::Close(Task* closed_task) {
- if (MessageLoop::current() != message_loop()) {
- message_loop()->PostTask(
+ if (MessageLoop::current() != message_loop_) {
+ message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(this, &JingleSessionManager::Close,
closed_task));
return;
@@ -247,7 +245,7 @@ scoped_refptr<protocol::Session> JingleSessionManager::Connect(
jingle_session->set_candidate_config(candidate_config);
jingle_session->set_receiver_token(receiver_token);
- message_loop()->PostTask(
+ message_loop_->PostTask(
FROM_HERE, NewRunnableMethod(this, &JingleSessionManager::DoConnect,
jingle_session, host_jid,
host_public_key, receiver_token,
@@ -261,7 +259,7 @@ void JingleSessionManager::DoConnect(
const std::string& host_public_key,
const std::string& receiver_token,
protocol::Session::StateChangeCallback* state_change_callback) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
cricket::Session* cricket_session = cricket_session_manager_->CreateSession(
local_jid_, kChromotingXmlNamespace);
@@ -275,17 +273,13 @@ void JingleSessionManager::DoConnect(
jingle_session->GetEncryptedMasterKey()));
}
-JingleThread* JingleSessionManager::jingle_thread() {
- return jingle_thread_;
-}
-
MessageLoop* JingleSessionManager::message_loop() {
- return jingle_thread_->message_loop();
+ return message_loop_;
}
void JingleSessionManager::OnSessionCreate(
cricket::Session* cricket_session, bool incoming) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
// Allow local connections if neccessary.
cricket_session->set_allow_local_ips(allow_local_ips_);
@@ -303,7 +297,7 @@ void JingleSessionManager::OnSessionCreate(
}
void JingleSessionManager::OnSessionDestroy(cricket::Session* cricket_session) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
std::list<scoped_refptr<JingleSession> >::iterator it;
for (it = sessions_.begin(); it != sessions_.end(); ++it) {
@@ -318,7 +312,7 @@ void JingleSessionManager::OnSessionDestroy(cricket::Session* cricket_session) {
void JingleSessionManager::AcceptConnection(
JingleSession* jingle_session,
cricket::Session* cricket_session) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
+ DCHECK_EQ(message_loop_, MessageLoop::current());
// Reject connection if we are closed.
if (closed_) {
diff --git a/remoting/protocol/jingle_session_manager.h b/remoting/protocol/jingle_session_manager.h
index c53567a..b91087f 100644
--- a/remoting/protocol/jingle_session_manager.h
+++ b/remoting/protocol/jingle_session_manager.h
@@ -28,8 +28,6 @@ class SessionManager;
namespace remoting {
-class JingleThread;
-
namespace protocol {
// ContentDescription used for chromoting sessions. It contains the information
@@ -75,7 +73,7 @@ class JingleSessionManager
: public protocol::SessionManager,
public cricket::SessionClient {
public:
- explicit JingleSessionManager(remoting::JingleThread* jingle_thread);
+ explicit JingleSessionManager(MessageLoop* message_loop);
// Initializes the session client. Doesn't accept ownership of the
// |session_manager|. Close() must be called _before_ the |session_manager|
@@ -122,10 +120,7 @@ class JingleSessionManager
private:
friend class JingleSession;
- // The jingle thread used by this object.
- JingleThread* jingle_thread();
-
- // Message loop that corresponds to jingle_thread().
+ // Message loop that corresponds to the network thread.
MessageLoop* message_loop();
// Called by JingleChromotocolConnection when a new connection is initiated.
@@ -150,7 +145,7 @@ class JingleSessionManager
scoped_refptr<net::X509Certificate> certificate);
std::string local_jid_; // Full jid for the local side of the session.
- JingleThread* jingle_thread_;
+ MessageLoop* message_loop_;
cricket::SessionManager* cricket_session_manager_;
scoped_ptr<IncomingSessionCallback> incoming_session_callback_;
bool allow_local_ips_;
diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc
index c70fc2e..003fcfd 100644
--- a/remoting/protocol/jingle_session_unittest.cc
+++ b/remoting/protocol/jingle_session_unittest.cc
@@ -151,7 +151,7 @@ class JingleSessionTest : public testing::Test {
session_manager_pair_ = new SessionManagerPair(&thread_);
session_manager_pair_->Init();
- host_server_ = new JingleSessionManager(&thread_);
+ host_server_ = new JingleSessionManager(thread_.message_loop());
host_server_->set_allow_local_ips(true);
host_server_->Init(
SessionManagerPair::kHostJid,
@@ -161,7 +161,7 @@ class JingleSessionTest : public testing::Test {
private_key.release(),
cert);
- client_server_ = new JingleSessionManager(&thread_);
+ client_server_ = new JingleSessionManager(thread_.message_loop());
client_server_->set_allow_local_ips(true);
client_server_->Init(
SessionManagerPair::kClientJid,
diff --git a/remoting/protocol/protocol_test_client.cc b/remoting/protocol/protocol_test_client.cc
index 586776f..39abd70 100644
--- a/remoting/protocol/protocol_test_client.cc
+++ b/remoting/protocol/protocol_test_client.cc
@@ -231,11 +231,11 @@ void ProtocolTestClient::Run(const std::string& username,
signal_strategy_.reset(
new XmppSignalStrategy(&jingle_thread, username, auth_token,
auth_service));
- client_ = new JingleClient(&jingle_thread, signal_strategy_.get(),
- NULL, NULL, NULL, this);
+ client_ = new JingleClient(jingle_thread.message_loop(),
+ signal_strategy_.get(), NULL, NULL, NULL, this);
client_->Init();
- session_manager_ = new JingleSessionManager(&jingle_thread);
+ session_manager_ = new JingleSessionManager(jingle_thread.message_loop());
host_jid_ = host_jid;