Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 1996443003: Return number of values deleted by IDBObjectStore.delete(range) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DeleteRange Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/auto_reset.h" 14 #include "base/auto_reset.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "base/numerics/safe_conversions.h"
20 #include "base/stl_util.h" 21 #include "base/stl_util.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #include "content/browser/indexed_db/indexed_db_blob_info.h" 24 #include "content/browser/indexed_db/indexed_db_blob_info.h"
24 #include "content/browser/indexed_db/indexed_db_class_factory.h" 25 #include "content/browser/indexed_db/indexed_db_class_factory.h"
25 #include "content/browser/indexed_db/indexed_db_connection.h" 26 #include "content/browser/indexed_db/indexed_db_connection.h"
26 #include "content/browser/indexed_db/indexed_db_context_impl.h" 27 #include "content/browser/indexed_db/indexed_db_context_impl.h"
27 #include "content/browser/indexed_db/indexed_db_cursor.h" 28 #include "content/browser/indexed_db/indexed_db_cursor.h"
28 #include "content/browser/indexed_db/indexed_db_factory.h" 29 #include "content/browser/indexed_db/indexed_db_factory.h"
29 #include "content/browser/indexed_db/indexed_db_index_writer.h" 30 #include "content/browser/indexed_db/indexed_db_index_writer.h"
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 object_store_id, 1404 object_store_id,
1404 base::Passed(&key_range), 1405 base::Passed(&key_range),
1405 callbacks)); 1406 callbacks));
1406 } 1407 }
1407 1408
1408 void IndexedDBDatabase::DeleteRangeOperation( 1409 void IndexedDBDatabase::DeleteRangeOperation(
1409 int64_t object_store_id, 1410 int64_t object_store_id,
1410 std::unique_ptr<IndexedDBKeyRange> key_range, 1411 std::unique_ptr<IndexedDBKeyRange> key_range,
1411 scoped_refptr<IndexedDBCallbacks> callbacks, 1412 scoped_refptr<IndexedDBCallbacks> callbacks,
1412 IndexedDBTransaction* transaction) { 1413 IndexedDBTransaction* transaction) {
1413 IDB_TRACE1( 1414 IDB_TRACE1("IndexedDBDatabase::DeleteRangeOperation", "txn.id",
1414 "IndexedDBDatabase::DeleteRangeOperation", "txn.id", transaction->id()); 1415 transaction->id());
1416 size_t delete_count = 0;
1415 leveldb::Status s = 1417 leveldb::Status s =
1416 backing_store_->DeleteRange(transaction->BackingStoreTransaction(), 1418 backing_store_->DeleteRange(transaction->BackingStoreTransaction(), id(),
1417 id(), 1419 object_store_id, *key_range, &delete_count);
1418 object_store_id,
1419 *key_range);
1420 if (!s.ok()) { 1420 if (!s.ok()) {
1421 base::string16 error_string = 1421 base::string16 error_string =
1422 ASCIIToUTF16("Internal error deleting data in range"); 1422 ASCIIToUTF16("Internal error deleting data in range");
1423 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, 1423 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
1424 error_string); 1424 error_string);
1425 transaction->Abort(error); 1425 transaction->Abort(error);
1426 if (s.IsCorruption()) { 1426 if (s.IsCorruption()) {
1427 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); 1427 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error);
1428 } 1428 }
1429 return; 1429 return;
1430 } 1430 }
1431 callbacks->OnSuccess(); 1431 callbacks->OnSuccess(base::checked_cast<int64_t>(delete_count));
dmurph 2016/05/24 18:49:18 Put the check right here. if (experiment_web_plat
palakj1 2016/05/26 18:04:28 Thanks. Had done the same thing.
1432 } 1432 }
1433 1433
1434 void IndexedDBDatabase::Clear(int64_t transaction_id, 1434 void IndexedDBDatabase::Clear(int64_t transaction_id,
1435 int64_t object_store_id, 1435 int64_t object_store_id,
1436 scoped_refptr<IndexedDBCallbacks> callbacks) { 1436 scoped_refptr<IndexedDBCallbacks> callbacks) {
1437 IDB_TRACE1("IndexedDBDatabase::Clear", "txn.id", transaction_id); 1437 IDB_TRACE1("IndexedDBDatabase::Clear", "txn.id", transaction_id);
1438 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 1438 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
1439 if (!transaction) 1439 if (!transaction)
1440 return; 1440 return;
1441 DCHECK_NE(transaction->mode(), blink::WebIDBTransactionModeReadOnly); 1441 DCHECK_NE(transaction->mode(), blink::WebIDBTransactionModeReadOnly);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 1941
1942 void IndexedDBDatabase::VersionChangeAbortOperation( 1942 void IndexedDBDatabase::VersionChangeAbortOperation(
1943 int64_t previous_version, 1943 int64_t previous_version,
1944 IndexedDBTransaction* transaction) { 1944 IndexedDBTransaction* transaction) {
1945 DCHECK(!transaction); 1945 DCHECK(!transaction);
1946 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 1946 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
1947 metadata_.version = previous_version; 1947 metadata_.version = previous_version;
1948 } 1948 }
1949 1949
1950 } // namespace content 1950 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698