0

[sql] Enable HAVE_USLEEP for more platforms.

HAVE_USLEEP affects SQLite's sleep implementation, which is used when
SQLite waits for a lock to clear.  Browser databases are generally
uncontended, but this case could happen for WebDatabase in the renderer.

BUG=none

Review URL: https://codereview.chromium.org/827523004

Cr-Commit-Position: refs/heads/master@{#312460}
This commit is contained in:
shess
2015-01-21 13:52:24 -08:00
committed by Commit bot
parent 27bd482c7d
commit 156733dbbc
3 changed files with 36 additions and 2 deletions

@ -112,4 +112,21 @@ TEST_F(SQLiteFeaturesTest, FTS3_Prefix) {
}
#endif
#if !defined(USE_SYSTEM_SQLITE)
// Verify that Chromium's SQLite is compiled with HAVE_USLEEP defined. With
// HAVE_USLEEP, SQLite uses usleep() with millisecond granularity. Otherwise it
// uses sleep() with second granularity.
TEST_F(SQLiteFeaturesTest, UsesUsleep) {
base::TimeTicks before = base::TimeTicks::Now();
sqlite3_sleep(1);
base::TimeDelta delta = base::TimeTicks::Now() - before;
// It is not impossible for this to be over 1000 if things are compiled the
// right way. But it is very unlikely, most platforms seem to be around
// <TBD>.
LOG(ERROR) << "Milliseconds: " << delta.InMilliseconds();
EXPECT_LT(delta.InMilliseconds(), 1000);
}
#endif
} // namespace

@ -45,6 +45,15 @@ source_set("sqlite") {
"SQLITE_NO_SYNC",
]
}
if (is_posix) {
defines += [
# Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
# will have microsecond precision. Should only affect contended databases
# via the busy callback. Browser profile databases are mostly exclusive,
# but renderer databases may allow for contention.
"HAVE_USLEEP=1",
]
}
include_dirs = [
"amalgamation",
@ -69,7 +78,6 @@ source_set("sqlite") {
libs = [ "CoreFoundation.framework" ]
} else if (is_android) {
defines += [
"HAVE_USLEEP=1",
"SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
"SQLITE_DEFAULT_AUTOVACUUM=1",
"SQLITE_TEMP_STORE=3",

@ -33,6 +33,16 @@
],
},
],
['os_posix == 1', {
'defines': [
# Allow xSleep() call on Unix to use usleep() rather than sleep().
# Microsecond precision is better than second precision. Should
# only affect contended databases via the busy callback. Browser
# profile databases are mostly exclusive, but renderer databases may
# allow for contention.
'HAVE_USLEEP=1',
],
}],
['use_system_sqlite', {
'type': 'none',
'direct_dependent_settings': {
@ -132,7 +142,6 @@
}],
['OS == "android"', {
'defines': [
'HAVE_USLEEP=1',
'SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576',
'SQLITE_DEFAULT_AUTOVACUUM=1',
'SQLITE_TEMP_STORE=3',