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

Side by Side Diff: sql/connection.cc

Issue 2033693004: Remove use of deprecated MessageLoop methods in sql. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: if (base::MessageLoop::current()) -> if (base::ThreadTaskRunnerHandle::Get()) Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
11 11
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/debug/dump_without_crashing.h" 15 #include "base/debug/dump_without_crashing.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/format_macros.h" 18 #include "base/format_macros.h"
19 #include "base/json/json_file_value_serializer.h" 19 #include "base/json/json_file_value_serializer.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/location.h"
21 #include "base/logging.h" 22 #include "base/logging.h"
22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/metrics/sparse_histogram.h" 24 #include "base/metrics/sparse_histogram.h"
25 #include "base/single_thread_task_runner.h"
25 #include "base/strings/string_split.h" 26 #include "base/strings/string_split.h"
26 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
27 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
29 #include "base/synchronization/lock.h" 30 #include "base/synchronization/lock.h"
31 #include "base/threading/thread_task_runner_handle.h"
30 #include "base/trace_event/memory_dump_manager.h" 32 #include "base/trace_event/memory_dump_manager.h"
31 #include "sql/connection_memory_dump_provider.h" 33 #include "sql/connection_memory_dump_provider.h"
32 #include "sql/meta_table.h" 34 #include "sql/meta_table.h"
33 #include "sql/statement.h" 35 #include "sql/statement.h"
34 #include "third_party/sqlite/sqlite3.h" 36 #include "third_party/sqlite/sqlite3.h"
35 37
36 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) 38 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
37 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" 39 #include "third_party/sqlite/src/ext/icu/sqliteicu.h"
38 #endif 40 #endif
39 41
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // is changed, remove the dynamic_annotations dependency in sql.gyp. 154 // is changed, remove the dynamic_annotations dependency in sql.gyp.
153 base::LazyInstance<base::Lock>::Leaky 155 base::LazyInstance<base::Lock>::Leaky
154 g_sqlite_init_lock = LAZY_INSTANCE_INITIALIZER; 156 g_sqlite_init_lock = LAZY_INSTANCE_INITIALIZER;
155 void InitializeSqlite() { 157 void InitializeSqlite() {
156 base::AutoLock lock(g_sqlite_init_lock.Get()); 158 base::AutoLock lock(g_sqlite_init_lock.Get());
157 static bool first_call = true; 159 static bool first_call = true;
158 if (first_call) { 160 if (first_call) {
159 sqlite3_initialize(); 161 sqlite3_initialize();
160 162
161 // Schedule callback to record memory footprint histograms at 10m, 1h, and 163 // Schedule callback to record memory footprint histograms at 10m, 1h, and
162 // 1d. There may not be a message loop in tests. 164 // 1d. There may not be a registered thread task runner in tests.
163 if (base::MessageLoop::current()) { 165 if (base::ThreadTaskRunnerHandle::IsSet()) {
164 base::MessageLoop::current()->PostDelayedTask( 166 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
165 FROM_HERE, base::Bind(&RecordSqliteMemory10Min), 167 FROM_HERE, base::Bind(&RecordSqliteMemory10Min),
166 base::TimeDelta::FromMinutes(10)); 168 base::TimeDelta::FromMinutes(10));
167 base::MessageLoop::current()->PostDelayedTask( 169 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
168 FROM_HERE, base::Bind(&RecordSqliteMemoryHour), 170 FROM_HERE, base::Bind(&RecordSqliteMemoryHour),
169 base::TimeDelta::FromHours(1)); 171 base::TimeDelta::FromHours(1));
170 base::MessageLoop::current()->PostDelayedTask( 172 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
171 FROM_HERE, base::Bind(&RecordSqliteMemoryDay), 173 FROM_HERE, base::Bind(&RecordSqliteMemoryDay),
172 base::TimeDelta::FromDays(1)); 174 base::TimeDelta::FromDays(1));
173 base::MessageLoop::current()->PostDelayedTask( 175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
174 FROM_HERE, base::Bind(&RecordSqliteMemoryWeek), 176 FROM_HERE, base::Bind(&RecordSqliteMemoryWeek),
175 base::TimeDelta::FromDays(7)); 177 base::TimeDelta::FromDays(7));
176 } 178 }
177 179
178 first_call = false; 180 first_call = false;
179 } 181 }
180 } 182 }
181 183
182 // Helper to get the sqlite3_file* associated with the "main" database. 184 // Helper to get the sqlite3_file* associated with the "main" database.
183 int GetSqlite3File(sqlite3* db, sqlite3_file** file) { 185 int GetSqlite3File(sqlite3* db, sqlite3_file** file) {
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 ignore_result(Execute(kNoWritableSchema)); 1975 ignore_result(Execute(kNoWritableSchema));
1974 1976
1975 return ret; 1977 return ret;
1976 } 1978 }
1977 1979
1978 base::TimeTicks TimeSource::Now() { 1980 base::TimeTicks TimeSource::Now() {
1979 return base::TimeTicks::Now(); 1981 return base::TimeTicks::Now();
1980 } 1982 }
1981 1983
1982 } // namespace sql 1984 } // namespace sql
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698