Skip to content

Commit

Permalink
Remove use of deprecated MessageLoop methods in sql.
Browse files Browse the repository at this point in the history
MessageLoop::PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon
are deprecated. This CL makes the following replacements to
remove some uses of these methods:

"MessageLoop::current()->PostTask" ->
  "ThreadTaskRunnerHandle::Get()->PostTask"
"MessageLoop::current()->PostDelayedTask" ->
  "ThreadTaskRunnerHandle::Get()->PostDelayedTask"
"MessageLoop::current()->DeleteSoon" ->
  "ThreadTaskRunnerHandle::Get()->DeleteSoon"
"MessageLoop::current()->ReleaseSoon" ->
  "ThreadTaskRunnerHandle::Get()->ReleaseSoon"

In files where these replacements are made, it adds these includes:
  #include "base/location.h"
  #include "base/single_thread_task_runner.h"
  #include "base/threading/thread_task_runner_handle.h"

And removes this include if it is no longer required:
  #include "base/message_loop/message_loop.h"

Why ThreadTaskRunnerHandle::Get() instead of
MessageLoop::current()->task_runner()?
 - The two are equivalent on threads that run a MessageLoop.
 - MessageLoop::current() doesn't work in base/task_scheduler
   because the scheduler's thread don't run MessageLoops.
   This CL will therefore facilitate the migration of browser
   threads to base/task_scheduler.

Steps to generate this patch:
1. Run message_loop_cleanup.py (see code on the bug).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.

BUG=616447
R=shess@chromium.org

Review-Url: https://codereview.chromium.org/2033693004
Cr-Commit-Position: refs/heads/master@{#398284}
  • Loading branch information
fdoray authored and Commit bot committed Jun 7, 2016
1 parent d8fc081 commit 2dfa764
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
#include "base/format_macros.h"
#include "base/json/json_file_value_serializer.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
#include "sql/connection_memory_dump_provider.h"
#include "sql/meta_table.h"
Expand Down Expand Up @@ -159,18 +161,18 @@ void InitializeSqlite() {
sqlite3_initialize();

// Schedule callback to record memory footprint histograms at 10m, 1h, and
// 1d. There may not be a message loop in tests.
if (base::MessageLoop::current()) {
base::MessageLoop::current()->PostDelayedTask(
// 1d. There may not be a registered thread task runner in tests.
if (base::ThreadTaskRunnerHandle::IsSet()) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&RecordSqliteMemory10Min),
base::TimeDelta::FromMinutes(10));
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&RecordSqliteMemoryHour),
base::TimeDelta::FromHours(1));
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&RecordSqliteMemoryDay),
base::TimeDelta::FromDays(1));
base::MessageLoop::current()->PostDelayedTask(
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&RecordSqliteMemoryWeek),
base::TimeDelta::FromDays(7));
}
Expand Down

0 comments on commit 2dfa764

Please sign in to comment.