OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cursor_impl.h" | 5 #include "content/browser/indexed_db/cursor_impl.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
9 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 9 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
10 #include "content/browser/indexed_db/indexed_db_cursor.h" | 10 #include "content/browser/indexed_db/indexed_db_cursor.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 CursorImpl::~CursorImpl() { | 43 CursorImpl::~CursorImpl() { |
44 idb_runner_->DeleteSoon(FROM_HERE, helper_); | 44 idb_runner_->DeleteSoon(FROM_HERE, helper_); |
45 } | 45 } |
46 | 46 |
47 void CursorImpl::Advance( | 47 void CursorImpl::Advance( |
48 uint32_t count, | 48 uint32_t count, |
49 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 49 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
50 scoped_refptr<IndexedDBCallbacks> callbacks( | 50 scoped_refptr<IndexedDBCallbacks> callbacks( |
51 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, | 51 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
52 std::move(callbacks_info), idb_runner_)); | 52 std::move(callbacks_info), idb_runner_)); |
53 idb_runner_->PostTask(FROM_HERE, base::Bind(&IDBSequenceHelper::Advance, | 53 idb_runner_->PostTask( |
54 base::Unretained(helper_), count, | 54 FROM_HERE, |
55 base::Passed(&callbacks))); | 55 base::BindOnce(&IDBSequenceHelper::Advance, base::Unretained(helper_), |
| 56 count, base::Passed(&callbacks))); |
56 } | 57 } |
57 | 58 |
58 void CursorImpl::Continue( | 59 void CursorImpl::Continue( |
59 const IndexedDBKey& key, | 60 const IndexedDBKey& key, |
60 const IndexedDBKey& primary_key, | 61 const IndexedDBKey& primary_key, |
61 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 62 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
62 scoped_refptr<IndexedDBCallbacks> callbacks( | 63 scoped_refptr<IndexedDBCallbacks> callbacks( |
63 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, | 64 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
64 std::move(callbacks_info), idb_runner_)); | 65 std::move(callbacks_info), idb_runner_)); |
65 idb_runner_->PostTask( | 66 idb_runner_->PostTask( |
66 FROM_HERE, | 67 FROM_HERE, |
67 base::Bind(&IDBSequenceHelper::Continue, base::Unretained(helper_), key, | 68 base::BindOnce(&IDBSequenceHelper::Continue, base::Unretained(helper_), |
68 primary_key, base::Passed(&callbacks))); | 69 key, primary_key, base::Passed(&callbacks))); |
69 } | 70 } |
70 | 71 |
71 void CursorImpl::Prefetch( | 72 void CursorImpl::Prefetch( |
72 int32_t count, | 73 int32_t count, |
73 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 74 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
74 scoped_refptr<IndexedDBCallbacks> callbacks( | 75 scoped_refptr<IndexedDBCallbacks> callbacks( |
75 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, | 76 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
76 std::move(callbacks_info), idb_runner_)); | 77 std::move(callbacks_info), idb_runner_)); |
77 idb_runner_->PostTask(FROM_HERE, base::Bind(&IDBSequenceHelper::Prefetch, | 78 idb_runner_->PostTask( |
78 base::Unretained(helper_), count, | 79 FROM_HERE, |
79 base::Passed(&callbacks))); | 80 base::BindOnce(&IDBSequenceHelper::Prefetch, base::Unretained(helper_), |
| 81 count, base::Passed(&callbacks))); |
80 } | 82 } |
81 | 83 |
82 void CursorImpl::PrefetchReset( | 84 void CursorImpl::PrefetchReset( |
83 int32_t used_prefetches, | 85 int32_t used_prefetches, |
84 int32_t unused_prefetches, | 86 int32_t unused_prefetches, |
85 const std::vector<std::string>& unused_blob_uuids) { | 87 const std::vector<std::string>& unused_blob_uuids) { |
86 for (const auto& uuid : unused_blob_uuids) | 88 for (const auto& uuid : unused_blob_uuids) |
87 dispatcher_host_->DropBlobData(uuid); | 89 dispatcher_host_->DropBlobData(uuid); |
88 | 90 |
89 idb_runner_->PostTask( | 91 idb_runner_->PostTask( |
90 FROM_HERE, | 92 FROM_HERE, base::BindOnce(&IDBSequenceHelper::PrefetchReset, |
91 base::Bind(&IDBSequenceHelper::PrefetchReset, base::Unretained(helper_), | 93 base::Unretained(helper_), used_prefetches, |
92 used_prefetches, unused_prefetches)); | 94 unused_prefetches)); |
93 } | 95 } |
94 | 96 |
95 CursorImpl::IDBSequenceHelper::IDBSequenceHelper( | 97 CursorImpl::IDBSequenceHelper::IDBSequenceHelper( |
96 std::unique_ptr<IndexedDBCursor> cursor) | 98 std::unique_ptr<IndexedDBCursor> cursor) |
97 : cursor_(std::move(cursor)) {} | 99 : cursor_(std::move(cursor)) {} |
98 | 100 |
99 CursorImpl::IDBSequenceHelper::~IDBSequenceHelper() {} | 101 CursorImpl::IDBSequenceHelper::~IDBSequenceHelper() {} |
100 | 102 |
101 void CursorImpl::IDBSequenceHelper::Advance( | 103 void CursorImpl::IDBSequenceHelper::Advance( |
102 uint32_t count, | 104 uint32_t count, |
(...skipping 21 matching lines...) Expand all Loading... |
124 void CursorImpl::IDBSequenceHelper::PrefetchReset(int32_t used_prefetches, | 126 void CursorImpl::IDBSequenceHelper::PrefetchReset(int32_t used_prefetches, |
125 int32_t unused_prefetches) { | 127 int32_t unused_prefetches) { |
126 leveldb::Status s = | 128 leveldb::Status s = |
127 cursor_->PrefetchReset(used_prefetches, unused_prefetches); | 129 cursor_->PrefetchReset(used_prefetches, unused_prefetches); |
128 // TODO(cmumford): Handle this error (crbug.com/363397) | 130 // TODO(cmumford): Handle this error (crbug.com/363397) |
129 if (!s.ok()) | 131 if (!s.ok()) |
130 DLOG(ERROR) << "Unable to reset prefetch"; | 132 DLOG(ERROR) << "Unable to reset prefetch"; |
131 } | 133 } |
132 | 134 |
133 } // namespace content | 135 } // namespace content |
OLD | NEW |