OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/indexed_db_dispatcher.h" | 5 #include "content/renderer/indexed_db_dispatcher.h" |
6 | 6 |
7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
10 #include "content/renderer/renderer_webidbcursor_impl.h" | 10 #include "content/renderer/renderer_webidbcursor_impl.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 params.lower_open = idb_key_range.lowerOpen(); | 270 params.lower_open = idb_key_range.lowerOpen(); |
271 params.upper_open = idb_key_range.upperOpen(); | 271 params.upper_open = idb_key_range.upperOpen(); |
272 params.direction = direction; | 272 params.direction = direction; |
273 params.idb_index_id = idb_index_id; | 273 params.idb_index_id = idb_index_id; |
274 params.transaction_id = TransactionId(transaction); | 274 params.transaction_id = TransactionId(transaction); |
275 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); | 275 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); |
276 if (*ec) | 276 if (*ec) |
277 pending_callbacks_.Remove(params.response_id); | 277 pending_callbacks_.Remove(params.response_id); |
278 } | 278 } |
279 | 279 |
| 280 void IndexedDBDispatcher::RequestIDBIndexCount( |
| 281 const WebIDBKeyRange& idb_key_range, |
| 282 WebIDBCallbacks* callbacks_ptr, |
| 283 int32 idb_index_id, |
| 284 const WebIDBTransaction& transaction, |
| 285 WebExceptionCode* ec) { |
| 286 ResetCursorPrefetchCaches(); |
| 287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 288 IndexedDBHostMsg_IndexCount_Params params; |
| 289 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 290 params.lower_key.Set(idb_key_range.lower()); |
| 291 params.upper_key.Set(idb_key_range.upper()); |
| 292 params.lower_open = idb_key_range.lowerOpen(); |
| 293 params.upper_open = idb_key_range.upperOpen(); |
| 294 params.idb_index_id = idb_index_id; |
| 295 params.transaction_id = TransactionId(transaction); |
| 296 Send(new IndexedDBHostMsg_IndexCount(params, ec)); |
| 297 if (*ec) |
| 298 pending_callbacks_.Remove(params.response_id); |
| 299 } |
| 300 |
280 void IndexedDBDispatcher::RequestIDBIndexGetObject( | 301 void IndexedDBDispatcher::RequestIDBIndexGetObject( |
281 const IndexedDBKey& key, | 302 const IndexedDBKey& key, |
282 WebIDBCallbacks* callbacks_ptr, | 303 WebIDBCallbacks* callbacks_ptr, |
283 int32 idb_index_id, | 304 int32 idb_index_id, |
284 const WebIDBTransaction& transaction, | 305 const WebIDBTransaction& transaction, |
285 WebExceptionCode* ec) { | 306 WebExceptionCode* ec) { |
286 ResetCursorPrefetchCaches(); | 307 ResetCursorPrefetchCaches(); |
287 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 308 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
288 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 309 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
289 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, | 310 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 params.lower_open = idb_key_range.lowerOpen(); | 415 params.lower_open = idb_key_range.lowerOpen(); |
395 params.upper_open = idb_key_range.upperOpen(); | 416 params.upper_open = idb_key_range.upperOpen(); |
396 params.direction = direction; | 417 params.direction = direction; |
397 params.idb_object_store_id = idb_object_store_id; | 418 params.idb_object_store_id = idb_object_store_id; |
398 params.transaction_id = TransactionId(transaction); | 419 params.transaction_id = TransactionId(transaction); |
399 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); | 420 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); |
400 if (*ec) | 421 if (*ec) |
401 pending_callbacks_.Remove(params.response_id); | 422 pending_callbacks_.Remove(params.response_id); |
402 } | 423 } |
403 | 424 |
| 425 void IndexedDBDispatcher::RequestIDBObjectStoreCount( |
| 426 const WebIDBKeyRange& idb_key_range, |
| 427 WebIDBCallbacks* callbacks_ptr, |
| 428 int32 idb_object_store_id, |
| 429 const WebIDBTransaction& transaction, |
| 430 WebExceptionCode* ec) { |
| 431 ResetCursorPrefetchCaches(); |
| 432 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 433 IndexedDBHostMsg_ObjectStoreCount_Params params; |
| 434 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 435 params.lower_key.Set(idb_key_range.lower()); |
| 436 params.upper_key.Set(idb_key_range.upper()); |
| 437 params.lower_open = idb_key_range.lowerOpen(); |
| 438 params.upper_open = idb_key_range.upperOpen(); |
| 439 params.idb_object_store_id = idb_object_store_id; |
| 440 params.transaction_id = TransactionId(transaction); |
| 441 Send(new IndexedDBHostMsg_ObjectStoreCount(params, ec)); |
| 442 if (*ec) |
| 443 pending_callbacks_.Remove(params.response_id); |
| 444 } |
| 445 |
404 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( | 446 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( |
405 WebIDBTransactionCallbacks* callbacks, | 447 WebIDBTransactionCallbacks* callbacks, |
406 int32 id) { | 448 int32 id) { |
407 pending_transaction_callbacks_.AddWithID(callbacks, id); | 449 pending_transaction_callbacks_.AddWithID(callbacks, id); |
408 } | 450 } |
409 | 451 |
410 void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) { | 452 void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) { |
411 cursors_.erase(cursor_id); | 453 cursors_.erase(cursor_id); |
412 } | 454 } |
413 | 455 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 602 } |
561 | 603 |
562 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 604 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
563 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 605 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
564 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 606 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
565 if (i->first == exception_cursor_id) | 607 if (i->first == exception_cursor_id) |
566 continue; | 608 continue; |
567 i->second->ResetPrefetchCache(); | 609 i->second->ResetPrefetchCache(); |
568 } | 610 } |
569 } | 611 } |
OLD | NEW |