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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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/webidbdatabase_impl.h" 5 #include "content/browser/indexed_db/webidbdatabase_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, 46 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id,
47 long long object_store_id) { 47 long long object_store_id) {
48 database_backend_->DeleteObjectStore(transaction_id, object_store_id); 48 database_backend_->DeleteObjectStore(transaction_id, object_store_id);
49 } 49 }
50 50
51 void WebIDBDatabaseImpl::createTransaction( 51 void WebIDBDatabaseImpl::createTransaction(
52 long long id, 52 long long id,
53 IndexedDBDatabaseCallbacks* /*callbacks*/, 53 IndexedDBDatabaseCallbacks* /*callbacks*/,
54 const std::vector<int64>& object_store_ids, 54 const std::vector<int64>& object_store_ids,
55 unsigned short mode) { 55 unsigned short mode) {
56 if (!database_callbacks_) 56 if (!database_callbacks_.get())
57 return; 57 return;
58 database_backend_->CreateTransaction( 58 database_backend_->CreateTransaction(
59 id, database_callbacks_.get(), object_store_ids, mode); 59 id, database_callbacks_.get(), object_store_ids, mode);
60 } 60 }
61 61
62 void WebIDBDatabaseImpl::close() { 62 void WebIDBDatabaseImpl::close() {
63 // Use the callbacks passed in to the constructor so that the backend in 63 // Use the callbacks passed in to the constructor so that the backend in
64 // multi-process chromium knows which database connection is closing. 64 // multi-process chromium knows which database connection is closing.
65 if (!database_callbacks_) 65 if (!database_callbacks_.get())
66 return; 66 return;
67 database_backend_->Close(database_callbacks_); 67 database_backend_->Close(database_callbacks_);
68 database_callbacks_ = NULL; 68 database_callbacks_ = NULL;
69 } 69 }
70 70
71 void WebIDBDatabaseImpl::forceClose() { 71 void WebIDBDatabaseImpl::forceClose() {
72 if (!database_callbacks_) 72 if (!database_callbacks_.get())
73 return; 73 return;
74 database_backend_->Close(database_callbacks_); 74 database_backend_->Close(database_callbacks_);
75 database_callbacks_->OnForcedClose(); 75 database_callbacks_->OnForcedClose();
76 database_callbacks_ = NULL; 76 database_callbacks_ = NULL;
77 } 77 }
78 78
79 void WebIDBDatabaseImpl::abort(long long transaction_id) { 79 void WebIDBDatabaseImpl::abort(long long transaction_id) {
80 if (database_backend_) 80 if (database_backend_.get())
81 database_backend_->Abort(transaction_id); 81 database_backend_->Abort(transaction_id);
82 } 82 }
83 83
84 void WebIDBDatabaseImpl::abort(long long transaction_id, 84 void WebIDBDatabaseImpl::abort(long long transaction_id,
85 const WebIDBDatabaseError& error) { 85 const WebIDBDatabaseError& error) {
86 if (database_backend_) 86 if (database_backend_.get())
87 database_backend_->Abort(transaction_id, IndexedDBDatabaseError(error)); 87 database_backend_->Abort(transaction_id, IndexedDBDatabaseError(error));
88 } 88 }
89 89
90 void WebIDBDatabaseImpl::commit(long long transaction_id) { 90 void WebIDBDatabaseImpl::commit(long long transaction_id) {
91 if (database_backend_) 91 if (database_backend_.get())
92 database_backend_->Commit(transaction_id); 92 database_backend_->Commit(transaction_id);
93 } 93 }
94 94
95 void WebIDBDatabaseImpl::openCursor(long long transaction_id, 95 void WebIDBDatabaseImpl::openCursor(long long transaction_id,
96 long long object_store_id, 96 long long object_store_id,
97 long long index_id, 97 long long index_id,
98 const IndexedDBKeyRange& key_range, 98 const IndexedDBKeyRange& key_range,
99 unsigned short direction, 99 unsigned short direction,
100 bool key_only, 100 bool key_only,
101 WebKit::WebIDBDatabase::TaskType task_type, 101 WebKit::WebIDBDatabase::TaskType task_type,
102 IndexedDBCallbacksBase* callbacks) { 102 IndexedDBCallbacksBase* callbacks) {
103 if (database_backend_) 103 if (database_backend_.get())
104 database_backend_->OpenCursor( 104 database_backend_->OpenCursor(
105 transaction_id, 105 transaction_id,
106 object_store_id, 106 object_store_id,
107 index_id, 107 index_id,
108 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 108 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
109 static_cast<indexed_db::CursorDirection>(direction), 109 static_cast<indexed_db::CursorDirection>(direction),
110 key_only, 110 key_only,
111 static_cast<IndexedDBDatabase::TaskType>(task_type), 111 static_cast<IndexedDBDatabase::TaskType>(task_type),
112 IndexedDBCallbacksWrapper::Create(callbacks)); 112 IndexedDBCallbacksWrapper::Create(callbacks));
113 } 113 }
114 114
115 void WebIDBDatabaseImpl::count(long long transaction_id, 115 void WebIDBDatabaseImpl::count(long long transaction_id,
116 long long object_store_id, 116 long long object_store_id,
117 long long index_id, 117 long long index_id,
118 const IndexedDBKeyRange& key_range, 118 const IndexedDBKeyRange& key_range,
119 IndexedDBCallbacksBase* callbacks) { 119 IndexedDBCallbacksBase* callbacks) {
120 if (database_backend_) 120 if (database_backend_.get())
121 database_backend_->Count(transaction_id, 121 database_backend_->Count(transaction_id,
122 object_store_id, 122 object_store_id,
123 index_id, 123 index_id,
124 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 124 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
125 IndexedDBCallbacksWrapper::Create(callbacks)); 125 IndexedDBCallbacksWrapper::Create(callbacks));
126 } 126 }
127 127
128 void WebIDBDatabaseImpl::get(long long transaction_id, 128 void WebIDBDatabaseImpl::get(long long transaction_id,
129 long long object_store_id, 129 long long object_store_id,
130 long long index_id, 130 long long index_id,
131 const IndexedDBKeyRange& key_range, 131 const IndexedDBKeyRange& key_range,
132 bool key_only, 132 bool key_only,
133 IndexedDBCallbacksBase* callbacks) { 133 IndexedDBCallbacksBase* callbacks) {
134 if (database_backend_) 134 if (database_backend_.get())
135 database_backend_->Get(transaction_id, 135 database_backend_->Get(transaction_id,
136 object_store_id, 136 object_store_id,
137 index_id, 137 index_id,
138 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 138 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
139 key_only, 139 key_only,
140 IndexedDBCallbacksWrapper::Create(callbacks)); 140 IndexedDBCallbacksWrapper::Create(callbacks));
141 } 141 }
142 142
143 void WebIDBDatabaseImpl::put(long long transaction_id, 143 void WebIDBDatabaseImpl::put(long long transaction_id,
144 long long object_store_id, 144 long long object_store_id,
145 std::vector<char>* value, 145 std::vector<char>* value,
146 const IndexedDBKey& key, 146 const IndexedDBKey& key,
147 WebKit::WebIDBDatabase::PutMode put_mode, 147 WebKit::WebIDBDatabase::PutMode put_mode,
148 IndexedDBCallbacksBase* callbacks, 148 IndexedDBCallbacksBase* callbacks,
149 const std::vector<int64>& index_ids, 149 const std::vector<int64>& index_ids,
150 const std::vector<IndexKeys>& index_keys) { 150 const std::vector<IndexKeys>& index_keys) {
151 if (!database_backend_) 151 if (!database_backend_.get())
152 return; 152 return;
153 153
154 DCHECK_EQ(index_ids.size(), index_keys.size()); 154 DCHECK_EQ(index_ids.size(), index_keys.size());
155 155
156 database_backend_->Put(transaction_id, 156 database_backend_->Put(transaction_id,
157 object_store_id, 157 object_store_id,
158 value, 158 value,
159 make_scoped_ptr(new IndexedDBKey(key)), 159 make_scoped_ptr(new IndexedDBKey(key)),
160 static_cast<IndexedDBDatabase::PutMode>(put_mode), 160 static_cast<IndexedDBDatabase::PutMode>(put_mode),
161 IndexedDBCallbacksWrapper::Create(callbacks), 161 IndexedDBCallbacksWrapper::Create(callbacks),
162 index_ids, 162 index_ids,
163 index_keys); 163 index_keys);
164 } 164 }
165 165
166 void WebIDBDatabaseImpl::setIndexKeys( 166 void WebIDBDatabaseImpl::setIndexKeys(
167 long long transaction_id, 167 long long transaction_id,
168 long long object_store_id, 168 long long object_store_id,
169 const IndexedDBKey& primary_key, 169 const IndexedDBKey& primary_key,
170 const std::vector<int64>& index_ids, 170 const std::vector<int64>& index_ids,
171 const std::vector<IndexKeys>& index_keys) { 171 const std::vector<IndexKeys>& index_keys) {
172 if (!database_backend_) 172 if (!database_backend_.get())
173 return; 173 return;
174 174
175 DCHECK_EQ(index_ids.size(), index_keys.size()); 175 DCHECK_EQ(index_ids.size(), index_keys.size());
176 database_backend_->SetIndexKeys( 176 database_backend_->SetIndexKeys(
177 transaction_id, 177 transaction_id,
178 object_store_id, 178 object_store_id,
179 make_scoped_ptr(new IndexedDBKey(primary_key)), 179 make_scoped_ptr(new IndexedDBKey(primary_key)),
180 index_ids, 180 index_ids,
181 index_keys); 181 index_keys);
182 } 182 }
183 183
184 void WebIDBDatabaseImpl::setIndexesReady( 184 void WebIDBDatabaseImpl::setIndexesReady(
185 long long transaction_id, 185 long long transaction_id,
186 long long object_store_id, 186 long long object_store_id,
187 const std::vector<int64>& web_index_ids) { 187 const std::vector<int64>& web_index_ids) {
188 if (!database_backend_) 188 if (!database_backend_.get())
189 return; 189 return;
190 190
191 std::vector<int64> index_ids(web_index_ids.size()); 191 std::vector<int64> index_ids(web_index_ids.size());
192 for (size_t i = 0; i < web_index_ids.size(); ++i) 192 for (size_t i = 0; i < web_index_ids.size(); ++i)
193 index_ids[i] = web_index_ids[i]; 193 index_ids[i] = web_index_ids[i];
194 database_backend_->SetIndexesReady( 194 database_backend_->SetIndexesReady(
195 transaction_id, object_store_id, index_ids); 195 transaction_id, object_store_id, index_ids);
196 } 196 }
197 197
198 void WebIDBDatabaseImpl::deleteRange(long long transaction_id, 198 void WebIDBDatabaseImpl::deleteRange(long long transaction_id,
199 long long object_store_id, 199 long long object_store_id,
200 const IndexedDBKeyRange& key_range, 200 const IndexedDBKeyRange& key_range,
201 IndexedDBCallbacksBase* callbacks) { 201 IndexedDBCallbacksBase* callbacks) {
202 if (database_backend_) 202 if (database_backend_.get())
203 database_backend_->DeleteRange( 203 database_backend_->DeleteRange(
204 transaction_id, 204 transaction_id,
205 object_store_id, 205 object_store_id,
206 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 206 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
207 IndexedDBCallbacksWrapper::Create(callbacks)); 207 IndexedDBCallbacksWrapper::Create(callbacks));
208 } 208 }
209 209
210 void WebIDBDatabaseImpl::clear(long long transaction_id, 210 void WebIDBDatabaseImpl::clear(long long transaction_id,
211 long long object_store_id, 211 long long object_store_id,
212 IndexedDBCallbacksBase* callbacks) { 212 IndexedDBCallbacksBase* callbacks) {
213 if (database_backend_) 213 if (database_backend_.get())
214 database_backend_->Clear(transaction_id, 214 database_backend_->Clear(transaction_id,
215 object_store_id, 215 object_store_id,
216 IndexedDBCallbacksWrapper::Create(callbacks)); 216 IndexedDBCallbacksWrapper::Create(callbacks));
217 } 217 }
218 218
219 void WebIDBDatabaseImpl::createIndex(long long transaction_id, 219 void WebIDBDatabaseImpl::createIndex(long long transaction_id,
220 long long object_store_id, 220 long long object_store_id,
221 long long index_id, 221 long long index_id,
222 const WebString& name, 222 const WebString& name,
223 const IndexedDBKeyPath& key_path, 223 const IndexedDBKeyPath& key_path,
224 bool unique, 224 bool unique,
225 bool multi_entry) { 225 bool multi_entry) {
226 if (database_backend_) 226 if (database_backend_.get())
227 database_backend_->CreateIndex(transaction_id, 227 database_backend_->CreateIndex(transaction_id,
228 object_store_id, 228 object_store_id,
229 index_id, 229 index_id,
230 name, 230 name,
231 IndexedDBKeyPath(key_path), 231 IndexedDBKeyPath(key_path),
232 unique, 232 unique,
233 multi_entry); 233 multi_entry);
234 } 234 }
235 235
236 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, 236 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id,
237 long long object_store_id, 237 long long object_store_id,
238 long long index_id) { 238 long long index_id) {
239 if (database_backend_) 239 if (database_backend_.get())
240 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); 240 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id);
241 } 241 }
242 242
243 } // namespace WebKit 243 } // namespace WebKit
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction.cc ('k') | content/browser/loader/redirect_to_file_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698