| 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 "content/browser/appcache/appcache_database.h" | 5 #include "content/browser/appcache/appcache_database.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 else | 170 else |
| 171 sql += "CREATE INDEX "; | 171 sql += "CREATE INDEX "; |
| 172 sql += info.index_name; | 172 sql += info.index_name; |
| 173 sql += " ON "; | 173 sql += " ON "; |
| 174 sql += info.table_name; | 174 sql += info.table_name; |
| 175 sql += info.columns; | 175 sql += info.columns; |
| 176 return db->Execute(sql.c_str()); | 176 return db->Execute(sql.c_str()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 std::string GetActiveExperimentFlags() { | 179 std::string GetActiveExperimentFlags() { |
| 180 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableExecutableHandlers)) | 180 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 181 kEnableExecutableHandlers)) |
| 181 return std::string("executableHandlersEnabled"); | 182 return std::string("executableHandlersEnabled"); |
| 182 return std::string(); | 183 return std::string(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 } // anon namespace | 186 } // anon namespace |
| 186 | 187 |
| 187 // AppCacheDatabase ---------------------------------------------------------- | 188 // AppCacheDatabase ---------------------------------------------------------- |
| 188 | 189 |
| 189 AppCacheDatabase::GroupRecord::GroupRecord() | 190 AppCacheDatabase::GroupRecord::GroupRecord() |
| 190 : group_id(0) { | 191 : group_id(0) { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 const char* kSql = | 706 const char* kSql = |
| 706 "INSERT INTO Namespaces" | 707 "INSERT INTO Namespaces" |
| 707 " (cache_id, origin, type, namespace_url, target_url, is_pattern)" | 708 " (cache_id, origin, type, namespace_url, target_url, is_pattern)" |
| 708 " VALUES (?, ?, ?, ?, ?, ?)"; | 709 " VALUES (?, ?, ?, ?, ?, ?)"; |
| 709 | 710 |
| 710 // Note: quick and dirty storage for the 'executable' bit w/o changing | 711 // Note: quick and dirty storage for the 'executable' bit w/o changing |
| 711 // schemas, we use the high bit of 'type' field. | 712 // schemas, we use the high bit of 'type' field. |
| 712 int type_with_executable_bit = record->namespace_.type; | 713 int type_with_executable_bit = record->namespace_.type; |
| 713 if (record->namespace_.is_executable) { | 714 if (record->namespace_.is_executable) { |
| 714 type_with_executable_bit |= 0x8000000; | 715 type_with_executable_bit |= 0x8000000; |
| 715 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 716 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 716 kEnableExecutableHandlers)); | 717 kEnableExecutableHandlers)); |
| 717 } | 718 } |
| 718 | 719 |
| 719 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 720 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
| 720 statement.BindInt64(0, record->cache_id); | 721 statement.BindInt64(0, record->cache_id); |
| 721 statement.BindString(1, record->origin.spec()); | 722 statement.BindString(1, record->origin.spec()); |
| 722 statement.BindInt(2, type_with_executable_bit); | 723 statement.BindInt(2, type_with_executable_bit); |
| 723 statement.BindString(3, record->namespace_.namespace_url.spec()); | 724 statement.BindString(3, record->namespace_.namespace_url.spec()); |
| 724 statement.BindString(4, record->namespace_.target_url.spec()); | 725 statement.BindString(4, record->namespace_.target_url.spec()); |
| 725 statement.BindBool(5, record->namespace_.is_pattern); | 726 statement.BindBool(5, record->namespace_.is_pattern); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 record->namespace_.target_url = GURL(statement->ColumnString(4)); | 970 record->namespace_.target_url = GURL(statement->ColumnString(4)); |
| 970 record->namespace_.is_pattern = statement->ColumnBool(5); | 971 record->namespace_.is_pattern = statement->ColumnBool(5); |
| 971 | 972 |
| 972 // Note: quick and dirty storage for the 'executable' bit w/o changing | 973 // Note: quick and dirty storage for the 'executable' bit w/o changing |
| 973 // schemas, we use the high bit of 'type' field. | 974 // schemas, we use the high bit of 'type' field. |
| 974 record->namespace_.type = static_cast<AppCacheNamespaceType> | 975 record->namespace_.type = static_cast<AppCacheNamespaceType> |
| 975 (type_with_executable_bit & 0x7ffffff); | 976 (type_with_executable_bit & 0x7ffffff); |
| 976 record->namespace_.is_executable = | 977 record->namespace_.is_executable = |
| 977 (type_with_executable_bit & 0x80000000) != 0; | 978 (type_with_executable_bit & 0x80000000) != 0; |
| 978 DCHECK(!record->namespace_.is_executable || | 979 DCHECK(!record->namespace_.is_executable || |
| 979 CommandLine::ForCurrentProcess()->HasSwitch(kEnableExecutableHandlers)); | 980 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 981 kEnableExecutableHandlers)); |
| 980 } | 982 } |
| 981 | 983 |
| 982 void AppCacheDatabase::ReadOnlineWhiteListRecord( | 984 void AppCacheDatabase::ReadOnlineWhiteListRecord( |
| 983 const sql::Statement& statement, OnlineWhiteListRecord* record) { | 985 const sql::Statement& statement, OnlineWhiteListRecord* record) { |
| 984 record->cache_id = statement.ColumnInt64(0); | 986 record->cache_id = statement.ColumnInt64(0); |
| 985 record->namespace_url = GURL(statement.ColumnString(1)); | 987 record->namespace_url = GURL(statement.ColumnString(1)); |
| 986 record->is_pattern = statement.ColumnBool(2); | 988 record->is_pattern = statement.ColumnBool(2); |
| 987 } | 989 } |
| 988 | 990 |
| 989 bool AppCacheDatabase::LazyOpen(bool create_if_needed) { | 991 bool AppCacheDatabase::LazyOpen(bool create_if_needed) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1219 } |
| 1218 | 1220 |
| 1219 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { | 1221 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { |
| 1220 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); | 1222 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); |
| 1221 if (!db_->ShouldIgnoreSqliteError(err)) | 1223 if (!db_->ShouldIgnoreSqliteError(err)) |
| 1222 DLOG(ERROR) << db_->GetErrorMessage(); | 1224 DLOG(ERROR) << db_->GetErrorMessage(); |
| 1223 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? | 1225 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? |
| 1224 } | 1226 } |
| 1225 | 1227 |
| 1226 } // namespace content | 1228 } // namespace content |
| OLD | NEW |