Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: jingle/notifier/listener/mediator_thread_impl.cc

Issue 3358028: Revert r59012 which started using Chrome sockets for sync. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jingle/notifier/listener/mediator_thread_impl.h ('k') | remoting/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/notifier/listener/mediator_thread_impl.cc
diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc
index 918b49bf85ca6d39153ad10a60379e3a5c85cbd5..02d48fb17a877730791f3abe62f54f2d713f7847 100644
--- a/jingle/notifier/listener/mediator_thread_impl.cc
+++ b/jingle/notifier/listener/mediator_thread_impl.cc
@@ -16,6 +16,8 @@
#include "jingle/notifier/listener/subscribe_task.h"
#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
+#include "talk/base/physicalsocketserver.h"
+#include "talk/base/thread.h"
#include "talk/xmpp/xmppclient.h"
#include "talk/xmpp/xmppclientsettings.h"
@@ -49,6 +51,44 @@ void MediatorThreadImpl::Start() {
// TODO(akalin): Make this function return a bool and remove this
// CHECK().
CHECK(worker_thread_.StartWithOptions(options));
+ if (!notifier_options_.use_chrome_async_socket) {
+ worker_message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &MediatorThreadImpl::StartLibjingleThread));
+ }
+}
+
+void MediatorThreadImpl::StartLibjingleThread() {
+ DCHECK_EQ(MessageLoop::current(), worker_message_loop());
+ DCHECK(!notifier_options_.use_chrome_async_socket);
+ socket_server_.reset(new talk_base::PhysicalSocketServer());
+ libjingle_thread_.reset(new talk_base::Thread());
+ talk_base::ThreadManager::SetCurrent(libjingle_thread_.get());
+ worker_message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &MediatorThreadImpl::PumpLibjingleLoop));
+}
+
+void MediatorThreadImpl::StopLibjingleThread() {
+ DCHECK_EQ(MessageLoop::current(), worker_message_loop());
+ DCHECK(!notifier_options_.use_chrome_async_socket);
+ talk_base::ThreadManager::SetCurrent(NULL);
+ libjingle_thread_.reset();
+ socket_server_.reset();
+}
+
+void MediatorThreadImpl::PumpLibjingleLoop() {
+ DCHECK_EQ(MessageLoop::current(), worker_message_loop());
+ DCHECK(!notifier_options_.use_chrome_async_socket);
+ // Pump the libjingle message loop 100ms at a time.
+ if (!libjingle_thread_.get()) {
+ // StopLibjingleThread() was called.
+ return;
+ }
+ libjingle_thread_->ProcessMessages(100);
+ worker_message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &MediatorThreadImpl::PumpLibjingleLoop));
}
void MediatorThreadImpl::Login(const buzz::XmppClientSettings& settings) {
@@ -63,6 +103,11 @@ void MediatorThreadImpl::Logout() {
worker_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &MediatorThreadImpl::DoDisconnect));
+ if (!notifier_options_.use_chrome_async_socket) {
+ worker_message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &MediatorThreadImpl::StopLibjingleThread));
+ }
// TODO(akalin): Decomp this into a separate stop method.
worker_thread_.Stop();
// Process any messages the worker thread may be posted on our
@@ -160,6 +205,7 @@ void MediatorThreadImpl::DoLogin(
// Language is not used in the stanza so we default to |en|.
std::string lang = "en";
login_.reset(new notifier::Login(pump_.get(),
+ notifier_options_.use_chrome_async_socket,
settings,
options,
lang,
« no previous file with comments | « jingle/notifier/listener/mediator_thread_impl.h ('k') | remoting/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698