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 "webkit/browser/appcache/appcache_database.h" | 5 #include "webkit/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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 record->flags = statement.ColumnInt(2); | 944 record->flags = statement.ColumnInt(2); |
945 record->response_id = statement.ColumnInt64(3); | 945 record->response_id = statement.ColumnInt64(3); |
946 record->response_size = statement.ColumnInt64(4); | 946 record->response_size = statement.ColumnInt64(4); |
947 } | 947 } |
948 | 948 |
949 void AppCacheDatabase::ReadNamespaceRecords( | 949 void AppCacheDatabase::ReadNamespaceRecords( |
950 sql::Statement* statement, | 950 sql::Statement* statement, |
951 NamespaceRecordVector* intercepts, | 951 NamespaceRecordVector* intercepts, |
952 NamespaceRecordVector* fallbacks) { | 952 NamespaceRecordVector* fallbacks) { |
953 while (statement->Step()) { | 953 while (statement->Step()) { |
954 NamespaceType type = static_cast<NamespaceType>(statement->ColumnInt(2)); | 954 AppCacheNamespaceType type = static_cast<AppCacheNamespaceType>( |
| 955 statement->ColumnInt(2)); |
955 NamespaceRecordVector* records = | 956 NamespaceRecordVector* records = |
956 (type == FALLBACK_NAMESPACE) ? fallbacks : intercepts; | 957 (type == FALLBACK_NAMESPACE) ? fallbacks : intercepts; |
957 records->push_back(NamespaceRecord()); | 958 records->push_back(NamespaceRecord()); |
958 ReadNamespaceRecord(statement, &records->back()); | 959 ReadNamespaceRecord(statement, &records->back()); |
959 } | 960 } |
960 } | 961 } |
961 | 962 |
962 void AppCacheDatabase::ReadNamespaceRecord( | 963 void AppCacheDatabase::ReadNamespaceRecord( |
963 const sql::Statement* statement, NamespaceRecord* record) { | 964 const sql::Statement* statement, NamespaceRecord* record) { |
964 record->cache_id = statement->ColumnInt64(0); | 965 record->cache_id = statement->ColumnInt64(0); |
965 record->origin = GURL(statement->ColumnString(1)); | 966 record->origin = GURL(statement->ColumnString(1)); |
966 int type_with_executable_bit = statement->ColumnInt(2); | 967 int type_with_executable_bit = statement->ColumnInt(2); |
967 record->namespace_.namespace_url = GURL(statement->ColumnString(3)); | 968 record->namespace_.namespace_url = GURL(statement->ColumnString(3)); |
968 record->namespace_.target_url = GURL(statement->ColumnString(4)); | 969 record->namespace_.target_url = GURL(statement->ColumnString(4)); |
969 record->namespace_.is_pattern = statement->ColumnBool(5); | 970 record->namespace_.is_pattern = statement->ColumnBool(5); |
970 | 971 |
971 // Note: quick and dirty storage for the 'executable' bit w/o changing | 972 // Note: quick and dirty storage for the 'executable' bit w/o changing |
972 // schemas, we use the high bit of 'type' field. | 973 // schemas, we use the high bit of 'type' field. |
973 record->namespace_.type = static_cast<NamespaceType> | 974 record->namespace_.type = static_cast<AppCacheNamespaceType> |
974 (type_with_executable_bit & 0x7ffffff); | 975 (type_with_executable_bit & 0x7ffffff); |
975 record->namespace_.is_executable = | 976 record->namespace_.is_executable = |
976 (type_with_executable_bit & 0x80000000) != 0; | 977 (type_with_executable_bit & 0x80000000) != 0; |
977 DCHECK(!record->namespace_.is_executable || | 978 DCHECK(!record->namespace_.is_executable || |
978 CommandLine::ForCurrentProcess()->HasSwitch(kEnableExecutableHandlers)); | 979 CommandLine::ForCurrentProcess()->HasSwitch(kEnableExecutableHandlers)); |
979 } | 980 } |
980 | 981 |
981 void AppCacheDatabase::ReadOnlineWhiteListRecord( | 982 void AppCacheDatabase::ReadOnlineWhiteListRecord( |
982 const sql::Statement& statement, OnlineWhiteListRecord* record) { | 983 const sql::Statement& statement, OnlineWhiteListRecord* record) { |
983 record->cache_id = statement.ColumnInt64(0); | 984 record->cache_id = statement.ColumnInt64(0); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 } | 1216 } |
1216 | 1217 |
1217 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { | 1218 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { |
1218 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); | 1219 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); |
1219 if (!db_->ShouldIgnoreSqliteError(err)) | 1220 if (!db_->ShouldIgnoreSqliteError(err)) |
1220 DLOG(ERROR) << db_->GetErrorMessage(); | 1221 DLOG(ERROR) << db_->GetErrorMessage(); |
1221 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? | 1222 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? |
1222 } | 1223 } |
1223 | 1224 |
1224 } // namespace appcache | 1225 } // namespace appcache |
OLD | NEW |