diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-09-01 11:08:40 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-01 12:16:21 +0000 |
commit | 03c549e0392f92c02536d3f86d5e1d8dfa3435ac (patch) | |
tree | fe49d170a929b34ba82cd10db1a0bd8e3760fa4b /chromium/sql | |
parent | 5d013f5804a0d91fcf6c626b2d6fb6eca5c845b0 (diff) | |
download | qtwebengine-chromium-03c549e0392f92c02536d3f86d5e1d8dfa3435ac.tar.gz |
BASELINE: Update Chromium to 91.0.4472.160
Change-Id: I0def1f08a2412aeed79a9ab95dd50eb5c3f65f31
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/sql')
-rw-r--r-- | chromium/sql/OWNERS | 1 | ||||
-rw-r--r-- | chromium/sql/database.cc | 6 | ||||
-rw-r--r-- | chromium/sql/recovery.cc | 4 | ||||
-rw-r--r-- | chromium/sql/statement.cc | 37 | ||||
-rw-r--r-- | chromium/sql/statement.h | 31 |
5 files changed, 66 insertions, 13 deletions
diff --git a/chromium/sql/OWNERS b/chromium/sql/OWNERS index f1d3c71464f..0717bd0d40e 100644 --- a/chromium/sql/OWNERS +++ b/chromium/sql/OWNERS @@ -5,3 +5,4 @@ pwnall@chromium.org # Secondary: cmumford@google.com +mek@chromium.org diff --git a/chromium/sql/database.cc b/chromium/sql/database.cc index bb23163cca5..73fff33cd6e 100644 --- a/chromium/sql/database.cc +++ b/chromium/sql/database.cc @@ -9,6 +9,8 @@ #include <stdint.h> #include <string.h> +#include <memory> + #include "base/feature_list.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -1631,8 +1633,8 @@ bool Database::OpenInternal(const std::string& file_name, } DCHECK(!memory_dump_provider_); - memory_dump_provider_.reset( - new DatabaseMemoryDumpProvider(db_, histogram_tag_)); + memory_dump_provider_ = + std::make_unique<DatabaseMemoryDumpProvider>(db_, histogram_tag_); base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( memory_dump_provider_.get(), "sql::Database", nullptr); diff --git a/chromium/sql/recovery.cc b/chromium/sql/recovery.cc index 4e6d1519991..67d11163e46 100644 --- a/chromium/sql/recovery.cc +++ b/chromium/sql/recovery.cc @@ -151,7 +151,7 @@ std::unique_ptr<Recovery> Recovery::Begin(Database* database, // Warn about API mis-use. DCHECK(database->poisoned(InternalApiToken())) << "Illegal to recover with closed Database"; - return std::unique_ptr<Recovery>(); + return nullptr; } // Using `new` to access a non-public constructor @@ -159,7 +159,7 @@ std::unique_ptr<Recovery> Recovery::Begin(Database* database, if (!recovery->Init(db_path)) { // TODO(shess): Should Init() failure result in Raze()? recovery->Shutdown(POISON); - return std::unique_ptr<Recovery>(); + return nullptr; } return recovery; diff --git a/chromium/sql/statement.cc b/chromium/sql/statement.cc index c3a2a70be0e..87c2b120796 100644 --- a/chromium/sql/statement.cc +++ b/chromium/sql/statement.cc @@ -13,6 +13,7 @@ #include "base/strings/string_piece_forward.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/time/time.h" #include "build/build_config.h" // TODO(crbug.com/866218): Remove this include. #include "third_party/sqlite/sqlite3.h" @@ -182,6 +183,17 @@ bool Statement::BindDouble(int col, double val) { return is_valid() && CheckOk(sqlite3_bind_double(ref_->stmt(), col + 1, val)); } +bool Statement::BindTime(int col, base::Time val) { +#if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +#endif // OS_ANDROID + DCHECK(!stepped_); + + int64_t int_value = val.ToDeltaSinceWindowsEpoch().InMicroseconds(); + return is_valid() && + CheckOk(sqlite3_bind_int64(ref_->stmt(), col + 1, int_value)); +} + bool Statement::BindCString(int col, const char* val) { #if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); @@ -290,6 +302,19 @@ double Statement::ColumnDouble(int col) const { return sqlite3_column_double(ref_->stmt(), col); } +base::Time Statement::ColumnTime(int col) const { +#if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +#endif // OS_ANDROID + + if (!CheckValid()) + return base::Time(); + + int64_t int_value = sqlite3_column_int64(ref_->stmt(), col); + return base::Time::FromDeltaSinceWindowsEpoch( + base::TimeDelta::FromMicroseconds(int_value)); +} + std::string Statement::ColumnString(int col) const { #if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); @@ -308,16 +333,16 @@ std::string Statement::ColumnString(int col) const { return result; } -base::string16 Statement::ColumnString16(int col) const { +std::u16string Statement::ColumnString16(int col) const { #if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); #endif // OS_ANDROID if (!CheckValid()) - return base::string16(); + return std::u16string(); std::string s = ColumnString(col); - return !s.empty() ? base::UTF8ToUTF16(s) : base::string16(); + return !s.empty() ? base::UTF8ToUTF16(s) : std::u16string(); } int Statement::ColumnByteLength(int col) const { @@ -359,7 +384,7 @@ bool Statement::ColumnBlobAsString(int col, std::string* blob) const { return true; } -bool Statement::ColumnBlobAsString16(int col, base::string16* val) const { +bool Statement::ColumnBlobAsString16(int col, std::u16string* val) const { #if !defined(OS_ANDROID) // TODO(crbug.com/866218): Remove this conditional DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); #endif // OS_ANDROID @@ -368,11 +393,11 @@ bool Statement::ColumnBlobAsString16(int col, base::string16* val) const { return false; const void* data = ColumnBlob(col); - size_t len = ColumnByteLength(col) / sizeof(base::char16); + size_t len = ColumnByteLength(col) / sizeof(char16_t); val->resize(len); if (val->size() != len) return false; - val->assign(reinterpret_cast<const base::char16*>(data), len); + val->assign(reinterpret_cast<const char16_t*>(data), len); return true; } diff --git a/chromium/sql/statement.h b/chromium/sql/statement.h index 4ae259ba4f7..bc016930c12 100644 --- a/chromium/sql/statement.h +++ b/chromium/sql/statement.h @@ -14,8 +14,8 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/sequence_checker.h" -#include "base/strings/string16.h" #include "base/strings/string_piece_forward.h" +#include "base/time/time.h" #include "build/build_config.h" // TODO(crbug.com/866218): Remove this include. #include "sql/database.h" @@ -128,6 +128,20 @@ class COMPONENT_EXPORT(SQL) Statement { bool BindString16(int col, base::StringPiece16 value); bool BindBlob(int col, const void* value, int value_len); + // Conforms with base::Time serialization recommendations. + // + // This is equivalent to the following snippets, which should be replaced. + // * BindInt64(col, val.ToInternalValue()) + // * BindInt64(col, val.ToDeltaSinceWindowsEpoch().InMicroseconds()) + // + // Features that serialize base::Time in other ways, such as ToTimeT() or + // ToJavaTime(), will require a database migration to be converted to this + // (recommended) serialization method. + // + // TODO(crbug.com/1195962): Migrate all time serialization to this method, and + // then remove the migration details above. + bool BindTime(int col, base::Time time); + // Retrieving ---------------------------------------------------------------- // Returns the number of output columns in the result. @@ -147,7 +161,18 @@ class COMPONENT_EXPORT(SQL) Statement { int64_t ColumnInt64(int col) const; double ColumnDouble(int col) const; std::string ColumnString(int col) const; - base::string16 ColumnString16(int col) const; + std::u16string ColumnString16(int col) const; + + // Conforms with base::Time serialization recommendations. + // + // This is equivalent to the following snippets, which should be replaced. + // * base::Time::FromInternalValue(ColumnInt64(col)) + // * base::Time::FromDeltaSinceWindowsEpoch( + // base::TimeDelta::FromMicroseconds(ColumnInt64(col))) + // + // TODO(crbug.com/1195962): Migrate all time serialization to this method, and + // then remove the migration details above. + base::Time ColumnTime(int col) const; // When reading a blob, you can get a raw pointer to the underlying data, // along with the length, or you can just ask us to copy the blob into a @@ -155,7 +180,7 @@ class COMPONENT_EXPORT(SQL) Statement { int ColumnByteLength(int col) const; const void* ColumnBlob(int col) const; bool ColumnBlobAsString(int col, std::string* blob) const; - bool ColumnBlobAsString16(int col, base::string16* val) const; + bool ColumnBlobAsString16(int col, std::u16string* val) const; bool ColumnBlobAsVector(int col, std::vector<char>* val) const; bool ColumnBlobAsVector(int col, std::vector<unsigned char>* val) const; |