summaryrefslogtreecommitdiff
path: root/chromium/sql
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/sql
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/sql')
-rw-r--r--chromium/sql/BUILD.gn26
-rw-r--r--chromium/sql/connection.cc29
-rw-r--r--chromium/sql/connection.h11
-rw-r--r--chromium/sql/connection_unittest.cc8
-rw-r--r--chromium/sql/recovery.cc17
-rw-r--r--chromium/sql/recovery.h16
-rw-r--r--chromium/sql/recovery_unittest.cc58
7 files changed, 76 insertions, 89 deletions
diff --git a/chromium/sql/BUILD.gn b/chromium/sql/BUILD.gn
index b2ca63849f9..fb1bd2f4709 100644
--- a/chromium/sql/BUILD.gn
+++ b/chromium/sql/BUILD.gn
@@ -72,7 +72,7 @@ source_set("redirection_header") {
bundle_data("sql_unittests_bundle_data") {
testonly = true
sources = [
- "test/data",
+ "test/data/recovery_387868",
]
outputs = [
"{{bundle_resources_dir}}/" +
@@ -114,28 +114,4 @@ test("sql_unittests") {
"//testing/gtest",
"//third_party/sqlite",
]
-
- if (is_android) {
- isolate_file = "sql_unittests.isolate"
- }
-
- # TODO(GYP)
- #['OS == "android"', {
- # 'dependencies': [
- # '../testing/android/native_test.gyp:native_test_native_code',
- # ],
- #}],
-}
-
-if (is_android) {
- #TODO(GYP)
- #'target_name': 'sql_unittests_apk',
- #'type': 'none',
- #'dependencies': [
- # 'sql_unittests',
- #],
- #'variables': {
- # 'test_suite_name': 'sql_unittests',
- #},
- #'includes': [ '../build/apk_test.gypi' ],
}
diff --git a/chromium/sql/connection.cc b/chromium/sql/connection.cc
index 7787adfe283..f4da99ef76b 100644
--- a/chromium/sql/connection.cc
+++ b/chromium/sql/connection.cc
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
+
#include <utility>
#include "base/bind.h"
@@ -43,8 +44,6 @@ namespace {
// TODO(shess): Better story on this. http://crbug.com/56559
const int kBusyTimeoutSeconds = 1;
-bool g_mmap_disabled_default = false;
-
class ScopedBusyTimeout {
public:
explicit ScopedBusyTimeout(sqlite3* db)
@@ -115,9 +114,8 @@ int BackupDatabase(sqlite3* src, sqlite3* dst, const char* db_name) {
// just use clean names to start with.
bool ValidAttachmentPoint(const char* attachment_point) {
for (size_t i = 0; attachment_point[i]; ++i) {
- if (!((attachment_point[i] >= '0' && attachment_point[i] <= '9') ||
- (attachment_point[i] >= 'a' && attachment_point[i] <= 'z') ||
- (attachment_point[i] >= 'A' && attachment_point[i] <= 'Z') ||
+ if (!(base::IsAsciiDigit(attachment_point[i]) ||
+ base::IsAsciiAlpha(attachment_point[i]) ||
attachment_point[i] == '_')) {
return false;
}
@@ -256,12 +254,6 @@ bool Connection::ShouldIgnoreSqliteCompileError(int error) {
basic_error == SQLITE_CORRUPT;
}
-// static
-void Connection::set_mmap_disabled_by_default() {
- g_mmap_disabled_default = true;
-}
-
-
void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) {
AssertIOAllowed();
@@ -355,7 +347,7 @@ Connection::Connection()
needs_rollback_(false),
in_memory_(false),
poisoned_(false),
- mmap_disabled_(g_mmap_disabled_default),
+ mmap_disabled_(false),
mmap_enabled_(false),
total_changes_at_last_release_(0),
stats_histogram_(NULL),
@@ -542,7 +534,7 @@ void Connection::Preload() {
if (preload_size > file_size)
preload_size = file_size;
- scoped_ptr<char[]> buf(new char[page_size]);
+ std::unique_ptr<char[]> buf(new char[page_size]);
for (sqlite3_int64 pos = 0; pos < preload_size; pos += page_size) {
rc = file->pMethods->xRead(file, buf.get(), page_size, pos);
@@ -679,12 +671,13 @@ bool Connection::RegisterIntentToUpload() const {
// already bad.
base::AutoLock lock(g_sqlite_init_lock.Get());
- scoped_ptr<base::Value> root;
+ std::unique_ptr<base::Value> root;
if (!base::PathExists(breadcrumb_path)) {
- scoped_ptr<base::DictionaryValue> root_dict(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> root_dict(
+ new base::DictionaryValue());
root_dict->SetInteger(kVersionKey, kVersion);
- scoped_ptr<base::ListValue> dumps(new base::ListValue);
+ std::unique_ptr<base::ListValue> dumps(new base::ListValue);
dumps->AppendString(histogram_tag_);
root_dict->Set(kDiagnosticDumpsKey, std::move(dumps));
@@ -693,11 +686,11 @@ bool Connection::RegisterIntentToUpload() const {
// Failure to read a valid dictionary implies that something is going wrong
// on the system.
JSONFileValueDeserializer deserializer(breadcrumb_path);
- scoped_ptr<base::Value> read_root(
+ std::unique_ptr<base::Value> read_root(
deserializer.Deserialize(nullptr, nullptr));
if (!read_root.get())
return false;
- scoped_ptr<base::DictionaryValue> root_dict =
+ std::unique_ptr<base::DictionaryValue> root_dict =
base::DictionaryValue::From(std::move(read_root));
if (!root_dict)
return false;
diff --git a/chromium/sql/connection.h b/chromium/sql/connection.h
index 4606a1f357c..8e8931f2e67 100644
--- a/chromium/sql/connection.h
+++ b/chromium/sql/connection.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -17,7 +18,6 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "sql/sql_export.h"
@@ -149,12 +149,9 @@ class SQL_EXPORT Connection {
// other platforms.
void set_restrict_to_user() { restrict_to_user_ = true; }
- // Call to opt out of memory-mapped file I/O on per connection basis.
+ // Call to opt out of memory-mapped file I/O.
void set_mmap_disabled() { mmap_disabled_ = true; }
- // Call to opt out of memory-mapped file I/O on all connections.
- static void set_mmap_disabled_by_default();
-
// Set an error-handling callback. On errors, the error number (and
// statement, if available) will be passed to the callback.
//
@@ -792,10 +789,10 @@ class SQL_EXPORT Connection {
// Source for timing information, provided to allow tests to inject time
// changes.
- scoped_ptr<TimeSource> clock_;
+ std::unique_ptr<TimeSource> clock_;
// Stores the dump provider object when db is open.
- scoped_ptr<ConnectionMemoryDumpProvider> memory_dump_provider_;
+ std::unique_ptr<ConnectionMemoryDumpProvider> memory_dump_provider_;
DISALLOW_COPY_AND_ASSIGN(Connection);
};
diff --git a/chromium/sql/connection_unittest.cc b/chromium/sql/connection_unittest.cc
index d9dd9d9f460..1c08881227d 100644
--- a/chromium/sql/connection_unittest.cc
+++ b/chromium/sql/connection_unittest.cc
@@ -71,7 +71,7 @@ class ScopedMockTimeSource {
Connection& db_;
// Saves original source from |db_|.
- scoped_ptr<TimeSource> save_;
+ std::unique_ptr<TimeSource> save_;
// Current time returned by mock.
base::TimeTicks current_time_;
@@ -1208,7 +1208,7 @@ TEST_F(SQLConnectionTest, TimeQuery) {
EXPECT_TRUE(db().Execute("SELECT milliadjust(10)"));
- scoped_ptr<base::HistogramSamples> samples(
+ std::unique_ptr<base::HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(kQueryTime));
ASSERT_TRUE(samples);
// 10 for the adjust, 1 for the measurement.
@@ -1246,7 +1246,7 @@ TEST_F(SQLConnectionTest, TimeUpdateAutocommit) {
EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (10, milliadjust(10))"));
- scoped_ptr<base::HistogramSamples> samples(
+ std::unique_ptr<base::HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(kQueryTime));
ASSERT_TRUE(samples);
// 10 for the adjust, 1 for the measurement.
@@ -1298,7 +1298,7 @@ TEST_F(SQLConnectionTest, TimeUpdateTransaction) {
EXPECT_TRUE(db().CommitTransaction());
}
- scoped_ptr<base::HistogramSamples> samples(
+ std::unique_ptr<base::HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(kQueryTime));
ASSERT_TRUE(samples);
// 10 for insert adjust, 10 for update adjust, 100 for commit adjust, 1 for
diff --git a/chromium/sql/recovery.cc b/chromium/sql/recovery.cc
index 7b9ca9f6fee..92c7f875e15 100644
--- a/chromium/sql/recovery.cc
+++ b/chromium/sql/recovery.cc
@@ -102,9 +102,8 @@ bool Recovery::FullRecoverySupported() {
}
// static
-scoped_ptr<Recovery> Recovery::Begin(
- Connection* connection,
- const base::FilePath& db_path) {
+std::unique_ptr<Recovery> Recovery::Begin(Connection* connection,
+ const base::FilePath& db_path) {
// Recovery is likely to be used in error handling. Since recovery changes
// the state of the handle, protect against multiple layers attempting the
// same recovery.
@@ -112,32 +111,32 @@ scoped_ptr<Recovery> Recovery::Begin(
// Warn about API mis-use.
DLOG_IF(FATAL, !connection->poisoned_)
<< "Illegal to recover with closed database";
- return scoped_ptr<Recovery>();
+ return std::unique_ptr<Recovery>();
}
- scoped_ptr<Recovery> r(new Recovery(connection));
+ std::unique_ptr<Recovery> r(new Recovery(connection));
if (!r->Init(db_path)) {
// TODO(shess): Should Init() failure result in Raze()?
r->Shutdown(POISON);
- return scoped_ptr<Recovery>();
+ return std::unique_ptr<Recovery>();
}
return r;
}
// static
-bool Recovery::Recovered(scoped_ptr<Recovery> r) {
+bool Recovery::Recovered(std::unique_ptr<Recovery> r) {
return r->Backup();
}
// static
-void Recovery::Unrecoverable(scoped_ptr<Recovery> r) {
+void Recovery::Unrecoverable(std::unique_ptr<Recovery> r) {
CHECK(r->db_);
// ~Recovery() will RAZE_AND_POISON.
}
// static
-void Recovery::Rollback(scoped_ptr<Recovery> r) {
+void Recovery::Rollback(std::unique_ptr<Recovery> r) {
// TODO(shess): HISTOGRAM to track? Or just have people crash out?
// Crash and dump?
r->Shutdown(POISON);
diff --git a/chromium/sql/recovery.h b/chromium/sql/recovery.h
index af991081929..8efd7187731 100644
--- a/chromium/sql/recovery.h
+++ b/chromium/sql/recovery.h
@@ -7,6 +7,8 @@
#include <stddef.h>
+#include <memory>
+
#include "base/macros.h"
#include "sql/connection.h"
@@ -25,7 +27,7 @@ namespace sql {
// not accidentally disrupt the restored data.
//
// {
-// scoped_ptr<sql::Recovery> r =
+// std::unique_ptr<sql::Recovery> r =
// sql::Recovery::Begin(orig_db, orig_db_path);
// if (r) {
// // Create the schema to recover to. On failure, clear the
@@ -80,9 +82,9 @@ class SQL_EXPORT Recovery {
// TODO(shess): Later versions of SQLite allow extracting the path
// from the connection.
// TODO(shess): Allow specifying the connection point?
- static scoped_ptr<Recovery> Begin(
- Connection* connection,
- const base::FilePath& db_path) WARN_UNUSED_RESULT;
+ static std::unique_ptr<Recovery> Begin(Connection* connection,
+ const base::FilePath& db_path)
+ WARN_UNUSED_RESULT;
// Mark recovery completed by replicating the recovery database over
// the original database, then closing the recovery database. The
@@ -95,11 +97,11 @@ class SQL_EXPORT Recovery {
// TODO(shess): At this time, this function can fail while leaving
// the original database intact. Figure out which failure cases
// should go to RazeAndClose() instead.
- static bool Recovered(scoped_ptr<Recovery> r) WARN_UNUSED_RESULT;
+ static bool Recovered(std::unique_ptr<Recovery> r) WARN_UNUSED_RESULT;
// Indicate that the database is unrecoverable. The original
// database is razed, and the handle poisoned.
- static void Unrecoverable(scoped_ptr<Recovery> r);
+ static void Unrecoverable(std::unique_ptr<Recovery> r);
// When initially developing recovery code, sometimes the possible
// database states are not well-understood without further
@@ -107,7 +109,7 @@ class SQL_EXPORT Recovery {
// database.
// NOTE(shess): Only call this when adding recovery support. In the
// steady state, all databases should progress to recovered or razed.
- static void Rollback(scoped_ptr<Recovery> r);
+ static void Rollback(std::unique_ptr<Recovery> r);
// Handle to the temporary recovery database.
sql::Connection* db() { return &recover_db_; }
diff --git a/chromium/sql/recovery_unittest.cc b/chromium/sql/recovery_unittest.cc
index d3b04b1eb90..b215777560d 100644
--- a/chromium/sql/recovery_unittest.cc
+++ b/chromium/sql/recovery_unittest.cc
@@ -5,6 +5,8 @@
#include "sql/recovery.h"
#include <stddef.h>
+
+#include <memory>
#include <string>
#include <utility>
@@ -80,7 +82,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// If the Recovery handle goes out of scope without being
// Recovered(), the database is razed.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
}
EXPECT_FALSE(db().is_open());
@@ -95,7 +98,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Unrecoverable() also razes.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
sql::Recovery::Unrecoverable(std::move(recovery));
@@ -108,7 +112,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Attempting to recover a previously-recovered handle fails early.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
recovery.reset();
@@ -128,7 +133,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Recovered() replaces the original with the "recovered" version.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// Create the new version of the table.
@@ -155,7 +161,8 @@ TEST_F(SQLRecoveryTest, RecoverBasic) {
// Rollback() discards recovery progress and leaves the database as it was.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
@@ -181,7 +188,8 @@ TEST_F(SQLRecoveryTest, VirtualTable) {
// Successfully recover the database.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
// Tables to recover original DB, now at [corrupt].
const char kRecoveryCreateSql[] =
@@ -221,7 +229,7 @@ void RecoveryCallback(sql::Connection* db, const base::FilePath& db_path,
// Clear the error callback to prevent reentrancy.
db->reset_error_callback();
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path);
+ std::unique_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path);
ASSERT_TRUE(recovery.get());
ASSERT_TRUE(recovery->db()->Execute(create_table));
@@ -386,7 +394,8 @@ TEST_F(SQLRecoveryTest, Meta) {
// Test expected case where everything works.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_TRUE(recovery->SetupMeta());
int version = 0;
EXPECT_TRUE(recovery->GetMetaVersionNumber(&version));
@@ -399,7 +408,8 @@ TEST_F(SQLRecoveryTest, Meta) {
// Test version row missing.
EXPECT_TRUE(db().Execute("DELETE FROM meta WHERE key = 'version'"));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_TRUE(recovery->SetupMeta());
int version = 0;
EXPECT_FALSE(recovery->GetMetaVersionNumber(&version));
@@ -414,7 +424,8 @@ TEST_F(SQLRecoveryTest, Meta) {
{
sql::ScopedErrorIgnorer ignore_errors;
ignore_errors.IgnoreError(SQLITE_CORRUPT); // From virtual table.
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
EXPECT_FALSE(recovery->SetupMeta());
ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
}
@@ -439,7 +450,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTable) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
// Save a copy of the temp db's schema before recovering the table.
@@ -466,7 +478,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTable) {
// Recovery fails if the target table doesn't exist.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
// TODO(shess): Should this failure implicitly lead to Raze()?
@@ -523,7 +536,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithDefault) {
}
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
// Different default to detect which table provides the default.
ASSERT_TRUE(recovery->db()->Execute(final_schema.c_str()));
@@ -560,7 +574,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableNullFilter) {
ASSERT_NE(kOrigSchema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kFinalSchema));
size_t rows = 0;
@@ -599,7 +614,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithRowid) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
size_t rows = 0;
@@ -644,7 +660,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableWithCompoundKey) {
ASSERT_NE(orig_schema, GetSchema(&db()));
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
size_t rows = 0;
@@ -690,7 +707,8 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableMissingColumns) {
// Recover the previous version of the table into the altered version.
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
ASSERT_TRUE(recovery->db()->Execute(kAlterSql));
size_t rows = 0;
@@ -718,7 +736,8 @@ TEST_F(SQLRecoveryTest, Bug387868) {
ASSERT_TRUE(Reopen());
{
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// Create the new version of the table.
@@ -738,7 +757,8 @@ TEST_F(SQLRecoveryTest, Bug387868) {
// Memory-mapped I/O interacts poorly with I/O errors. Make sure the recovery
// database doesn't accidentally enable it.
TEST_F(SQLRecoveryTest, NoMmap) {
- scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ std::unique_ptr<sql::Recovery> recovery =
+ sql::Recovery::Begin(&db(), db_path());
ASSERT_TRUE(recovery.get());
// In the current implementation, the PRAGMA successfully runs with no result