sql: Remove references to USE_SYSTEM_SQLITE.

USE_SYSTEM_SQLITE used to be supported on iOS, and now is a no-op.
This CL removes the references to it from //sql, to avoid confusing
readers.

The CL also breaks down an unnecessarily large unit test in
//sql/connection_unittest.cc that happend to be near the changes in this
CL.

Change-Id: I47c324300b54362529364a5ef26ee45b45fe3b76
Reviewed-on: https://chromium-review.googlesource.com/1137921
Reviewed-by: Chris Mumford <cmumford@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576213}
diff --git a/content/browser/dom_storage/dom_storage_database_unittest.cc b/content/browser/dom_storage/dom_storage_database_unittest.cc
index 5226a1a7..d3b199a 100644
--- a/content/browser/dom_storage/dom_storage_database_unittest.cc
+++ b/content/browser/dom_storage/dom_storage_database_unittest.cc
@@ -354,11 +354,6 @@
 
   {
     sql::test::ScopedErrorExpecter expecter;
-
-    // Old SQLite versions returned a different error code.
-    ASSERT_GE(expecter.SQLiteLibVersionNumber(), 3014000)
-        << "Chrome ships with SQLite 3.22.0+. The system SQLite version is "
-        << "only supported on iOS 10+, which ships with SQLite 3.14.0+";
     expecter.ExpectError(SQLITE_NOTADB);
 
     // Try and open the file. As it's not a database, we should end up deleting
diff --git a/sql/connection.cc b/sql/connection.cc
index 44ef8fd0..45dd021 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -38,11 +38,6 @@
 #include "sql/vfs_wrapper.h"
 #include "third_party/sqlite/sqlite3.h"
 
-#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
-#include "base/ios/ios_util.h"
-#include "third_party/sqlite/src/ext/icu/sqliteicu.h"
-#endif
-
 namespace {
 
 // Spin for up to a second waiting for the lock to clear when setting
@@ -830,13 +825,6 @@
 size_t Connection::GetAppropriateMmapSize() {
   AssertIOAllowed();
 
-#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
-  if (!base::ios::IsRunningOnIOS10OrLater()) {
-    // iOS SQLite does not support memory mapping.
-    return 0;
-  }
-#endif
-
   // How much to map if no errors are found.  50MB encompasses the 99th
   // percentile of Chrome databases in the wild, so this should be good.
   const size_t kMmapEverything = 256 * 1024 * 1024;
@@ -1712,13 +1700,6 @@
     }
   }
 
-#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
-  // The version of SQLite shipped with iOS doesn't enable ICU, which includes
-  // REGEXP support. Add it in dynamically.
-  err = sqlite3IcuInit(db_);
-  DCHECK_EQ(err, SQLITE_OK) << "Could not enable ICU support";
-#endif  // OS_IOS && USE_SYSTEM_SQLITE
-
   // If indicated, lock up the database before doing anything else, so
   // that the following code doesn't have to deal with locking.
   // TODO(shess): This code is brittle.  Find the cases where code
diff --git a/sql/connection.h b/sql/connection.h
index d45db948..57fc5453 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -396,9 +396,7 @@
   //
   // On the SQLite version shipped with Chrome (3.21+, Oct 2017), databases can
   // be attached while a transaction is opened. However, these databases cannot
-  // be detached until the transaction is committed or aborted. On iOS, the
-  // built-in SQLite might not be older than 3.21. In that case, attaching a
-  // database while a transaction is open results in a error.
+  // be detached until the transaction is committed or aborted.
   bool AttachDatabase(const base::FilePath& other_db_path,
                       const char* attachment_point);
   bool DetachDatabase(const char* attachment_point);
diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
index b79214fd..ec24cb4 100644
--- a/sql/connection_unittest.cc
+++ b/sql/connection_unittest.cc
@@ -307,30 +307,41 @@
   ASSERT_FALSE(db().IsSQLValid("SELECT no_exist FROM foo"));
 }
 
