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 #include <vector> |
9 | 10 |
10 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 18 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
18 #include "content/browser/indexed_db/indexed_db_connection.h" | 19 #include "content/browser/indexed_db/indexed_db_connection.h" |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 base::Passed(&key_range), | 1217 base::Passed(&key_range), |
1217 callbacks)); | 1218 callbacks)); |
1218 } | 1219 } |
1219 | 1220 |
1220 void IndexedDBDatabase::DeleteRangeOperation( | 1221 void IndexedDBDatabase::DeleteRangeOperation( |
1221 int64 object_store_id, | 1222 int64 object_store_id, |
1222 scoped_ptr<IndexedDBKeyRange> key_range, | 1223 scoped_ptr<IndexedDBKeyRange> key_range, |
1223 scoped_refptr<IndexedDBCallbacks> callbacks, | 1224 scoped_refptr<IndexedDBCallbacks> callbacks, |
1224 IndexedDBTransaction* transaction) { | 1225 IndexedDBTransaction* transaction) { |
1225 IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation"); | 1226 IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation"); |
1226 leveldb::Status s; | 1227 if (!backing_store_->DeleteRange(transaction->BackingStoreTransaction(), |
1227 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor = | 1228 id(), |
1228 backing_store_->OpenObjectStoreCursor( | 1229 object_store_id, |
1229 transaction->BackingStoreTransaction(), | 1230 *key_range).ok()) { |
1230 id(), | 1231 callbacks->OnError( |
1231 object_store_id, | 1232 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
1232 *key_range, | 1233 "Internal error deleting data in range")); |
1233 indexed_db::CURSOR_NEXT, | |
1234 &s); | |
1235 if (backing_store_cursor && s.ok()) { | |
1236 do { | |
1237 if (!backing_store_->DeleteRecord( | |
1238 transaction->BackingStoreTransaction(), | |
1239 id(), | |
1240 object_store_id, | |
1241 backing_store_cursor->record_identifier()) | |
1242 .ok()) { | |
1243 callbacks->OnError( | |
1244 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | |
1245 "Internal error deleting data in range")); | |
1246 return; | |
1247 } | |
1248 } while (backing_store_cursor->Continue(&s)); | |
1249 } | |
1250 | |
1251 if (!s.ok()) { | |
1252 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | |
1253 ASCIIToUTF16("Internal error deleting range")); | |
1254 transaction->Abort(error); | |
1255 if (s.IsCorruption()) { | |
1256 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | |
1257 error); | |
1258 } | |
1259 return; | 1234 return; |
1260 } | 1235 } |
1261 | |
1262 callbacks->OnSuccess(); | 1236 callbacks->OnSuccess(); |
1263 } | 1237 } |
1264 | 1238 |
1265 void IndexedDBDatabase::Clear(int64 transaction_id, | 1239 void IndexedDBDatabase::Clear(int64 transaction_id, |
1266 int64 object_store_id, | 1240 int64 object_store_id, |
1267 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1241 scoped_refptr<IndexedDBCallbacks> callbacks) { |
1268 IDB_TRACE("IndexedDBDatabase::Clear"); | 1242 IDB_TRACE("IndexedDBDatabase::Clear"); |
1269 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1243 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
1270 if (!transaction) | 1244 if (!transaction) |
1271 return; | 1245 return; |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 const base::string16& previous_version, | 1740 const base::string16& previous_version, |
1767 int64 previous_int_version, | 1741 int64 previous_int_version, |
1768 IndexedDBTransaction* transaction) { | 1742 IndexedDBTransaction* transaction) { |
1769 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1743 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1770 DCHECK(!transaction); | 1744 DCHECK(!transaction); |
1771 metadata_.version = previous_version; | 1745 metadata_.version = previous_version; |
1772 metadata_.int_version = previous_int_version; | 1746 metadata_.int_version = previous_int_version; |
1773 } | 1747 } |
1774 | 1748 |
1775 } // namespace content | 1749 } // namespace content |
OLD | NEW |