0

sql: Remove basictypes.h includes.

* Use the standard integer types from stdint.h instead.
* Use macros.h for the DISALLOW_COPY_AND_ASSIGN macro.

BUG=138542
TEST=sql_unittests
R=shess@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#329256}
This commit is contained in:
tfarina
2015-05-11 15:31:26 -07:00
committed by Commit bot
parent c16f8dcdc0
commit 720d4f346c
13 changed files with 27 additions and 26 deletions

@ -228,7 +228,7 @@ Connection::~Connection() {
bool Connection::Open(const base::FilePath& path) {
if (!histogram_tag_.empty()) {
int64 size_64 = 0;
int64_t size_64 = 0;
if (base::GetFileSize(path, &size_64)) {
size_t sample = static_cast<size_t>(size_64 / 1024);
std::string full_histogram_name = "Sqlite.SizeKB." + histogram_tag_;
@ -835,7 +835,7 @@ bool Connection::DoesColumnExist(const char* table_name,
return false;
}
int64 Connection::GetLastInsertRowId() const {
int64_t Connection::GetLastInsertRowId() const {
if (!db_) {
DLOG_IF(FATAL, !poisoned_) << "Illegal use of connection without a db";
return 0;

@ -5,14 +5,15 @@
#ifndef SQL_CONNECTION_H_
#define SQL_CONNECTION_H_
#include <stdint.h>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_restrictions.h"
@ -372,7 +373,7 @@ class SQL_EXPORT Connection {
// Returns sqlite's internal ID for the last inserted row. Valid only
// immediately after an insert.
int64 GetLastInsertRowId() const;
int64_t GetLastInsertRowId() const;
// Returns sqlite's count of the number of rows modified by the last
// statement executed. Will be 0 if no statement has executed or the database

@ -198,7 +198,7 @@ TEST_F(SQLConnectionTest, GetLastInsertRowId) {
ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)"));
// Last insert row ID should be valid.
int64 row = db().GetLastInsertRowId();
int64_t row = db().GetLastInsertRowId();
EXPECT_LT(0, row);
// It should be the primary key of the row we just inserted.

@ -180,7 +180,7 @@ bool MetaTable::SetValue(const char* key, int value) {
return s.Run();
}
bool MetaTable::SetValue(const char* key, int64 value) {
bool MetaTable::SetValue(const char* key, int64_t value) {
Statement s;
PrepareSetStatement(&s, key);
s.BindInt64(1, value);
@ -205,7 +205,7 @@ bool MetaTable::GetValue(const char* key, int* value) {
return true;
}
bool MetaTable::GetValue(const char* key, int64* value) {
bool MetaTable::GetValue(const char* key, int64_t* value) {
Statement s;
if (!PrepareGetStatement(&s, key))
return false;

@ -5,9 +5,10 @@
#ifndef SQL_META_TABLE_H_
#define SQL_META_TABLE_H_
#include <stdint.h>
#include <string>
#include "base/basictypes.h"
#include "base/macros.h"
#include "sql/sql_export.h"
namespace sql {
@ -74,13 +75,13 @@ class SQL_EXPORT MetaTable {
// Set the given arbitrary key with the given data. Returns true on success.
bool SetValue(const char* key, const std::string& value);
bool SetValue(const char* key, int value);
bool SetValue(const char* key, int64 value);
bool SetValue(const char* key, int64_t value);
// Retrieves the value associated with the given key. This will use sqlite's
// type conversion rules. It will return true on success.
bool GetValue(const char* key, std::string* value);
bool GetValue(const char* key, int* value);
bool GetValue(const char* key, int64* value);
bool GetValue(const char* key, int64_t* value);
// Deletes the key from the table.
bool DeleteKey(const char* key);

@ -208,15 +208,15 @@ TEST_F(SQLMetaTableTest, IntValue) {
TEST_F(SQLMetaTableTest, Int64Value) {
const char kKey[] = "Int Key";
const int64 kFirstValue = 5000000017LL;
const int64 kSecondValue = 5000000023LL;
const int64_t kFirstValue = 5000000017LL;
const int64_t kSecondValue = 5000000023LL;
// Initially, the value isn't there until set.
{
sql::MetaTable meta_table;
EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
int64 value;
int64_t value;
EXPECT_FALSE(meta_table.GetValue(kKey, &value));
EXPECT_TRUE(meta_table.SetValue(kKey, kFirstValue));
@ -229,7 +229,7 @@ TEST_F(SQLMetaTableTest, Int64Value) {
sql::MetaTable meta_table;
EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
int64 value;
int64_t value;
EXPECT_TRUE(meta_table.GetValue(kKey, &value));
EXPECT_EQ(kFirstValue, value);
@ -241,7 +241,7 @@ TEST_F(SQLMetaTableTest, Int64Value) {
sql::MetaTable meta_table;
EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
int64 value;
int64_t value;
EXPECT_TRUE(meta_table.GetValue(kKey, &value));
EXPECT_EQ(kSecondValue, value);
}

@ -5,8 +5,7 @@
#ifndef SQL_RECOVERY_H_
#define SQL_RECOVERY_H_
#include "base/basictypes.h"
#include "base/macros.h"
#include "sql/connection.h"
namespace base {

@ -112,7 +112,7 @@ bool Statement::BindInt(int col, int val) {
return CheckOk(sqlite3_bind_int(ref_->stmt(), col + 1, val));
}
bool Statement::BindInt64(int col, int64 val) {
bool Statement::BindInt64(int col, int64_t val) {
DCHECK(!stepped_);
if (!is_valid())
return false;
@ -207,7 +207,7 @@ int Statement::ColumnInt(int col) const {
return sqlite3_column_int(ref_->stmt(), col);
}
int64 Statement::ColumnInt64(int col) const {
int64_t Statement::ColumnInt64(int col) const {
if (!CheckValid())
return 0;

@ -5,10 +5,11 @@
#ifndef SQL_STATEMENT_H_
#define SQL_STATEMENT_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "sql/connection.h"
@ -104,7 +105,7 @@ class SQL_EXPORT Statement {
bool BindNull(int col);
bool BindBool(int col, bool val);
bool BindInt(int col, int val);
bool BindInt64(int col, int64 val);
bool BindInt64(int col, int64_t val);
bool BindDouble(int col, double val);
bool BindCString(int col, const char* val);
bool BindString(int col, const std::string& val);
@ -128,7 +129,7 @@ class SQL_EXPORT Statement {
// These all take a 0-based argument index.
bool ColumnBool(int col) const;
int ColumnInt(int col) const;
int64 ColumnInt64(int col) const;
int64_t ColumnInt64(int col) const;
double ColumnDouble(int col) const;
std::string ColumnString(int col) const;
base::string16 ColumnString16(int col) const;

@ -7,7 +7,7 @@
#include <set>
#include "base/basictypes.h"
#include "base/macros.h"
#include "sql/connection.h"
// This is not strictly necessary for the operation of ScopedErrorIgnorer, but

@ -85,7 +85,7 @@ bool CorruptSizeInHeader(const base::FilePath& db_path) {
if (1u != fread(header, sizeof(header), 1, file.get()))
return false;
int64 db_size = 0;
int64_t db_size = 0;
if (!base::GetFileSize(db_path, &db_size))
return false;

@ -7,7 +7,6 @@
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"

@ -5,7 +5,7 @@
#ifndef SQL_TRANSACTION_H_
#define SQL_TRANSACTION_H_
#include "base/basictypes.h"
#include "base/macros.h"
#include "sql/sql_export.h"
namespace sql {