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> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
30 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" |
31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" |
33 #include "sql/connection_memory_dump_provider.h" | 33 #include "sql/connection_memory_dump_provider.h" |
34 #include "sql/meta_table.h" | 34 #include "sql/meta_table.h" |
35 #include "sql/statement.h" | 35 #include "sql/statement.h" |
36 #include "third_party/sqlite/sqlite3.h" | 36 #include "third_party/sqlite/sqlite3.h" |
37 | 37 |
38 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 38 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
| 39 #include "base/ios/ios_util.h" |
39 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 40 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" |
40 #endif | 41 #endif |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 // Spin for up to a second waiting for the lock to clear when setting | 45 // Spin for up to a second waiting for the lock to clear when setting |
45 // up the database. | 46 // up the database. |
46 // TODO(shess): Better story on this. http://crbug.com/56559 | 47 // TODO(shess): Better story on this. http://crbug.com/56559 |
47 const int kBusyTimeoutSeconds = 1; | 48 const int kBusyTimeoutSeconds = 1; |
48 | 49 |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 base::StringAppendF(&debug_info, "%s\n", messages[i].c_str()); | 851 base::StringAppendF(&debug_info, "%s\n", messages[i].c_str()); |
851 } | 852 } |
852 } | 853 } |
853 | 854 |
854 return debug_info; | 855 return debug_info; |
855 } | 856 } |
856 | 857 |
857 size_t Connection::GetAppropriateMmapSize() { | 858 size_t Connection::GetAppropriateMmapSize() { |
858 AssertIOAllowed(); | 859 AssertIOAllowed(); |
859 | 860 |
860 #if defined(OS_IOS) | 861 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
861 // iOS SQLite does not support memory mapping. | 862 if (!base::ios::IsRunningOnIOS10OrLater()) { |
862 return 0; | 863 // iOS SQLite does not support memory mapping. |
| 864 return 0; |
| 865 } |
863 #endif | 866 #endif |
864 | 867 |
865 // How much to map if no errors are found. 50MB encompasses the 99th | 868 // How much to map if no errors are found. 50MB encompasses the 99th |
866 // percentile of Chrome databases in the wild, so this should be good. | 869 // percentile of Chrome databases in the wild, so this should be good. |
867 const size_t kMmapEverything = 256 * 1024 * 1024; | 870 const size_t kMmapEverything = 256 * 1024 * 1024; |
868 | 871 |
869 // If the database doesn't have a place to track progress, assume the best. | 872 // If the database doesn't have a place to track progress, assume the best. |
870 // This will happen when new databases are created, or if a database doesn't | 873 // This will happen when new databases are created, or if a database doesn't |
871 // use a meta table. sql::MetaTable::Init() will preload kMmapSuccess. | 874 // use a meta table. sql::MetaTable::Init() will preload kMmapSuccess. |
872 // TODO(shess): Databases not using meta include: | 875 // TODO(shess): Databases not using meta include: |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 ignore_result(Execute(kNoWritableSchema)); | 1955 ignore_result(Execute(kNoWritableSchema)); |
1953 | 1956 |
1954 return ret; | 1957 return ret; |
1955 } | 1958 } |
1956 | 1959 |
1957 base::TimeTicks TimeSource::Now() { | 1960 base::TimeTicks TimeSource::Now() { |
1958 return base::TimeTicks::Now(); | 1961 return base::TimeTicks::Now(); |
1959 } | 1962 } |
1960 | 1963 |
1961 } // namespace sql | 1964 } // namespace sql |
OLD | NEW |