OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/indexed_db/proxy_webidbdatabase_impl.h" | 5 #include "content/common/indexed_db/proxy_webidbdatabase_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
10 #include "content/common/indexed_db/indexed_db_messages.h" | 10 #include "content/common/indexed_db/indexed_db_messages.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return NULL; | 144 return NULL; |
145 return new RendererWebIDBTransactionImpl(ipc_transaction_id); | 145 return new RendererWebIDBTransactionImpl(ipc_transaction_id); |
146 } | 146 } |
147 | 147 |
148 void RendererWebIDBDatabaseImpl::close() { | 148 void RendererWebIDBDatabaseImpl::close() { |
149 IndexedDBDispatcher* dispatcher = | 149 IndexedDBDispatcher* dispatcher = |
150 IndexedDBDispatcher::ThreadSpecificInstance(); | 150 IndexedDBDispatcher::ThreadSpecificInstance(); |
151 dispatcher->RequestIDBDatabaseClose(ipc_database_id_); | 151 dispatcher->RequestIDBDatabaseClose(ipc_database_id_); |
152 } | 152 } |
153 | 153 |
| 154 void RendererWebIDBDatabaseImpl::get( |
| 155 long long transaction_id, |
| 156 long long object_store_id, |
| 157 long long index_id, |
| 158 const WebKit::WebIDBKeyRange& key_range, |
| 159 bool key_only, |
| 160 WebIDBCallbacks* callbacks) { |
| 161 IndexedDBDispatcher* dispatcher = |
| 162 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 163 dispatcher->RequestIDBDatabaseGet( |
| 164 ipc_database_id_, transaction_id, object_store_id, index_id, |
| 165 IndexedDBKeyRange(key_range), key_only, callbacks); |
| 166 } |
| 167 |
| 168 void RendererWebIDBDatabaseImpl::put( |
| 169 long long transaction_id, |
| 170 long long object_store_id, |
| 171 WebVector<unsigned char>* value, |
| 172 const WebKit::WebIDBKey& key, |
| 173 PutMode put_mode, |
| 174 WebIDBCallbacks* callbacks, |
| 175 const WebVector<long long>& web_index_ids, |
| 176 const WebVector<WebIndexKeys>& web_index_keys) { |
| 177 IndexedDBDispatcher* dispatcher = |
| 178 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 179 dispatcher->RequestIDBDatabasePut( |
| 180 ipc_database_id_, transaction_id, object_store_id, |
| 181 value, IndexedDBKey(key), put_mode, callbacks, |
| 182 web_index_ids, web_index_keys); |
| 183 } |
| 184 |
| 185 void RendererWebIDBDatabaseImpl::setIndexKeys( |
| 186 long long transaction_id, |
| 187 long long object_store_id, |
| 188 const WebKit::WebIDBKey& primary_key, |
| 189 const WebVector<long long>& index_ids, |
| 190 const WebVector<WebIndexKeys>& index_keys) { |
| 191 IndexedDBHostMsg_DatabaseSetIndexKeys_Params params; |
| 192 params.ipc_database_id = ipc_database_id_; |
| 193 params.transaction_id = transaction_id; |
| 194 params.object_store_id = object_store_id; |
| 195 params.primary_key = IndexedDBKey(primary_key); |
| 196 COMPILE_ASSERT(sizeof(params.index_ids[0]) == |
| 197 sizeof(index_ids[0]), Cant_copy); |
| 198 params.index_ids.assign(index_ids.data(), |
| 199 index_ids.data() + index_ids.size()); |
| 200 |
| 201 params.index_keys.resize(index_keys.size()); |
| 202 for (size_t i = 0; i < index_keys.size(); ++i) { |
| 203 params.index_keys[i].resize(index_keys[i].size()); |
| 204 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
| 205 params.index_keys[i][j] = content::IndexedDBKey(index_keys[i][j]); |
| 206 } |
| 207 } |
| 208 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseSetIndexKeys( |
| 209 params)); |
| 210 } |
| 211 |
| 212 void RendererWebIDBDatabaseImpl::setIndexesReady( |
| 213 long long transaction_id, |
| 214 long long object_store_id, |
| 215 const WebVector<long long>& web_index_ids) { |
| 216 std::vector<int64> index_ids(web_index_ids.data(), |
| 217 web_index_ids.data() + web_index_ids.size()); |
| 218 IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseSetIndexesReady( |
| 219 ipc_database_id_, transaction_id, object_store_id, index_ids)); |
| 220 } |
| 221 |
| 222 void RendererWebIDBDatabaseImpl::openCursor( |
| 223 long long transaction_id, |
| 224 long long object_store_id, |
| 225 long long index_id, |
| 226 const WebKit::WebIDBKeyRange& key_range, |
| 227 unsigned short direction, |
| 228 bool key_only, |
| 229 TaskType task_type, |
| 230 WebIDBCallbacks* callbacks) { |
| 231 IndexedDBDispatcher* dispatcher = |
| 232 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 233 dispatcher->RequestIDBDatabaseOpenCursor( |
| 234 ipc_database_id_, |
| 235 transaction_id, object_store_id, index_id, |
| 236 IndexedDBKeyRange(key_range), direction, key_only, task_type, callbacks); |
| 237 } |
| 238 |
| 239 void RendererWebIDBDatabaseImpl::count( |
| 240 long long transaction_id, |
| 241 long long object_store_id, |
| 242 long long index_id, |
| 243 const WebKit::WebIDBKeyRange& key_range, |
| 244 WebIDBCallbacks* callbacks) { |
| 245 IndexedDBDispatcher* dispatcher = |
| 246 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 247 dispatcher->RequestIDBDatabaseCount( |
| 248 ipc_database_id_, |
| 249 transaction_id, object_store_id, index_id, |
| 250 IndexedDBKeyRange(key_range), callbacks); |
| 251 } |
| 252 |
| 253 void RendererWebIDBDatabaseImpl::deleteRange( |
| 254 long long transaction_id, |
| 255 long long object_store_id, |
| 256 const WebKit::WebIDBKeyRange& key_range, |
| 257 WebIDBCallbacks* callbacks) { |
| 258 IndexedDBDispatcher* dispatcher = |
| 259 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 260 dispatcher->RequestIDBDatabaseDeleteRange( |
| 261 ipc_database_id_, |
| 262 transaction_id, object_store_id, |
| 263 IndexedDBKeyRange(key_range), callbacks); |
| 264 } |
| 265 |
| 266 void RendererWebIDBDatabaseImpl::clear( |
| 267 long long transaction_id, |
| 268 long long object_store_id, |
| 269 WebIDBCallbacks* callbacks) { |
| 270 IndexedDBDispatcher* dispatcher = |
| 271 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 272 dispatcher->RequestIDBDatabaseClear( |
| 273 ipc_database_id_, |
| 274 transaction_id, object_store_id, callbacks); |
| 275 } |
154 } // namespace content | 276 } // namespace content |
OLD | NEW |