-TEST_F(SQLConnectionTest, DoesStuffExist) {
-  // Test DoesTableExist and DoesIndexExist.
+TEST_F(SQLConnectionTest, DoesTableExist) {
   EXPECT_FALSE(db().DoesTableExist("foo"));
-  ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
-  ASSERT_TRUE(db().Execute("CREATE INDEX foo_a ON foo (a)"));
-  EXPECT_FALSE(db().DoesIndexExist("foo"));
-  EXPECT_TRUE(db().DoesTableExist("foo"));
-  EXPECT_TRUE(db().DoesIndexExist("foo_a"));
-  EXPECT_FALSE(db().DoesTableExist("foo_a"));
+  EXPECT_FALSE(db().DoesTableExist("foo_index"));
 
-  // Test DoesViewExist.  The CREATE VIEW is an older form because some iOS
-  // versions use an earlier version of SQLite, and the difference isn't
-  // relevant for this test.
+  ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
+  ASSERT_TRUE(db().Execute("CREATE INDEX foo_index ON foo (a)"));
+  EXPECT_TRUE(db().DoesTableExist("foo"));
+  EXPECT_FALSE(db().DoesTableExist("foo_index"));
+}
+
+TEST_F(SQLConnectionTest, DoesIndexExist) {
+  ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
+  EXPECT_FALSE(db().DoesIndexExist("foo"));
+  EXPECT_FALSE(db().DoesIndexExist("foo_ubdex"));
+
+  ASSERT_TRUE(db().Execute("CREATE INDEX foo_index ON foo (a)"));
+  EXPECT_TRUE(db().DoesIndexExist("foo_index"));
+  EXPECT_FALSE(db().DoesIndexExist("foo"));
+}
+
+TEST_F(SQLConnectionTest, DoesViewExist) {
   EXPECT_FALSE(db().DoesViewExist("voo"));
-  ASSERT_TRUE(db().Execute("CREATE VIEW voo AS SELECT 1"));
+  ASSERT_TRUE(db().Execute("CREATE VIEW voo (a) AS SELECT 1"));
   EXPECT_FALSE(db().DoesIndexExist("voo"));
   EXPECT_FALSE(db().DoesTableExist("voo"));
   EXPECT_TRUE(db().DoesViewExist("voo"));
+}
 
-  // Test DoesColumnExist.
+TEST_F(SQLConnectionTest, DoesColumnExist) {
+  ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
+
   EXPECT_FALSE(db().DoesColumnExist("foo", "bar"));
   EXPECT_TRUE(db().DoesColumnExist("foo", "a"));
 
-  // Testing for a column on a nonexistent table.
+  ASSERT_FALSE(db().DoesTableExist("bar"));
   EXPECT_FALSE(db().DoesColumnExist("bar", "b"));
 
   // Names are not case sensitive.
@@ -661,11 +672,6 @@
   // statements that access the database.
   {
     sql::test::ScopedErrorExpecter expecter;
-
-    // Old SQLite versions returned a different error code.
-    ASSERT_GE(expecter.SQLiteLibVersionNumber(), 3014000)
-        << "Chrome ships with SQLite 3.22.0+. The system SQLite version is "
-        << "only supported on iOS 10+, which ships with SQLite 3.14.0+";
     expecter.ExpectError(SQLITE_NOTADB);
 
     EXPECT_TRUE(db().Open(db_path()));
diff --git a/sql/sqlite_features_unittest.cc b/sql/sqlite_features_unittest.cc
index 05d357a..778ca1a 100644
--- a/sql/sqlite_features_unittest.cc
+++ b/sql/sqlite_features_unittest.cc
@@ -188,10 +188,6 @@
   // disable mmap support.  Alternately, sqlite3_config() could be used.  In
   // that case, the pragma will run successfully, but the size will always be 0.
   //
-  // Historical note: The SQLite version bundled with iOS 9 and below does not
-  // have mmap support. Chrome now requires iOS 10 and above. This is only
-  // relevant when USE_SYSTEM_SQLITE is defined.
-  //
   // MojoVFS implements a no-op for xFileControl().  PRAGMA mmap_size is
   // implemented in terms of SQLITE_FCNTL_MMAP_SIZE.  In that case, the pragma
   // will succeed but with no effect.
@@ -214,10 +210,6 @@
   {
     sql::Statement s(db().GetUniqueStatement("PRAGMA mmap_size"));
 
-    // Historical note: The SQLite version bundled with iOS 9 and below does
-    // not have mmap support. Chrome now requires iOS 10 and above. This is
-    // only relevant when USE_SYSTEM_SQLITE is defined.
-
     ASSERT_TRUE(s.Step());
     ASSERT_GT(s.ColumnInt64(0), 0);
   }