diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 02:00:53 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 02:00:53 +0000 |
commit | e2cadec89844f232f4b8887e85cfb72182d49107 (patch) | |
tree | b387565d11df7aabfbd4c8b30b780b620bf0f9cf /sql | |
parent | 91f10325d9835d204cbe88693f79221b3b402931 (diff) | |
download | chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.zip chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.tar.gz chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.tar.bz2 |
AppCache INTERCEPT namespace.
- Add support for a custom CHROMIUM CACHE MANIFEST signature. Other browsers should ignore files with this signature.
- Parse intercept namespace entries out of the new CHROMIUM-INTERCEPT manifest section. Other browsers should ignore this entire section.
- Store and retrieve the new kind of namespace records in the database layer.
- Upgrade existing databases to the new schema.
- Look for matches in the new namespaces when handling main and sub resource requests.
- Add unit tests.
BUG=101565
Review URL: http://codereview.chromium.org/8396013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql')
-rw-r--r-- | sql/connection.cc | 14 | ||||
-rw-r--r-- | sql/connection.h | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/sql/connection.cc b/sql/connection.cc index 26e71fd..38fd62a 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -283,12 +283,22 @@ bool Connection::IsSQLValid(const char* sql) { } bool Connection::DoesTableExist(const char* table_name) const { + return DoesTableOrIndexExist(table_name, "table"); +} + +bool Connection::DoesIndexExist(const char* index_name) const { + return DoesTableOrIndexExist(index_name, "index"); +} + +bool Connection::DoesTableOrIndexExist( + const char* name, const char* type) const { // GetUniqueStatement can't be const since statements may modify the // database, but we know ours doesn't modify it, so the cast is safe. Statement statement(const_cast<Connection*>(this)->GetUniqueStatement( "SELECT name FROM sqlite_master " - "WHERE type='table' AND name=?")); - statement.BindString(0, table_name); + "WHERE type=? AND name=?")); + statement.BindString(0, type); + statement.BindString(1, name); return statement.Step(); // Table exists if any row was returned. } diff --git a/sql/connection.h b/sql/connection.h index a2bfeef..39b999b 100644 --- a/sql/connection.h +++ b/sql/connection.h @@ -258,6 +258,9 @@ class SQL_EXPORT Connection { // Returns true if the given table exists. bool DoesTableExist(const char* table_name) const; + // Returns true if the given index exists. + bool DoesIndexExist(const char* index_name) const; + // Returns true if a column with the given name exists in the given table. bool DoesColumnExist(const char* table_name, const char* column_name) const; @@ -293,6 +296,9 @@ class SQL_EXPORT Connection { // sqlite3_open. The string can also be sqlite's special ":memory:" string. bool OpenInternal(const std::string& file_name); + // Internal helper for DoesTableExist and DoesIndexExist. + bool DoesTableOrIndexExist(const char* name, const char* type) const; + // A StatementRef is a refcounted wrapper around a sqlite statement pointer. // Refcounting allows us to give these statements out to sql::Statement // objects while also optionally maintaining a cache of compiled statements |