Skip to content

Commit

Permalink
Migrate MessageLoop::current() to MessageLoopCurrent in /mojo/edk/sys…
Browse files Browse the repository at this point in the history
…tem/channel_fuchsia.cc

These changes were scripted as part of the effort to restrict exposure of the
raw MessageLoop*.

Note that many static methods exposed on MessageLoopCurrent are also deprecated
so it is very well possible that this is migrating to an already deprecated
method.

The goal of this pass is to reduce usage of MessageLoop::current() (and
ultimately make it impossible to obtain the MessageLoop* statically).

As such I will not edit this CL unless the script did something logically wrong.
I defer to owners to fix highlighted usage of already deprecated APIs.

Possible script screw ups / things to look out for in this review:
 - Storing MessageLoopCurrent in a MessageLoop* variable or comparing it against
   one (I will go over that in a separate pass).

Includes should have been stripped if that was the last usage of message_loop.h
in that file.

Please CQ if LGTY

This CL was uploaded by git cl split.

R=scottmg@chromium.org

Bug: 825327
Change-Id: I3fe0959f4d7e62f3a05a0748782a44ae2306d496
Reviewed-on: https://chromium-review.googlesource.com/1024439
Commit-Queue: Gabriel Charette <gab@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552758}
  • Loading branch information
Gabriel Charette authored and Commit Bot committed Apr 23, 2018
1 parent 32092c3 commit 4d2fa70
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mojo/edk/system/channel_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_for_io.h"
#include "base/synchronization/lock.h"
#include "base/task_runner.h"
Expand Down Expand Up @@ -185,7 +186,7 @@ class MessageView {
};

class ChannelFuchsia : public Channel,
public base::MessageLoop::DestructionObserver,
public base::MessageLoopCurrent::DestructionObserver,
public base::MessagePumpForIO::ZxHandleWatcher {
public:
ChannelFuchsia(Delegate* delegate,
Expand Down Expand Up @@ -284,17 +285,17 @@ class ChannelFuchsia : public Channel,
void StartOnIOThread() {
DCHECK(!read_watch_);

base::MessageLoop::current()->AddDestructionObserver(this);
base::MessageLoopCurrent::Get()->AddDestructionObserver(this);

read_watch_.reset(
new base::MessagePumpForIO::ZxHandleWatchController(FROM_HERE));
base::MessageLoopForIO::current()->WatchZxHandle(
base::MessageLoopCurrentForIO::Get()->WatchZxHandle(
handle_.get().as_handle(), true /* persistent */,
ZX_CHANNEL_READABLE | ZX_CHANNEL_PEER_CLOSED, read_watch_.get(), this);
}

void ShutDownOnIOThread() {
base::MessageLoop::current()->RemoveDestructionObserver(this);
base::MessageLoopCurrent::Get()->RemoveDestructionObserver(this);

read_watch_.reset();
if (leak_handle_)
Expand All @@ -305,7 +306,7 @@ class ChannelFuchsia : public Channel,
self_ = nullptr;
}

// base::MessageLoop::DestructionObserver:
// base::MessageLoopCurrent::DestructionObserver:
void WillDestroyCurrentMessageLoop() override {
DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
if (self_)
Expand Down

0 comments on commit 4d2fa70

Please sign in to comment.