| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/renderer/renderer_webidbcursor_impl.h" | 5 #include "chrome/renderer/renderer_webidbcursor_impl.h" |
| 6 | 6 |
| 7 #include "chrome/common/indexed_db_key.h" | 7 #include "chrome/common/indexed_db_messages.h" |
| 8 #include "chrome/common/render_messages.h" | |
| 9 #include "chrome/common/serialized_script_value.h" | |
| 10 #include "chrome/renderer/indexed_db_dispatcher.h" | 8 #include "chrome/renderer/indexed_db_dispatcher.h" |
| 11 #include "chrome/renderer/render_thread.h" | 9 #include "chrome/renderer/render_thread.h" |
| 12 | 10 |
| 13 using WebKit::WebExceptionCode; | 11 using WebKit::WebExceptionCode; |
| 14 using WebKit::WebIDBCallbacks; | 12 using WebKit::WebIDBCallbacks; |
| 15 using WebKit::WebIDBKey; | 13 using WebKit::WebIDBKey; |
| 16 using WebKit::WebSerializedScriptValue; | 14 using WebKit::WebSerializedScriptValue; |
| 17 | 15 |
| 18 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id) | 16 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id) |
| 19 : idb_cursor_id_(idb_cursor_id) { | 17 : idb_cursor_id_(idb_cursor_id) { |
| 20 } | 18 } |
| 21 | 19 |
| 22 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { | 20 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { |
| 23 RenderThread::current()->Send(new ViewHostMsg_IDBCursorDestroyed( | 21 RenderThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed( |
| 24 idb_cursor_id_)); | 22 idb_cursor_id_)); |
| 25 } | 23 } |
| 26 | 24 |
| 27 unsigned short RendererWebIDBCursorImpl::direction() const { | 25 unsigned short RendererWebIDBCursorImpl::direction() const { |
| 28 int direction; | 26 int direction; |
| 29 RenderThread::current()->Send( | 27 RenderThread::current()->Send( |
| 30 new ViewHostMsg_IDBCursorDirection(idb_cursor_id_, &direction)); | 28 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); |
| 31 return direction; | 29 return direction; |
| 32 } | 30 } |
| 33 | 31 |
| 34 WebIDBKey RendererWebIDBCursorImpl::key() const { | 32 WebIDBKey RendererWebIDBCursorImpl::key() const { |
| 35 IndexedDBKey key; | 33 IndexedDBKey key; |
| 36 RenderThread::current()->Send( | 34 RenderThread::current()->Send( |
| 37 new ViewHostMsg_IDBCursorKey(idb_cursor_id_, &key)); | 35 new IndexedDBHostMsg_CursorKey(idb_cursor_id_, &key)); |
| 38 return key; | 36 return key; |
| 39 } | 37 } |
| 40 | 38 |
| 41 void RendererWebIDBCursorImpl::value( | 39 void RendererWebIDBCursorImpl::value( |
| 42 WebSerializedScriptValue& webScriptValue, | 40 WebSerializedScriptValue& webScriptValue, |
| 43 WebIDBKey& webKey) const { | 41 WebIDBKey& webKey) const { |
| 44 SerializedScriptValue scriptValue; | 42 SerializedScriptValue scriptValue; |
| 45 IndexedDBKey key; | 43 IndexedDBKey key; |
| 46 RenderThread::current()->Send( | 44 RenderThread::current()->Send( |
| 47 new ViewHostMsg_IDBCursorValue(idb_cursor_id_, &scriptValue, | 45 new IndexedDBHostMsg_CursorValue(idb_cursor_id_, &scriptValue, |
| 48 &key)); | 46 &key)); |
| 49 // Only one or the other type should have been "returned" to us. | 47 // Only one or the other type should have been "returned" to us. |
| 50 DCHECK(scriptValue.is_null() != (key.type() == WebIDBKey::InvalidType)); | 48 DCHECK(scriptValue.is_null() != (key.type() == WebIDBKey::InvalidType)); |
| 51 webScriptValue = scriptValue; | 49 webScriptValue = scriptValue; |
| 52 webKey = key; | 50 webKey = key; |
| 53 } | 51 } |
| 54 | 52 |
| 55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, | 53 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, |
| 56 WebIDBCallbacks* callbacks, | 54 WebIDBCallbacks* callbacks, |
| 57 WebExceptionCode& ec) { | 55 WebExceptionCode& ec) { |
| 58 IndexedDBDispatcher* dispatcher = | 56 IndexedDBDispatcher* dispatcher = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, | 67 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, |
| 70 idb_cursor_id_, &ec); | 68 idb_cursor_id_, &ec); |
| 71 } | 69 } |
| 72 | 70 |
| 73 void RendererWebIDBCursorImpl::remove(WebIDBCallbacks* callbacks, | 71 void RendererWebIDBCursorImpl::remove(WebIDBCallbacks* callbacks, |
| 74 WebExceptionCode& ec) { | 72 WebExceptionCode& ec) { |
| 75 IndexedDBDispatcher* dispatcher = | 73 IndexedDBDispatcher* dispatcher = |
| 76 RenderThread::current()->indexed_db_dispatcher(); | 74 RenderThread::current()->indexed_db_dispatcher(); |
| 77 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); | 75 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); |
| 78 } | 76 } |
| OLD | NEW |