summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-07 01:07:12 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-07 01:07:12 +0000
commit672704ff9b8498f28467cb1965407b98e79c71f2 (patch)
treeba692b300c040ffe9aefe8bb1ff69cd57a10b16e /remoting/jingle_glue
parent9e878ec93f9326d0f2c4d0a789ca53c88d09bfc1 (diff)
downloadchromium_src-672704ff9b8498f28467cb1965407b98e79c71f2.zip
chromium_src-672704ff9b8498f28467cb1965407b98e79c71f2.tar.gz
chromium_src-672704ff9b8498f28467cb1965407b98e79c71f2.tar.bz2
Move ChromotingHost initialization to the network thread.
Previously XmppSignalStrategy, ChromotingHost and some other objects were created on main or plugin thread but worked on the network thread. This could potentially cause synchronization bugs. Now it is possible to mark XmppSignalStrategy and LogToServer as NonThreadSafe to ensure that they are used only on the network thread. Review URL: http://codereview.chromium.org/9051001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.cc14
-rw-r--r--remoting/jingle_glue/xmpp_signal_strategy.h6
2 files changed, 17 insertions, 3 deletions
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.cc b/remoting/jingle_glue/xmpp_signal_strategy.cc
index f367b65..1e780e0 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.cc
+++ b/remoting/jingle_glue/xmpp_signal_strategy.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -32,6 +32,8 @@ XmppSignalStrategy::~XmppSignalStrategy() {
}
void XmppSignalStrategy::Connect() {
+ DCHECK(CalledOnValidThread());
+
// Disconnect first if we are currently connected.
Disconnect();
@@ -56,6 +58,8 @@ void XmppSignalStrategy::Connect() {
}
void XmppSignalStrategy::Disconnect() {
+ DCHECK(CalledOnValidThread());
+
if (xmpp_client_) {
xmpp_client_->engine()->RemoveStanzaHandler(this);
@@ -68,22 +72,27 @@ void XmppSignalStrategy::Disconnect() {
}
SignalStrategy::State XmppSignalStrategy::GetState() const {
+ DCHECK(CalledOnValidThread());
return state_;
}
std::string XmppSignalStrategy::GetLocalJid() const {
+ DCHECK(CalledOnValidThread());
return xmpp_client_->jid().Str();
}
void XmppSignalStrategy::AddListener(Listener* listener) {
+ DCHECK(CalledOnValidThread());
listeners_.AddObserver(listener);
}
void XmppSignalStrategy::RemoveListener(Listener* listener) {
+ DCHECK(CalledOnValidThread());
listeners_.RemoveObserver(listener);
}
bool XmppSignalStrategy::SendStanza(buzz::XmlElement* stanza) {
+ DCHECK(CalledOnValidThread());
if (!xmpp_client_) {
LOG(INFO) << "Dropping signalling message because XMPP "
"connection has been terminated.";
@@ -96,6 +105,7 @@ bool XmppSignalStrategy::SendStanza(buzz::XmlElement* stanza) {
}
std::string XmppSignalStrategy::GetNextId() {
+ DCHECK(CalledOnValidThread());
if (!xmpp_client_) {
// If the connection has been terminated then it doesn't matter
// what Id we return.
@@ -105,6 +115,7 @@ std::string XmppSignalStrategy::GetNextId() {
}
bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) {
+ DCHECK(CalledOnValidThread());
ObserverListBase<Listener>::Iterator it(listeners_);
Listener* listener;
while ((listener = it.GetNext()) != NULL) {
@@ -116,6 +127,7 @@ bool XmppSignalStrategy::HandleStanza(const buzz::XmlElement* stanza) {
void XmppSignalStrategy::OnConnectionStateChanged(
buzz::XmppEngine::State state) {
+ DCHECK(CalledOnValidThread());
State new_state;
switch (state) {
diff --git a/remoting/jingle_glue/xmpp_signal_strategy.h b/remoting/jingle_glue/xmpp_signal_strategy.h
index 8695c90..37d38bd 100644
--- a/remoting/jingle_glue/xmpp_signal_strategy.h
+++ b/remoting/jingle_glue/xmpp_signal_strategy.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -16,6 +16,7 @@
#include "base/compiler_specific.h"
#include "base/observer_list.h"
+#include "base/threading/non_thread_safe.h"
#include "third_party/libjingle/source/talk/base/sigslot.h"
#include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
@@ -23,7 +24,8 @@ namespace remoting {
class JingleThread;
-class XmppSignalStrategy : public SignalStrategy,
+class XmppSignalStrategy : public base::NonThreadSafe,
+ public SignalStrategy,
public buzz::XmppStanzaHandler,
public sigslot::has_slots<> {
public: