blob: 1837e2f103725233f8838c3ab3b64551bed0d4e2 [file] [log] [blame]
[email protected]9b8aa5b2011-08-22 18:15:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]5196b0cd2010-08-11 09:03:522// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]acb94722011-03-18 01:33:345#include "content/renderer/renderer_webidbcursor_impl.h"
[email protected]5196b0cd2010-08-11 09:03:526
[email protected]127dd582011-03-16 21:32:107#include "content/common/indexed_db_messages.h"
[email protected]230b7ef2011-03-16 22:30:198#include "content/renderer/indexed_db_dispatcher.h"
[email protected]f1a29a02011-10-06 23:08:449#include "content/renderer/render_thread_impl.h"
[email protected]5196b0cd2010-08-11 09:03:5210
[email protected]fb033cdc2010-10-13 07:19:4211using WebKit::WebExceptionCode;
[email protected]5196b0cd2010-08-11 09:03:5212using WebKit::WebIDBCallbacks;
13using WebKit::WebIDBKey;
14using WebKit::WebSerializedScriptValue;
15
[email protected]c97dd2f2011-10-12 05:23:4016RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id,
17 const IndexedDBKey& key, const IndexedDBKey& primary_key,
18 const SerializedScriptValue& value)
19 : idb_cursor_id_(idb_cursor_id),
20 key_(key),
21 primary_key_(primary_key),
22 value_(value) {
[email protected]5196b0cd2010-08-11 09:03:5223}
24
25RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
[email protected]21f69942011-01-12 10:40:2126 // It's not possible for there to be pending callbacks that address this
27 // object since inside WebKit, they hold a reference to the object wich owns
28 // this object. But, if that ever changed, then we'd need to invalidate
29 // any such pointers.
[email protected]f1a29a02011-10-06 23:08:4430 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_CursorDestroyed(
[email protected]5196b0cd2010-08-11 09:03:5231 idb_cursor_id_));
32}
33
34unsigned short RendererWebIDBCursorImpl::direction() const {
35 int direction;
[email protected]f1a29a02011-10-06 23:08:4436 RenderThreadImpl::current()->Send(
[email protected]2ba871b2010-12-13 21:11:0037 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction));
[email protected]5196b0cd2010-08-11 09:03:5238 return direction;
39}
40
41WebIDBKey RendererWebIDBCursorImpl::key() const {
[email protected]c97dd2f2011-10-12 05:23:4042 return key_;
[email protected]5196b0cd2010-08-11 09:03:5243}
44
[email protected]849991d2011-03-02 22:18:4545WebIDBKey RendererWebIDBCursorImpl::primaryKey() const {
[email protected]c97dd2f2011-10-12 05:23:4046 return primary_key_;
[email protected]849991d2011-03-02 22:18:4547}
48
[email protected]9b8aa5b2011-08-22 18:15:1549WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
[email protected]c97dd2f2011-10-12 05:23:4050 return value_;
[email protected]5196b0cd2010-08-11 09:03:5251}
52
53void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
[email protected]fb033cdc2010-10-13 07:19:4254 WebIDBCallbacks* callbacks,
55 WebExceptionCode& ec) {
[email protected]1e2de552010-09-03 12:15:1556 IndexedDBDispatcher* dispatcher =
[email protected]f1a29a02011-10-06 23:08:4457 RenderThreadImpl::current()->indexed_db_dispatcher();
[email protected]fb033cdc2010-10-13 07:19:4258 dispatcher->RequestIDBCursorUpdate(SerializedScriptValue(value), callbacks,
59 idb_cursor_id_, &ec);
[email protected]5196b0cd2010-08-11 09:03:5260}
61
62void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
[email protected]fb033cdc2010-10-13 07:19:4263 WebIDBCallbacks* callbacks,
64 WebExceptionCode& ec) {
[email protected]1e2de552010-09-03 12:15:1565 IndexedDBDispatcher* dispatcher =
[email protected]f1a29a02011-10-06 23:08:4466 RenderThreadImpl::current()->indexed_db_dispatcher();
[email protected]fb033cdc2010-10-13 07:19:4267 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks,
68 idb_cursor_id_, &ec);
[email protected]5196b0cd2010-08-11 09:03:5269}
70
[email protected]9b8aa5b2011-08-22 18:15:1571void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks,
72 WebExceptionCode& ec) {
[email protected]1e2de552010-09-03 12:15:1573 IndexedDBDispatcher* dispatcher =
[email protected]f1a29a02011-10-06 23:08:4474 RenderThreadImpl::current()->indexed_db_dispatcher();
[email protected]6454c0b2010-12-03 15:22:5075 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
[email protected]5196b0cd2010-08-11 09:03:5276}