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

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

Issue 18241003: IndexedDB: Remove IndexedDBCallbacksWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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_cursor.h" 5 #include "content/browser/indexed_db/indexed_db_cursor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/indexed_db/indexed_db_backing_store.h" 8 #include "content/browser/indexed_db/indexed_db_backing_store.h"
9 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" 9 #include "content/browser/indexed_db/indexed_db_callbacks.h"
10 #include "content/browser/indexed_db/indexed_db_database.h" 10 #include "content/browser/indexed_db/indexed_db_database.h"
11 #include "content/browser/indexed_db/indexed_db_database_error.h" 11 #include "content/browser/indexed_db/indexed_db_database_error.h"
12 #include "content/browser/indexed_db/indexed_db_tracing.h" 12 #include "content/browser/indexed_db/indexed_db_tracing.h"
13 #include "content/browser/indexed_db/indexed_db_transaction.h" 13 #include "content/browser/indexed_db/indexed_db_transaction.h"
14 #include "content/common/indexed_db/indexed_db_key_range.h" 14 #include "content/common/indexed_db/indexed_db_key_range.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class IndexedDBCursor::CursorIterationOperation 18 class IndexedDBCursor::CursorIterationOperation
19 : public IndexedDBTransaction::Operation { 19 : public IndexedDBTransaction::Operation {
20 public: 20 public:
21 CursorIterationOperation(scoped_refptr<IndexedDBCursor> cursor, 21 CursorIterationOperation(scoped_refptr<IndexedDBCursor> cursor,
22 scoped_ptr<IndexedDBKey> key, 22 scoped_ptr<IndexedDBKey> key,
23 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) 23 scoped_refptr<IndexedDBCallbacks> callbacks)
24 : cursor_(cursor), key_(key.Pass()), callbacks_(callbacks) {} 24 : cursor_(cursor), key_(key.Pass()), callbacks_(callbacks) {}
25 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; 25 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE;
26 26
27 private: 27 private:
28 scoped_refptr<IndexedDBCursor> cursor_; 28 scoped_refptr<IndexedDBCursor> cursor_;
29 scoped_ptr<IndexedDBKey> key_; 29 scoped_ptr<IndexedDBKey> key_;
30 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; 30 scoped_refptr<IndexedDBCallbacks> callbacks_;
31 }; 31 };
32 32
33 class IndexedDBCursor::CursorAdvanceOperation 33 class IndexedDBCursor::CursorAdvanceOperation
34 : public IndexedDBTransaction::Operation { 34 : public IndexedDBTransaction::Operation {
35 public: 35 public:
36 CursorAdvanceOperation(scoped_refptr<IndexedDBCursor> cursor, 36 CursorAdvanceOperation(scoped_refptr<IndexedDBCursor> cursor,
37 uint32 count, 37 uint32 count,
38 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) 38 scoped_refptr<IndexedDBCallbacks> callbacks)
39 : cursor_(cursor), count_(count), callbacks_(callbacks) {} 39 : cursor_(cursor), count_(count), callbacks_(callbacks) {}
40 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; 40 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE;
41 41
42 private: 42 private:
43 scoped_refptr<IndexedDBCursor> cursor_; 43 scoped_refptr<IndexedDBCursor> cursor_;
44 uint32 count_; 44 uint32 count_;
45 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; 45 scoped_refptr<IndexedDBCallbacks> callbacks_;
46 }; 46 };
47 47
48 class IndexedDBCursor::CursorPrefetchIterationOperation 48 class IndexedDBCursor::CursorPrefetchIterationOperation
49 : public IndexedDBTransaction::Operation { 49 : public IndexedDBTransaction::Operation {
50 public: 50 public:
51 CursorPrefetchIterationOperation( 51 CursorPrefetchIterationOperation(scoped_refptr<IndexedDBCursor> cursor,
52 scoped_refptr<IndexedDBCursor> cursor, 52 int number_to_fetch,
53 int number_to_fetch, 53 scoped_refptr<IndexedDBCallbacks> callbacks)
54 scoped_refptr<IndexedDBCallbacksWrapper> callbacks)
55 : cursor_(cursor), 54 : cursor_(cursor),
56 number_to_fetch_(number_to_fetch), 55 number_to_fetch_(number_to_fetch),
57 callbacks_(callbacks) {} 56 callbacks_(callbacks) {}
58 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; 57 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE;
59 58
60 private: 59 private:
61 scoped_refptr<IndexedDBCursor> cursor_; 60 scoped_refptr<IndexedDBCursor> cursor_;
62 int number_to_fetch_; 61 int number_to_fetch_;
63 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; 62 scoped_refptr<IndexedDBCallbacks> callbacks_;
64 }; 63 };
65 64
66 IndexedDBCursor::IndexedDBCursor( 65 IndexedDBCursor::IndexedDBCursor(
67 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, 66 scoped_ptr<IndexedDBBackingStore::Cursor> cursor,
68 indexed_db::CursorType cursor_type, 67 indexed_db::CursorType cursor_type,
69 IndexedDBDatabase::TaskType task_type, 68 IndexedDBDatabase::TaskType task_type,
70 IndexedDBTransaction* transaction) 69 IndexedDBTransaction* transaction)
71 : task_type_(task_type), 70 : task_type_(task_type),
72 cursor_type_(cursor_type), 71 cursor_type_(cursor_type),
73 transaction_(transaction), 72 transaction_(transaction),
74 cursor_(cursor.Pass()), 73 cursor_(cursor.Pass()),
75 closed_(false) { 74 closed_(false) {
76 transaction_->RegisterOpenCursor(this); 75 transaction_->RegisterOpenCursor(this);
77 } 76 }
78 77
79 IndexedDBCursor::~IndexedDBCursor() { 78 IndexedDBCursor::~IndexedDBCursor() {
80 transaction_->UnregisterOpenCursor(this); 79 transaction_->UnregisterOpenCursor(this);
81 } 80 }
82 81
83 void IndexedDBCursor::ContinueFunction( 82 void IndexedDBCursor::ContinueFunction(
84 scoped_ptr<IndexedDBKey> key, 83 scoped_ptr<IndexedDBKey> key,
85 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { 84 scoped_refptr<IndexedDBCallbacks> callbacks) {
86 IDB_TRACE("IndexedDBCursor::Continue"); 85 IDB_TRACE("IndexedDBCursor::Continue");
87 86
88 transaction_->ScheduleTask( 87 transaction_->ScheduleTask(
89 task_type_, new CursorIterationOperation(this, key.Pass(), callbacks)); 88 task_type_, new CursorIterationOperation(this, key.Pass(), callbacks));
90 } 89 }
91 90
92 void IndexedDBCursor::Advance( 91 void IndexedDBCursor::Advance(uint32 count,
93 uint32 count, 92 scoped_refptr<IndexedDBCallbacks> callbacks) {
94 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) {
95 IDB_TRACE("IndexedDBCursor::Advance"); 93 IDB_TRACE("IndexedDBCursor::Advance");
96 94
97 transaction_->ScheduleTask( 95 transaction_->ScheduleTask(
98 new CursorAdvanceOperation(this, count, callbacks)); 96 new CursorAdvanceOperation(this, count, callbacks));
99 } 97 }
100 98
101 void IndexedDBCursor::CursorAdvanceOperation::Perform( 99 void IndexedDBCursor::CursorAdvanceOperation::Perform(
102 IndexedDBTransaction* /*transaction*/) { 100 IndexedDBTransaction* /*transaction*/) {
103 IDB_TRACE("CursorAdvanceOperation"); 101 IDB_TRACE("CursorAdvanceOperation");
104 if (!cursor_->cursor_ || !cursor_->cursor_->Advance(count_)) { 102 if (!cursor_->cursor_ || !cursor_->cursor_->Advance(count_)) {
(...skipping 16 matching lines...) Expand all
121 callbacks_->OnSuccess(static_cast<std::vector<char>*>(NULL)); 119 callbacks_->OnSuccess(static_cast<std::vector<char>*>(NULL));
122 return; 120 return;
123 } 121 }
124 122
125 callbacks_->OnSuccess( 123 callbacks_->OnSuccess(
126 cursor_->key(), cursor_->primary_key(), cursor_->Value()); 124 cursor_->key(), cursor_->primary_key(), cursor_->Value());
127 } 125 }
128 126
129 void IndexedDBCursor::PrefetchContinue( 127 void IndexedDBCursor::PrefetchContinue(
130 int number_to_fetch, 128 int number_to_fetch,
131 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { 129 scoped_refptr<IndexedDBCallbacks> callbacks) {
132 IDB_TRACE("IndexedDBCursor::PrefetchContinue"); 130 IDB_TRACE("IndexedDBCursor::PrefetchContinue");
133 131
134 transaction_->ScheduleTask( 132 transaction_->ScheduleTask(
135 task_type_, 133 task_type_,
136 new CursorPrefetchIterationOperation(this, number_to_fetch, callbacks)); 134 new CursorPrefetchIterationOperation(this, number_to_fetch, callbacks));
137 } 135 }
138 136
139 void IndexedDBCursor::CursorPrefetchIterationOperation::Perform( 137 void IndexedDBCursor::CursorPrefetchIterationOperation::Perform(
140 IndexedDBTransaction* /*transaction*/) { 138 IndexedDBTransaction* /*transaction*/) {
141 IDB_TRACE("CursorPrefetchIterationOperation"); 139 IDB_TRACE("CursorPrefetchIterationOperation");
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 202 }
205 203
206 void IndexedDBCursor::Close() { 204 void IndexedDBCursor::Close() {
207 IDB_TRACE("IndexedDBCursor::Close"); 205 IDB_TRACE("IndexedDBCursor::Close");
208 closed_ = true; 206 closed_ = true;
209 cursor_.reset(); 207 cursor_.reset();
210 saved_cursor_.reset(); 208 saved_cursor_.reset();
211 } 209 }
212 210
213 } // namespace content 211 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698