summaryrefslogtreecommitdiffstats
path: root/remoting/jingle_glue/jingle_test_client.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-28 02:14:12 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-28 02:14:12 +0000
commit0f935491a6bb96ebad37266ce4f5fb98657c1391 (patch)
treef2ba72e83ef7f9782e80643ccebacae11116b3fc /remoting/jingle_glue/jingle_test_client.cc
parent087574ee809adadd4001fceb330e7954a1c65d8e (diff)
downloadchromium_src-0f935491a6bb96ebad37266ce4f5fb98657c1391.zip
chromium_src-0f935491a6bb96ebad37266ce4f5fb98657c1391.tar.gz
chromium_src-0f935491a6bb96ebad37266ce4f5fb98657c1391.tar.bz2
Jingle_glue bugfixes.
Fixed Closed() methods in JingleChannel and JingleClient so that they are not blocking and guarantee that callback is not called afterwards. Changed JingleThread shutdown mechanism so that the thread doesn't stop until all tasks are finished. JingleClient now uses LocalTunnelSessionClient that allows local connections. BUG=52889 TEST=unittests Review URL: http://codereview.chromium.org/3167047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue/jingle_test_client.cc')
-rw-r--r--remoting/jingle_glue/jingle_test_client.cc29
1 files changed, 24 insertions, 5 deletions
diff --git a/remoting/jingle_glue/jingle_test_client.cc b/remoting/jingle_glue/jingle_test_client.cc
index 255a931..4157930b 100644
--- a/remoting/jingle_glue/jingle_test_client.cc
+++ b/remoting/jingle_glue/jingle_test_client.cc
@@ -14,6 +14,8 @@ extern "C" {
#include <list>
#include "base/at_exit.h"
+#include "base/nss_util.h"
+#include "base/time.h"
#include "media/base/data_buffer.h"
#include "remoting/base/constants.h"
#include "remoting/jingle_glue/jingle_channel.h"
@@ -25,13 +27,17 @@ using remoting::JingleChannel;
using remoting::kChromotingTokenServiceName;
class JingleTestClient : public JingleChannel::Callback,
- public JingleClient::Callback {
+ public JingleClient::Callback,
+ public base::RefCountedThreadSafe<JingleTestClient> {
public:
+ JingleTestClient()
+ : closed_event_(true, false) {
+ }
+
virtual ~JingleTestClient() {}
void Run(const std::string& username, const std::string& auth_token,
const std::string& host_jid) {
- // TODO(hclam): Fix the threading problem.
remoting::JingleThread jingle_thread;
jingle_thread.Start();
client_ = new JingleClient(&jingle_thread);
@@ -63,7 +69,12 @@ class JingleTestClient : public JingleChannel::Callback,
}
while (!channels_.empty()) {
- channels_.front()->Close();
+ closed_event_.Reset();
+ channels_.front()->Close(
+ NewRunnableMethod(this, &JingleTestClient::OnClosed));
+ // Wait until channel is closed. If it is not closed within 0.1 seconds
+ // continue closing everything else.
+ closed_event_.TimedWait(base::TimeDelta::FromMilliseconds(100));
channels_.pop_front();
}
@@ -106,12 +117,17 @@ class JingleTestClient : public JingleChannel::Callback,
channels_.push_back(channel);
}
+ void OnClosed() {
+ closed_event_.Signal();
+ }
+
private:
typedef std::list<scoped_refptr<JingleChannel> > ChannelsList;
scoped_refptr<JingleClient> client_;
ChannelsList channels_;
Lock channels_lock_;
+ base::WaitableEvent closed_event_;
};
int main(int argc, char** argv) {
@@ -120,6 +136,9 @@ int main(int argc, char** argv) {
base::AtExitManager exit_manager;
+ base::EnsureNSPRInit();
+ base::EnsureNSSInit();
+
std::string host_jid = argc == 2 ? argv[1] : "";
std::string username;
@@ -130,9 +149,9 @@ int main(int argc, char** argv) {
std::cout << "Auth token: ";
std::cin >> auth_token;
- JingleTestClient client;
+ scoped_refptr<JingleTestClient> client = new JingleTestClient();
- client.Run(username, auth_token, host_jid);
+ client->Run(username, auth_token, host_jid);
return 0;
}