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

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

Powered by Google App Engine
This is Rietveld 408576698