OLD | NEW |
---|---|
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/message_loop/message_loop.h" |
23 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
24 #include "base/metrics/sparse_histogram.h" | 25 #include "base/metrics/sparse_histogram.h" |
26 #include "base/single_thread_task_runner.h" | |
25 #include "base/strings/string_split.h" | 27 #include "base/strings/string_split.h" |
26 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
27 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
28 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
29 #include "base/synchronization/lock.h" | 31 #include "base/synchronization/lock.h" |
32 #include "base/threading/thread_task_runner_handle.h" | |
30 #include "base/trace_event/memory_dump_manager.h" | 33 #include "base/trace_event/memory_dump_manager.h" |
31 #include "sql/connection_memory_dump_provider.h" | 34 #include "sql/connection_memory_dump_provider.h" |
32 #include "sql/meta_table.h" | 35 #include "sql/meta_table.h" |
33 #include "sql/statement.h" | 36 #include "sql/statement.h" |
34 #include "third_party/sqlite/sqlite3.h" | 37 #include "third_party/sqlite/sqlite3.h" |
35 | 38 |
36 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 39 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
37 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 40 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" |
38 #endif | 41 #endif |
39 | 42 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 base::LazyInstance<base::Lock>::Leaky | 156 base::LazyInstance<base::Lock>::Leaky |
154 g_sqlite_init_lock = LAZY_INSTANCE_INITIALIZER; | 157 g_sqlite_init_lock = LAZY_INSTANCE_INITIALIZER; |
155 void InitializeSqlite() { | 158 void InitializeSqlite() { |
156 base::AutoLock lock(g_sqlite_init_lock.Get()); | 159 base::AutoLock lock(g_sqlite_init_lock.Get()); |
157 static bool first_call = true; | 160 static bool first_call = true; |
158 if (first_call) { | 161 if (first_call) { |
159 sqlite3_initialize(); | 162 sqlite3_initialize(); |
160 | 163 |
161 // Schedule callback to record memory footprint histograms at 10m, 1h, and | 164 // Schedule callback to record memory footprint histograms at 10m, 1h, and |
162 // 1d. There may not be a message loop in tests. | 165 // 1d. There may not be a message loop in tests. |
163 if (base::MessageLoop::current()) { | 166 if (base::MessageLoop::current()) { |
Scott Hess - ex-Googler
2016/06/06 22:10:46
Is this test supported in the new world? It's pro
fdoray
2016/06/07 00:00:00
Done.
Other uses of "if (base::MessageLoop::curre
| |
164 base::MessageLoop::current()->PostDelayedTask( | 167 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
165 FROM_HERE, base::Bind(&RecordSqliteMemory10Min), | 168 FROM_HERE, base::Bind(&RecordSqliteMemory10Min), |
166 base::TimeDelta::FromMinutes(10)); | 169 base::TimeDelta::FromMinutes(10)); |
167 base::MessageLoop::current()->PostDelayedTask( | 170 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
168 FROM_HERE, base::Bind(&RecordSqliteMemoryHour), | 171 FROM_HERE, base::Bind(&RecordSqliteMemoryHour), |
169 base::TimeDelta::FromHours(1)); | 172 base::TimeDelta::FromHours(1)); |
170 base::MessageLoop::current()->PostDelayedTask( | 173 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
171 FROM_HERE, base::Bind(&RecordSqliteMemoryDay), | 174 FROM_HERE, base::Bind(&RecordSqliteMemoryDay), |
172 base::TimeDelta::FromDays(1)); | 175 base::TimeDelta::FromDays(1)); |
173 base::MessageLoop::current()->PostDelayedTask( | 176 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
174 FROM_HERE, base::Bind(&RecordSqliteMemoryWeek), | 177 FROM_HERE, base::Bind(&RecordSqliteMemoryWeek), |
175 base::TimeDelta::FromDays(7)); | 178 base::TimeDelta::FromDays(7)); |
176 } | 179 } |
177 | 180 |
178 first_call = false; | 181 first_call = false; |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
182 // Helper to get the sqlite3_file* associated with the "main" database. | 185 // Helper to get the sqlite3_file* associated with the "main" database. |
183 int GetSqlite3File(sqlite3* db, sqlite3_file** file) { | 186 int GetSqlite3File(sqlite3* db, sqlite3_file** file) { |
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1973 ignore_result(Execute(kNoWritableSchema)); | 1976 ignore_result(Execute(kNoWritableSchema)); |
1974 | 1977 |
1975 return ret; | 1978 return ret; |
1976 } | 1979 } |
1977 | 1980 |
1978 base::TimeTicks TimeSource::Now() { | 1981 base::TimeTicks TimeSource::Now() { |
1979 return base::TimeTicks::Now(); | 1982 return base::TimeTicks::Now(); |
1980 } | 1983 } |
1981 | 1984 |
1982 } // namespace sql | 1985 } // namespace sql |
OLD | NEW |