Skip to content

Commit

Permalink
Remove calls to MessageLoop::current() in jingle.
Browse files Browse the repository at this point in the history
Why?
The fact that there's a MessageLoop on the thread is an
unnecessary implementation detail. When browser threads
are migrated to base/task_scheduler, tasks will no longer
have access to a MessageLoop.

These changes were generated manually.

BUG=616447
R=sergeyu@chromium.org

Review-Url: https://codereview.chromium.org/2088433002
Cr-Commit-Position: refs/heads/master@{#401032}
  • Loading branch information
fdoray authored and Commit bot committed Jun 21, 2016
1 parent b4ed437 commit 038016b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 3 additions & 6 deletions jingle/glue/proxy_resolving_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/load_flags.h"
Expand Down Expand Up @@ -152,9 +153,7 @@ int ProxyResolvingClientSocket::Connect(
// We defer execution of ProcessProxyResolveDone instead of calling it
// directly here for simplicity. From the caller's point of view,
// the connect always happens asynchronously.
base::MessageLoop* message_loop = base::MessageLoop::current();
CHECK(message_loop);
message_loop->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
weak_factory_.GetWeakPtr(), status));
Expand Down Expand Up @@ -308,9 +307,7 @@ int ProxyResolvingClientSocket::ReconsiderProxyAfterError(int error) {
// In both cases we want to post ProcessProxyResolveDone (in the error case
// we might still want to fall back a direct connection).
if (rv != net::ERR_IO_PENDING) {
base::MessageLoop* message_loop = base::MessageLoop::current();
CHECK(message_loop);
message_loop->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&ProxyResolvingClientSocket::ProcessProxyResolveDone,
weak_factory_.GetWeakPtr(), rv));
Expand Down
7 changes: 3 additions & 4 deletions jingle/notifier/base/xmpp_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_piece.h"
#include "base/threading/thread_task_runner_handle.h"
#include "jingle/glue/chrome_async_socket.h"
#include "jingle/glue/task_pump.h"
#include "jingle/glue/xmpp_client_socket_factory.h"
Expand Down Expand Up @@ -82,13 +82,12 @@ XmppConnection::~XmppConnection() {
DCHECK(CalledOnValidThread());
ClearClient();
task_pump_->Stop();
base::MessageLoop* current_message_loop = base::MessageLoop::current();
CHECK(current_message_loop);
// We do this because XmppConnection may get destroyed as a result
// of a signal from XmppClient. If we delete |task_pump_| here, bad
// things happen when the stack pops back up to the XmppClient's
// (which is deleted by |task_pump_|) function.
current_message_loop->DeleteSoon(FROM_HERE, task_pump_.release());
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
task_pump_.release());
}

void XmppConnection::OnStateChange(buzz::XmppEngine::State state) {
Expand Down

0 comments on commit 038016b

Please sign in to comment.