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