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

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

Issue 2233153002: IndexedDB: WrapUnique(new T(args..)) -> MakeUnique<T>(args...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 4 years, 4 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_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.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/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/trace_event/memory_dump_manager.h" 22 #include "base/trace_event/memory_dump_manager.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "content/browser/child_process_security_policy_impl.h" 24 #include "content/browser/child_process_security_policy_impl.h"
24 #include "content/browser/indexed_db/indexed_db_blob_info.h" 25 #include "content/browser/indexed_db/indexed_db_blob_info.h"
25 #include "content/browser/indexed_db/indexed_db_class_factory.h" 26 #include "content/browser/indexed_db/indexed_db_class_factory.h"
26 #include "content/browser/indexed_db/indexed_db_context_impl.h" 27 #include "content/browser/indexed_db/indexed_db_context_impl.h"
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 base::SequencedTaskRunner* task_runner, 967 base::SequencedTaskRunner* task_runner,
967 bool clean_journal, 968 bool clean_journal,
968 leveldb::Status* status) { 969 leveldb::Status* status) {
969 IDB_TRACE("IndexedDBBackingStore::Open"); 970 IDB_TRACE("IndexedDBBackingStore::Open");
970 DCHECK(!path_base.empty()); 971 DCHECK(!path_base.empty());
971 *is_disk_full = false; 972 *is_disk_full = false;
972 973
973 data_loss_info->status = blink::WebIDBDataLossNone; 974 data_loss_info->status = blink::WebIDBDataLossNone;
974 *status = leveldb::Status::OK(); 975 *status = leveldb::Status::OK();
975 976
976 std::unique_ptr<LevelDBComparator> comparator(new Comparator()); 977 std::unique_ptr<LevelDBComparator> comparator(base::MakeUnique<Comparator>());
977 978
978 if (!base::IsStringASCII(path_base.AsUTF8Unsafe())) { 979 if (!base::IsStringASCII(path_base.AsUTF8Unsafe())) {
979 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, 980 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII,
980 origin); 981 origin);
981 } 982 }
982 if (!base::CreateDirectory(path_base)) { 983 if (!base::CreateDirectory(path_base)) {
983 *status = 984 *status =
984 leveldb::Status::IOError("Unable to create IndexedDB database path"); 985 leveldb::Status::IOError("Unable to create IndexedDB database path");
985 LOG(ERROR) << status->ToString() << ": \"" << path_base.AsUTF8Unsafe() 986 LOG(ERROR) << status->ToString() << ": \"" << path_base.AsUTF8Unsafe()
986 << "\""; 987 << "\"";
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 } 1112 }
1112 1113
1113 // static 1114 // static
1114 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( 1115 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory(
1115 const Origin& origin, 1116 const Origin& origin,
1116 LevelDBFactory* leveldb_factory, 1117 LevelDBFactory* leveldb_factory,
1117 base::SequencedTaskRunner* task_runner, 1118 base::SequencedTaskRunner* task_runner,
1118 leveldb::Status* status) { 1119 leveldb::Status* status) {
1119 IDB_TRACE("IndexedDBBackingStore::OpenInMemory"); 1120 IDB_TRACE("IndexedDBBackingStore::OpenInMemory");
1120 1121
1121 std::unique_ptr<LevelDBComparator> comparator(new Comparator()); 1122 std::unique_ptr<LevelDBComparator> comparator(base::MakeUnique<Comparator>());
1122 std::unique_ptr<LevelDBDatabase> db = 1123 std::unique_ptr<LevelDBDatabase> db =
1123 LevelDBDatabase::OpenInMemory(comparator.get()); 1124 LevelDBDatabase::OpenInMemory(comparator.get());
1124 if (!db) { 1125 if (!db) {
1125 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed."; 1126 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed.";
1126 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED, origin); 1127 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED, origin);
1127 return scoped_refptr<IndexedDBBackingStore>(); 1128 return scoped_refptr<IndexedDBBackingStore>();
1128 } 1129 }
1129 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, origin); 1130 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, origin);
1130 base::trace_event::MemoryDumpManager::GetInstance() 1131 base::trace_event::MemoryDumpManager::GetInstance()
1131 ->RegisterDumpProviderWithSequencedTaskRunner( 1132 ->RegisterDumpProviderWithSequencedTaskRunner(
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 2327
2327 void WriteBlobToFileOnIOThread(const FilePath& file_path, 2328 void WriteBlobToFileOnIOThread(const FilePath& file_path,
2328 const GURL& blob_url, 2329 const GURL& blob_url,
2329 const base::Time& last_modified, 2330 const base::Time& last_modified,
2330 net::URLRequestContext* request_context) { 2331 net::URLRequestContext* request_context) {
2331 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 2332 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
2332 std::unique_ptr<storage::FileStreamWriter> writer( 2333 std::unique_ptr<storage::FileStreamWriter> writer(
2333 storage::FileStreamWriter::CreateForLocalFile( 2334 storage::FileStreamWriter::CreateForLocalFile(
2334 task_runner_.get(), file_path, 0, 2335 task_runner_.get(), file_path, 0,
2335 storage::FileStreamWriter::CREATE_NEW_FILE)); 2336 storage::FileStreamWriter::CREATE_NEW_FILE));
2336 std::unique_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( 2337 std::unique_ptr<FileWriterDelegate> delegate(
2337 std::move(writer), storage::FlushPolicy::FLUSH_ON_COMPLETION)); 2338 base::MakeUnique<FileWriterDelegate>(
2339 std::move(writer), storage::FlushPolicy::FLUSH_ON_COMPLETION));
2338 2340
2339 DCHECK(blob_url.is_valid()); 2341 DCHECK(blob_url.is_valid());
2340 std::unique_ptr<net::URLRequest> blob_request( 2342 std::unique_ptr<net::URLRequest> blob_request(
2341 request_context->CreateRequest(blob_url, net::DEFAULT_PRIORITY, 2343 request_context->CreateRequest(blob_url, net::DEFAULT_PRIORITY,
2342 delegate.get())); 2344 delegate.get()));
2343 2345
2344 this->file_path_ = file_path; 2346 this->file_path_ = file_path;
2345 this->last_modified_ = last_modified; 2347 this->last_modified_ = last_modified;
2346 2348
2347 delegate->Start(std::move(blob_request), 2349 delegate->Start(std::move(blob_request),
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 else 3091 else
3090 return InvalidDBKeyStatus(); 3092 return InvalidDBKeyStatus();
3091 } 3093 }
3092 3094
3093 IndexedDBBackingStore::Cursor::Cursor( 3095 IndexedDBBackingStore::Cursor::Cursor(
3094 const IndexedDBBackingStore::Cursor* other) 3096 const IndexedDBBackingStore::Cursor* other)
3095 : backing_store_(other->backing_store_), 3097 : backing_store_(other->backing_store_),
3096 transaction_(other->transaction_), 3098 transaction_(other->transaction_),
3097 database_id_(other->database_id_), 3099 database_id_(other->database_id_),
3098 cursor_options_(other->cursor_options_), 3100 cursor_options_(other->cursor_options_),
3099 current_key_(new IndexedDBKey(*other->current_key_)) { 3101 current_key_(base::MakeUnique<IndexedDBKey>(*other->current_key_)) {
3100 if (other->iterator_) { 3102 if (other->iterator_) {
3101 iterator_ = transaction_->transaction()->CreateIterator(); 3103 iterator_ = transaction_->transaction()->CreateIterator();
3102 3104
3103 if (other->iterator_->IsValid()) { 3105 if (other->iterator_->IsValid()) {
3104 leveldb::Status s = iterator_->Seek(other->iterator_->Key()); 3106 leveldb::Status s = iterator_->Seek(other->iterator_->Key());
3105 // TODO(cmumford): Handle this error (crbug.com/363397) 3107 // TODO(cmumford): Handle this error (crbug.com/363397)
3106 DCHECK(iterator_->IsValid()); 3108 DCHECK(iterator_->IsValid());
3107 } 3109 }
3108 } 3110 }
3109 } 3111 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 ObjectStoreKeyCursorImpl( 3375 ObjectStoreKeyCursorImpl(
3374 scoped_refptr<IndexedDBBackingStore> backing_store, 3376 scoped_refptr<IndexedDBBackingStore> backing_store,
3375 IndexedDBBackingStore::Transaction* transaction, 3377 IndexedDBBackingStore::Transaction* transaction,
3376 int64_t database_id, 3378 int64_t database_id,
3377 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3379 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3378 : IndexedDBBackingStore::Cursor(backing_store, 3380 : IndexedDBBackingStore::Cursor(backing_store,
3379 transaction, 3381 transaction,
3380 database_id, 3382 database_id,
3381 cursor_options) {} 3383 cursor_options) {}
3382 3384
3383 Cursor* Clone() override { return new ObjectStoreKeyCursorImpl(this); } 3385 std::unique_ptr<Cursor> Clone() const override {
3386 return base::WrapUnique(new ObjectStoreKeyCursorImpl(this));
3387 }
3384 3388
3385 // IndexedDBBackingStore::Cursor 3389 // IndexedDBBackingStore::Cursor
3386 IndexedDBValue* value() override { 3390 IndexedDBValue* value() override {
3387 NOTREACHED(); 3391 NOTREACHED();
3388 return NULL; 3392 return NULL;
3389 } 3393 }
3390 bool LoadCurrentRow(leveldb::Status* s) override; 3394 bool LoadCurrentRow(leveldb::Status* s) override;
3391 3395
3392 protected: 3396 protected:
3393 std::string EncodeKey(const IndexedDBKey& key) override { 3397 std::string EncodeKey(const IndexedDBKey& key) override {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 ObjectStoreCursorImpl( 3443 ObjectStoreCursorImpl(
3440 scoped_refptr<IndexedDBBackingStore> backing_store, 3444 scoped_refptr<IndexedDBBackingStore> backing_store,
3441 IndexedDBBackingStore::Transaction* transaction, 3445 IndexedDBBackingStore::Transaction* transaction,
3442 int64_t database_id, 3446 int64_t database_id,
3443 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3447 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3444 : IndexedDBBackingStore::Cursor(backing_store, 3448 : IndexedDBBackingStore::Cursor(backing_store,
3445 transaction, 3449 transaction,
3446 database_id, 3450 database_id,
3447 cursor_options) {} 3451 cursor_options) {}
3448 3452
3449 Cursor* Clone() override { return new ObjectStoreCursorImpl(this); } 3453 std::unique_ptr<Cursor> Clone() const override {
3454 return base::WrapUnique(new ObjectStoreCursorImpl(this));
3455 }
3450 3456
3451 // IndexedDBBackingStore::Cursor 3457 // IndexedDBBackingStore::Cursor
3452 IndexedDBValue* value() override { return &current_value_; } 3458 IndexedDBValue* value() override { return &current_value_; }
3453 bool LoadCurrentRow(leveldb::Status* s) override; 3459 bool LoadCurrentRow(leveldb::Status* s) override;
3454 3460
3455 protected: 3461 protected:
3456 std::string EncodeKey(const IndexedDBKey& key) override { 3462 std::string EncodeKey(const IndexedDBKey& key) override {
3457 return ObjectStoreDataKey::Encode( 3463 return ObjectStoreDataKey::Encode(
3458 cursor_options_.database_id, cursor_options_.object_store_id, key); 3464 cursor_options_.database_id, cursor_options_.object_store_id, key);
3459 } 3465 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 IndexKeyCursorImpl( 3517 IndexKeyCursorImpl(
3512 scoped_refptr<IndexedDBBackingStore> backing_store, 3518 scoped_refptr<IndexedDBBackingStore> backing_store,
3513 IndexedDBBackingStore::Transaction* transaction, 3519 IndexedDBBackingStore::Transaction* transaction,
3514 int64_t database_id, 3520 int64_t database_id,
3515 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3521 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3516 : IndexedDBBackingStore::Cursor(backing_store, 3522 : IndexedDBBackingStore::Cursor(backing_store,
3517 transaction, 3523 transaction,
3518 database_id, 3524 database_id,
3519 cursor_options) {} 3525 cursor_options) {}
3520 3526
3521 Cursor* Clone() override { return new IndexKeyCursorImpl(this); } 3527 std::unique_ptr<Cursor> Clone() const override {
3528 return base::WrapUnique(new IndexKeyCursorImpl(this));
3529 }
3522 3530
3523 // IndexedDBBackingStore::Cursor 3531 // IndexedDBBackingStore::Cursor
3524 IndexedDBValue* value() override { 3532 IndexedDBValue* value() override {
3525 NOTREACHED(); 3533 NOTREACHED();
3526 return NULL; 3534 return NULL;
3527 } 3535 }
3528 const IndexedDBKey& primary_key() const override { return *primary_key_; } 3536 const IndexedDBKey& primary_key() const override { return *primary_key_; }
3529 const IndexedDBBackingStore::RecordIdentifier& record_identifier() 3537 const IndexedDBBackingStore::RecordIdentifier& record_identifier()
3530 const override { 3538 const override {
3531 NOTREACHED(); 3539 NOTREACHED();
(...skipping 13 matching lines...) Expand all
3545 return IndexDataKey::Encode(cursor_options_.database_id, 3553 return IndexDataKey::Encode(cursor_options_.database_id,
3546 cursor_options_.object_store_id, 3554 cursor_options_.object_store_id,
3547 cursor_options_.index_id, 3555 cursor_options_.index_id,
3548 key, 3556 key,
3549 primary_key); 3557 primary_key);
3550 } 3558 }
3551 3559
3552 private: 3560 private:
3553 explicit IndexKeyCursorImpl(const IndexKeyCursorImpl* other) 3561 explicit IndexKeyCursorImpl(const IndexKeyCursorImpl* other)
3554 : IndexedDBBackingStore::Cursor(other), 3562 : IndexedDBBackingStore::Cursor(other),
3555 primary_key_(new IndexedDBKey(*other->primary_key_)) {} 3563 primary_key_(base::MakeUnique<IndexedDBKey>(*other->primary_key_)) {}
3556 3564
3557 std::unique_ptr<IndexedDBKey> primary_key_; 3565 std::unique_ptr<IndexedDBKey> primary_key_;
3558 3566
3559 DISALLOW_COPY_AND_ASSIGN(IndexKeyCursorImpl); 3567 DISALLOW_COPY_AND_ASSIGN(IndexKeyCursorImpl);
3560 }; 3568 };
3561 3569
3562 bool IndexKeyCursorImpl::LoadCurrentRow(leveldb::Status* s) { 3570 bool IndexKeyCursorImpl::LoadCurrentRow(leveldb::Status* s) {
3563 StringPiece slice(iterator_->Key()); 3571 StringPiece slice(iterator_->Key());
3564 IndexDataKey index_data_key; 3572 IndexDataKey index_data_key;
3565 if (!IndexDataKey::Decode(&slice, &index_data_key)) { 3573 if (!IndexDataKey::Decode(&slice, &index_data_key)) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 IndexCursorImpl( 3635 IndexCursorImpl(
3628 scoped_refptr<IndexedDBBackingStore> backing_store, 3636 scoped_refptr<IndexedDBBackingStore> backing_store,
3629 IndexedDBBackingStore::Transaction* transaction, 3637 IndexedDBBackingStore::Transaction* transaction,
3630 int64_t database_id, 3638 int64_t database_id,
3631 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3639 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3632 : IndexedDBBackingStore::Cursor(backing_store, 3640 : IndexedDBBackingStore::Cursor(backing_store,
3633 transaction, 3641 transaction,
3634 database_id, 3642 database_id,
3635 cursor_options) {} 3643 cursor_options) {}
3636 3644
3637 Cursor* Clone() override { return new IndexCursorImpl(this); } 3645 std::unique_ptr<Cursor> Clone() const override {
3646 return base::WrapUnique(new IndexCursorImpl(this));
3647 }
3638 3648
3639 // IndexedDBBackingStore::Cursor 3649 // IndexedDBBackingStore::Cursor
3640 IndexedDBValue* value() override { return &current_value_; } 3650 IndexedDBValue* value() override { return &current_value_; }
3641 const IndexedDBKey& primary_key() const override { return *primary_key_; } 3651 const IndexedDBKey& primary_key() const override { return *primary_key_; }
3642 const IndexedDBBackingStore::RecordIdentifier& record_identifier() 3652 const IndexedDBBackingStore::RecordIdentifier& record_identifier()
3643 const override { 3653 const override {
3644 NOTREACHED(); 3654 NOTREACHED();
3645 return record_identifier_; 3655 return record_identifier_;
3646 } 3656 }
3647 bool LoadCurrentRow(leveldb::Status* s) override; 3657 bool LoadCurrentRow(leveldb::Status* s) override;
(...skipping 10 matching lines...) Expand all
3658 return IndexDataKey::Encode(cursor_options_.database_id, 3668 return IndexDataKey::Encode(cursor_options_.database_id,
3659 cursor_options_.object_store_id, 3669 cursor_options_.object_store_id,
3660 cursor_options_.index_id, 3670 cursor_options_.index_id,
3661 key, 3671 key,
3662 primary_key); 3672 primary_key);
3663 } 3673 }
3664 3674
3665 private: 3675 private:
3666 explicit IndexCursorImpl(const IndexCursorImpl* other) 3676 explicit IndexCursorImpl(const IndexCursorImpl* other)
3667 : IndexedDBBackingStore::Cursor(other), 3677 : IndexedDBBackingStore::Cursor(other),
3668 primary_key_(new IndexedDBKey(*other->primary_key_)), 3678 primary_key_(base::MakeUnique<IndexedDBKey>(*other->primary_key_)),
3669 current_value_(other->current_value_), 3679 current_value_(other->current_value_),
3670 primary_leveldb_key_(other->primary_leveldb_key_) {} 3680 primary_leveldb_key_(other->primary_leveldb_key_) {}
3671 3681
3672 std::unique_ptr<IndexedDBKey> primary_key_; 3682 std::unique_ptr<IndexedDBKey> primary_key_;
3673 IndexedDBValue current_value_; 3683 IndexedDBValue current_value_;
3674 std::string primary_leveldb_key_; 3684 std::string primary_leveldb_key_;
3675 3685
3676 DISALLOW_COPY_AND_ASSIGN(IndexCursorImpl); 3686 DISALLOW_COPY_AND_ASSIGN(IndexCursorImpl);
3677 }; 3687 };
3678 3688
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 *s = leveldb::Status::OK(); 3911 *s = leveldb::Status::OK();
3902 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 3912 LevelDBTransaction* leveldb_transaction = transaction->transaction();
3903 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; 3913 IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
3904 if (!ObjectStoreCursorOptions(leveldb_transaction, 3914 if (!ObjectStoreCursorOptions(leveldb_transaction,
3905 database_id, 3915 database_id,
3906 object_store_id, 3916 object_store_id,
3907 range, 3917 range,
3908 direction, 3918 direction,
3909 &cursor_options)) 3919 &cursor_options))
3910 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3920 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3911 std::unique_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( 3921 std::unique_ptr<ObjectStoreCursorImpl> cursor(
3912 this, transaction, database_id, cursor_options)); 3922 base::MakeUnique<ObjectStoreCursorImpl>(this, transaction, database_id,
3923 cursor_options));
3913 if (!cursor->FirstSeek(s)) 3924 if (!cursor->FirstSeek(s))
3914 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3925 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3915 3926
3916 return std::move(cursor); 3927 return std::move(cursor);
3917 } 3928 }
3918 3929
3919 std::unique_ptr<IndexedDBBackingStore::Cursor> 3930 std::unique_ptr<IndexedDBBackingStore::Cursor>
3920 IndexedDBBackingStore::OpenObjectStoreKeyCursor( 3931 IndexedDBBackingStore::OpenObjectStoreKeyCursor(
3921 IndexedDBBackingStore::Transaction* transaction, 3932 IndexedDBBackingStore::Transaction* transaction,
3922 int64_t database_id, 3933 int64_t database_id,
3923 int64_t object_store_id, 3934 int64_t object_store_id,
3924 const IndexedDBKeyRange& range, 3935 const IndexedDBKeyRange& range,
3925 blink::WebIDBCursorDirection direction, 3936 blink::WebIDBCursorDirection direction,
3926 leveldb::Status* s) { 3937 leveldb::Status* s) {
3927 IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreKeyCursor"); 3938 IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreKeyCursor");
3928 *s = leveldb::Status::OK(); 3939 *s = leveldb::Status::OK();
3929 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 3940 LevelDBTransaction* leveldb_transaction = transaction->transaction();
3930 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; 3941 IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
3931 if (!ObjectStoreCursorOptions(leveldb_transaction, 3942 if (!ObjectStoreCursorOptions(leveldb_transaction,
3932 database_id, 3943 database_id,
3933 object_store_id, 3944 object_store_id,
3934 range, 3945 range,
3935 direction, 3946 direction,
3936 &cursor_options)) 3947 &cursor_options))
3937 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3948 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3938 std::unique_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( 3949 std::unique_ptr<ObjectStoreKeyCursorImpl> cursor(
3939 this, transaction, database_id, cursor_options)); 3950 base::MakeUnique<ObjectStoreKeyCursorImpl>(this, transaction, database_id,
3951 cursor_options));
3940 if (!cursor->FirstSeek(s)) 3952 if (!cursor->FirstSeek(s))
3941 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3953 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3942 3954
3943 return std::move(cursor); 3955 return std::move(cursor);
3944 } 3956 }
3945 3957
3946 std::unique_ptr<IndexedDBBackingStore::Cursor> 3958 std::unique_ptr<IndexedDBBackingStore::Cursor>
3947 IndexedDBBackingStore::OpenIndexKeyCursor( 3959 IndexedDBBackingStore::OpenIndexKeyCursor(
3948 IndexedDBBackingStore::Transaction* transaction, 3960 IndexedDBBackingStore::Transaction* transaction,
3949 int64_t database_id, 3961 int64_t database_id,
3950 int64_t object_store_id, 3962 int64_t object_store_id,
3951 int64_t index_id, 3963 int64_t index_id,
3952 const IndexedDBKeyRange& range, 3964 const IndexedDBKeyRange& range,
3953 blink::WebIDBCursorDirection direction, 3965 blink::WebIDBCursorDirection direction,
3954 leveldb::Status* s) { 3966 leveldb::Status* s) {
3955 IDB_TRACE("IndexedDBBackingStore::OpenIndexKeyCursor"); 3967 IDB_TRACE("IndexedDBBackingStore::OpenIndexKeyCursor");
3956 *s = leveldb::Status::OK(); 3968 *s = leveldb::Status::OK();
3957 LevelDBTransaction* leveldb_transaction = transaction->transaction(); 3969 LevelDBTransaction* leveldb_transaction = transaction->transaction();
3958 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; 3970 IndexedDBBackingStore::Cursor::CursorOptions cursor_options;
3959 if (!IndexCursorOptions(leveldb_transaction, 3971 if (!IndexCursorOptions(leveldb_transaction,
3960 database_id, 3972 database_id,
3961 object_store_id, 3973 object_store_id,
3962 index_id, 3974 index_id,
3963 range, 3975 range,
3964 direction, 3976 direction,
3965 &cursor_options)) 3977 &cursor_options))
3966 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3978 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3967 std::unique_ptr<IndexKeyCursorImpl> cursor( 3979 std::unique_ptr<IndexKeyCursorImpl> cursor(
3968 new IndexKeyCursorImpl(this, transaction, database_id, cursor_options)); 3980 base::MakeUnique<IndexKeyCursorImpl>(this, transaction, database_id,
3981 cursor_options));
3969 if (!cursor->FirstSeek(s)) 3982 if (!cursor->FirstSeek(s))
3970 return std::unique_ptr<IndexedDBBackingStore::Cursor>(); 3983 return std::unique_ptr<IndexedDBBackingStore::Cursor>();
3971 3984
3972 return std::move(cursor); 3985 return std::move(cursor);
3973 } 3986 }
3974 3987
3975 std::unique_ptr<IndexedDBBackingStore::Cursor> 3988 std::unique_ptr<IndexedDBBackingStore::Cursor>
3976 IndexedDBBackingStore::OpenIndexCursor( 3989 IndexedDBBackingStore::OpenIndexCursor(
3977 IndexedDBBackingStore::Transaction* transaction, 3990 IndexedDBBackingStore::Transaction* transaction,
3978 int64_t database_id, 3991 int64_t database_id,
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
4468 4481
4469 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( 4482 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor(
4470 const WriteDescriptor& other) = default; 4483 const WriteDescriptor& other) = default;
4471 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() = 4484 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() =
4472 default; 4485 default;
4473 IndexedDBBackingStore::Transaction::WriteDescriptor& 4486 IndexedDBBackingStore::Transaction::WriteDescriptor&
4474 IndexedDBBackingStore::Transaction::WriteDescriptor:: 4487 IndexedDBBackingStore::Transaction::WriteDescriptor::
4475 operator=(const WriteDescriptor& other) = default; 4488 operator=(const WriteDescriptor& other) = default;
4476 4489
4477 } // namespace content 4490 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.h ('k') | content/browser/indexed_db/indexed_db_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698