OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/renderer/renderer_webidbcursor_impl.h" | |
6 | |
7 #include "chrome/renderer/render_thread.h" | |
8 #include "content/common/indexed_db_messages.h" | |
9 #include "content/renderer/indexed_db_dispatcher.h" | |
10 | |
11 using WebKit::WebExceptionCode; | |
12 using WebKit::WebIDBCallbacks; | |
13 using WebKit::WebIDBKey; | |
14 using WebKit::WebSerializedScriptValue; | |
15 | |
16 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id) | |
17 : idb_cursor_id_(idb_cursor_id) { | |
18 } | |
19 | |
20 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { | |
21 // It's not possible for there to be pending callbacks that address this | |
22 // object since inside WebKit, they hold a reference to the object wich owns | |
23 // this object. But, if that ever changed, then we'd need to invalidate | |
24 // any such pointers. | |
25 RenderThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed( | |
26 idb_cursor_id_)); | |
27 } | |
28 | |
29 unsigned short RendererWebIDBCursorImpl::direction() const { | |
30 int direction; | |
31 RenderThread::current()->Send( | |
32 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); | |
33 return direction; | |
34 } | |
35 | |
36 WebIDBKey RendererWebIDBCursorImpl::key() const { | |
37 IndexedDBKey key; | |
38 RenderThread::current()->Send( | |
39 new IndexedDBHostMsg_CursorKey(idb_cursor_id_, &key)); | |
40 return key; | |
41 } | |
42 | |
43 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { | |
44 IndexedDBKey primaryKey; | |
45 RenderThread::current()->Send( | |
46 new IndexedDBHostMsg_CursorPrimaryKey(idb_cursor_id_, &primaryKey)); | |
47 return primaryKey; | |
48 } | |
49 | |
50 void RendererWebIDBCursorImpl::value( | |
51 WebSerializedScriptValue& webScriptValue, | |
52 WebIDBKey& webKey) const { | |
53 SerializedScriptValue scriptValue; | |
54 IndexedDBKey key; | |
55 RenderThread::current()->Send( | |
56 new IndexedDBHostMsg_CursorValue(idb_cursor_id_, &scriptValue, | |
57 &key)); | |
58 // Only one or the other type should have been "returned" to us. | |
59 DCHECK(scriptValue.is_null() != (key.type() == WebIDBKey::InvalidType)); | |
60 webScriptValue = scriptValue; | |
61 webKey = key; | |
62 } | |
63 | |
64 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, | |
65 WebIDBCallbacks* callbacks, | |
66 WebExceptionCode& ec) { | |
67 IndexedDBDispatcher* dispatcher = | |
68 RenderThread::current()->indexed_db_dispatcher(); | |
69 dispatcher->RequestIDBCursorUpdate(SerializedScriptValue(value), callbacks, | |
70 idb_cursor_id_, &ec); | |
71 } | |
72 | |
73 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, | |
74 WebIDBCallbacks* callbacks, | |
75 WebExceptionCode& ec) { | |
76 IndexedDBDispatcher* dispatcher = | |
77 RenderThread::current()->indexed_db_dispatcher(); | |
78 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, | |
79 idb_cursor_id_, &ec); | |
80 } | |
81 | |
82 void RendererWebIDBCursorImpl::remove(WebIDBCallbacks* callbacks, | |
83 WebExceptionCode& ec) { | |
84 IndexedDBDispatcher* dispatcher = | |
85 RenderThread::current()->indexed_db_dispatcher(); | |
86 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); | |
87 } | |
OLD | NEW |