| 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/renderer_webidbcursor_impl.h" | 5 #include "content/renderer/renderer_webidbcursor_impl.h" |
| 6 | 6 |
| 7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
| 8 #include "content/renderer/indexed_db_dispatcher.h" | 8 #include "content/renderer/indexed_db_dispatcher.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
| 10 | 10 |
| 11 using WebKit::WebExceptionCode; | 11 using WebKit::WebExceptionCode; |
| 12 using WebKit::WebIDBCallbacks; | 12 using WebKit::WebIDBCallbacks; |
| 13 using WebKit::WebIDBKey; | 13 using WebKit::WebIDBKey; |
| 14 using WebKit::WebSerializedScriptValue; | 14 using WebKit::WebSerializedScriptValue; |
| 15 | 15 |
| 16 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id) | 16 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id, |
| 17 : idb_cursor_id_(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) { |
| 18 } | 23 } |
| 19 | 24 |
| 20 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { | 25 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { |
| 21 // It's not possible for there to be pending callbacks that address this | 26 // 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 | 27 // 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 | 28 // this object. But, if that ever changed, then we'd need to invalidate |
| 24 // any such pointers. | 29 // any such pointers. |
| 25 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_CursorDestroyed( | 30 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_CursorDestroyed( |
| 26 idb_cursor_id_)); | 31 idb_cursor_id_)); |
| 27 } | 32 } |
| 28 | 33 |
| 29 unsigned short RendererWebIDBCursorImpl::direction() const { | 34 unsigned short RendererWebIDBCursorImpl::direction() const { |
| 30 int direction; | 35 int direction; |
| 31 RenderThreadImpl::current()->Send( | 36 RenderThreadImpl::current()->Send( |
| 32 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); | 37 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); |
| 33 return direction; | 38 return direction; |
| 34 } | 39 } |
| 35 | 40 |
| 36 WebIDBKey RendererWebIDBCursorImpl::key() const { | 41 WebIDBKey RendererWebIDBCursorImpl::key() const { |
| 37 IndexedDBKey key; | 42 return key_; |
| 38 RenderThreadImpl::current()->Send( | |
| 39 new IndexedDBHostMsg_CursorKey(idb_cursor_id_, &key)); | |
| 40 return key; | |
| 41 } | 43 } |
| 42 | 44 |
| 43 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { | 45 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { |
| 44 IndexedDBKey primaryKey; | 46 return primary_key_; |
| 45 RenderThreadImpl::current()->Send( | |
| 46 new IndexedDBHostMsg_CursorPrimaryKey(idb_cursor_id_, &primaryKey)); | |
| 47 return primaryKey; | |
| 48 } | 47 } |
| 49 | 48 |
| 50 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { | 49 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { |
| 51 SerializedScriptValue scriptValue; | 50 return value_; |
| 52 RenderThreadImpl::current()->Send( | |
| 53 new IndexedDBHostMsg_CursorValue(idb_cursor_id_, &scriptValue)); | |
| 54 return scriptValue; | |
| 55 } | 51 } |
| 56 | 52 |
| 57 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, | 53 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, |
| 58 WebIDBCallbacks* callbacks, | 54 WebIDBCallbacks* callbacks, |
| 59 WebExceptionCode& ec) { | 55 WebExceptionCode& ec) { |
| 60 IndexedDBDispatcher* dispatcher = | 56 IndexedDBDispatcher* dispatcher = |
| 61 RenderThreadImpl::current()->indexed_db_dispatcher(); | 57 RenderThreadImpl::current()->indexed_db_dispatcher(); |
| 62 dispatcher->RequestIDBCursorUpdate(SerializedScriptValue(value), callbacks, | 58 dispatcher->RequestIDBCursorUpdate(SerializedScriptValue(value), callbacks, |
| 63 idb_cursor_id_, &ec); | 59 idb_cursor_id_, &ec); |
| 64 } | 60 } |
| 65 | 61 |
| 66 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, | 62 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, |
| 67 WebIDBCallbacks* callbacks, | 63 WebIDBCallbacks* callbacks, |
| 68 WebExceptionCode& ec) { | 64 WebExceptionCode& ec) { |
| 69 IndexedDBDispatcher* dispatcher = | 65 IndexedDBDispatcher* dispatcher = |
| 70 RenderThreadImpl::current()->indexed_db_dispatcher(); | 66 RenderThreadImpl::current()->indexed_db_dispatcher(); |
| 71 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, | 67 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, |
| 72 idb_cursor_id_, &ec); | 68 idb_cursor_id_, &ec); |
| 73 } | 69 } |
| 74 | 70 |
| 75 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, | 71 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, |
| 76 WebExceptionCode& ec) { | 72 WebExceptionCode& ec) { |
| 77 IndexedDBDispatcher* dispatcher = | 73 IndexedDBDispatcher* dispatcher = |
| 78 RenderThreadImpl::current()->indexed_db_dispatcher(); | 74 RenderThreadImpl::current()->indexed_db_dispatcher(); |
| 79 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); | 75 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); |
| 80 } | 76 } |
| OLD | NEW |