Commit cb692893 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Migrate MessageLoop::current() to MessageLoopCurrent in /ios/web

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=eugenebut@chromium.org

Bug: 825327
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ic89cc4297947534db6418c8c1b65f18a9528c71f
Reviewed-on: https://chromium-review.googlesource.com/1024872
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553851}
parent 02413949
...@@ -27,7 +27,7 @@ namespace web { ...@@ -27,7 +27,7 @@ namespace web {
// should be done immediately before the start of the main message loop // should be done immediately before the start of the main message loop
// should go in |PreMainMessageLoopStart()|. // should go in |PreMainMessageLoopStart()|.
// - RunMainMessageLoopParts: things to be done before and after invoking the // - RunMainMessageLoopParts: things to be done before and after invoking the
// main message loop run method (e.g. MessageLoopForUI::current()->Run()). // main message loop run method (e.g. MessageLoopCurrentForUI::Get()->Run()).
// //
// How to add stuff (to existing parts): // How to add stuff (to existing parts):
// - Figure out when your new code should be executed. What must happen // - Figure out when your new code should be executed. What must happen
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/task_scheduler/initialization_util.h" #include "base/task_scheduler/initialization_util.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
...@@ -58,10 +59,10 @@ void BuildMessageLoop() { ...@@ -58,10 +59,10 @@ void BuildMessageLoop() {
dispatch_once(&once_token, ^{ dispatch_once(&once_token, ^{
// Create a MessageLoop if one does not already exist for the current // Create a MessageLoop if one does not already exist for the current
// thread. // thread.
if (!base::MessageLoop::current()) { if (!base::MessageLoopCurrent::Get()) {
g_message_loop = new base::MessageLoopForUI(); g_message_loop = new base::MessageLoopForUI();
} }
base::MessageLoopForUI::current()->Attach(); base::MessageLoopCurrentForUI::Get()->Attach();
}); });
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
...@@ -88,15 +89,16 @@ class ServiceManagerConnectionImpl::IOThreadContext ...@@ -88,15 +89,16 @@ class ServiceManagerConnectionImpl::IOThreadContext
private: private:
friend class base::RefCountedThreadSafe<IOThreadContext>; friend class base::RefCountedThreadSafe<IOThreadContext>;
class MessageLoopObserver : public base::MessageLoop::DestructionObserver { class MessageLoopObserver
: public base::MessageLoopCurrent::DestructionObserver {
public: public:
explicit MessageLoopObserver(base::WeakPtr<IOThreadContext> context) explicit MessageLoopObserver(base::WeakPtr<IOThreadContext> context)
: context_(context) { : context_(context) {
base::MessageLoop::current()->AddDestructionObserver(this); base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
} }
~MessageLoopObserver() override { ~MessageLoopObserver() override {
base::MessageLoop::current()->RemoveDestructionObserver(this); base::MessageLoopCurrent::Get()->RemoveDestructionObserver(this);
} }
void ShutDown() { void ShutDown() {
......
...@@ -31,7 +31,7 @@ class URLFetcherBlockAdapterTest : public PlatformTest { ...@@ -31,7 +31,7 @@ class URLFetcherBlockAdapterTest : public PlatformTest {
: scoped_task_environment_( : scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::UI) {} base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
// Required for base::MessageLoop::current(). // Required for base::MessageLoopCurrent::Get().
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment