OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/indexed_db/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 base::Passed(&key_range), | 1199 base::Passed(&key_range), |
1200 callbacks)); | 1200 callbacks)); |
1201 } | 1201 } |
1202 | 1202 |
1203 void IndexedDBDatabase::DeleteRangeOperation( | 1203 void IndexedDBDatabase::DeleteRangeOperation( |
1204 int64 object_store_id, | 1204 int64 object_store_id, |
1205 scoped_ptr<IndexedDBKeyRange> key_range, | 1205 scoped_ptr<IndexedDBKeyRange> key_range, |
1206 scoped_refptr<IndexedDBCallbacks> callbacks, | 1206 scoped_refptr<IndexedDBCallbacks> callbacks, |
1207 IndexedDBTransaction* transaction) { | 1207 IndexedDBTransaction* transaction) { |
1208 IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation"); | 1208 IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation"); |
1209 leveldb::Status s; | 1209 leveldb::Status s = |
1210 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor = | 1210 backing_store_->DeleteRange(transaction->BackingStoreTransaction(), |
1211 backing_store_->OpenObjectStoreCursor( | 1211 id(), |
1212 transaction->BackingStoreTransaction(), | 1212 object_store_id, |
1213 id(), | 1213 *key_range); |
1214 object_store_id, | |
1215 *key_range, | |
1216 indexed_db::CURSOR_NEXT, | |
1217 &s); | |
1218 if (backing_store_cursor && s.ok()) { | |
1219 do { | |
1220 if (!backing_store_->DeleteRecord( | |
1221 transaction->BackingStoreTransaction(), | |
1222 id(), | |
1223 object_store_id, | |
1224 backing_store_cursor->record_identifier()) | |
1225 .ok()) { | |
1226 callbacks->OnError( | |
1227 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | |
1228 "Internal error deleting data in range")); | |
1229 return; | |
1230 } | |
1231 } while (backing_store_cursor->Continue(&s)); | |
1232 } | |
1233 | |
1234 if (!s.ok()) { | 1214 if (!s.ok()) { |
| 1215 base::string16 error_string = |
| 1216 ASCIIToUTF16("Internal error deleting data in range"); |
1235 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1217 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1236 ASCIIToUTF16("Internal error deleting range")); | 1218 error_string); |
1237 transaction->Abort(error); | 1219 transaction->Abort(error); |
1238 if (s.IsCorruption()) { | 1220 if (s.IsCorruption()) |
1239 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1221 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1240 error); | 1222 error); |
1241 } | |
1242 return; | 1223 return; |
1243 } | 1224 } |
1244 | |
1245 callbacks->OnSuccess(); | 1225 callbacks->OnSuccess(); |
1246 } | 1226 } |
1247 | 1227 |
1248 void IndexedDBDatabase::Clear(int64 transaction_id, | 1228 void IndexedDBDatabase::Clear(int64 transaction_id, |
1249 int64 object_store_id, | 1229 int64 object_store_id, |
1250 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1230 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1251 IDB_TRACE("IndexedDBDatabase::Clear"); | 1231 IDB_TRACE("IndexedDBDatabase::Clear"); |
1252 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1232 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
1253 if (!transaction) | 1233 if (!transaction) |
1254 return; | 1234 return; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 const base::string16& previous_version, | 1741 const base::string16& previous_version, |
1762 int64 previous_int_version, | 1742 int64 previous_int_version, |
1763 IndexedDBTransaction* transaction) { | 1743 IndexedDBTransaction* transaction) { |
1764 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1744 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1765 DCHECK(!transaction); | 1745 DCHECK(!transaction); |
1766 metadata_.version = previous_version; | 1746 metadata_.version = previous_version; |
1767 metadata_.int_version = previous_int_version; | 1747 metadata_.int_version = previous_int_version; |
1768 } | 1748 } |
1769 | 1749 |
1770 } // namespace content | 1750 } // namespace content |
OLD | NEW |