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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { | 24 RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { |
25 // It's not possible for there to be pending callbacks that address this | 25 // It's not possible for there to be pending callbacks that address this |
26 // object since inside WebKit, they hold a reference to the object wich owns | 26 // object since inside WebKit, they hold a reference to the object wich owns |
27 // this object. But, if that ever changed, then we'd need to invalidate | 27 // this object. But, if that ever changed, then we'd need to invalidate |
28 // any such pointers. | 28 // any such pointers. |
29 ChildThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed( | 29 ChildThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed( |
30 idb_cursor_id_)); | 30 idb_cursor_id_)); |
31 IndexedDBDispatcher* dispatcher = | 31 IndexedDBDispatcher* dispatcher = |
32 RenderThreadImpl::current()->indexed_db_dispatcher(); | 32 IndexedDBDispatcher::ThreadSpecificInstance(); |
33 dispatcher->CursorDestroyed(idb_cursor_id_); | 33 dispatcher->CursorDestroyed(idb_cursor_id_); |
34 } | 34 } |
35 | 35 |
36 unsigned short RendererWebIDBCursorImpl::direction() const { | 36 unsigned short RendererWebIDBCursorImpl::direction() const { |
37 int direction; | 37 int direction; |
38 ChildThread::current()->Send( | 38 ChildThread::current()->Send( |
39 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); | 39 new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction)); |
40 return direction; | 40 return direction; |
41 } | 41 } |
42 | 42 |
43 WebIDBKey RendererWebIDBCursorImpl::key() const { | 43 WebIDBKey RendererWebIDBCursorImpl::key() const { |
44 return key_; | 44 return key_; |
45 } | 45 } |
46 | 46 |
47 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { | 47 WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { |
48 return primary_key_; | 48 return primary_key_; |
49 } | 49 } |
50 | 50 |
51 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { | 51 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { |
52 return value_; | 52 return value_; |
53 } | 53 } |
54 | 54 |
55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, | 55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, |
56 WebIDBCallbacks* callbacks, | 56 WebIDBCallbacks* callbacks, |
57 WebExceptionCode& ec) { | 57 WebExceptionCode& ec) { |
58 IndexedDBDispatcher* dispatcher = | 58 IndexedDBDispatcher* dispatcher = |
59 RenderThreadImpl::current()->indexed_db_dispatcher(); | 59 IndexedDBDispatcher::ThreadSpecificInstance(); |
60 dispatcher->RequestIDBCursorUpdate( | 60 dispatcher->RequestIDBCursorUpdate( |
61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec); | 61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec); |
62 } | 62 } |
63 | 63 |
64 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, | 64 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, |
65 WebIDBCallbacks* callbacks, | 65 WebIDBCallbacks* callbacks, |
66 WebExceptionCode& ec) { | 66 WebExceptionCode& ec) { |
67 IndexedDBDispatcher* dispatcher = | 67 IndexedDBDispatcher* dispatcher = |
68 RenderThreadImpl::current()->indexed_db_dispatcher(); | 68 IndexedDBDispatcher::ThreadSpecificInstance(); |
69 | 69 |
70 if (key.type() == WebIDBKey::InvalidType) { | 70 if (key.type() == WebIDBKey::InvalidType) { |
71 // No key, so this would qualify for a prefetch. | 71 // No key, so this would qualify for a prefetch. |
72 ++continue_count_; | 72 ++continue_count_; |
73 | 73 |
74 if (!prefetch_keys_.empty()) { | 74 if (!prefetch_keys_.empty()) { |
75 // We have a prefetch cache, so serve the result from that. | 75 // We have a prefetch cache, so serve the result from that. |
76 CachedContinue(callbacks); | 76 CachedContinue(callbacks); |
77 return; | 77 return; |
78 } | 78 } |
(...skipping 15 matching lines...) Expand all Loading... |
94 ResetPrefetchCache(); | 94 ResetPrefetchCache(); |
95 } | 95 } |
96 | 96 |
97 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, | 97 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, |
98 idb_cursor_id_, &ec); | 98 idb_cursor_id_, &ec); |
99 } | 99 } |
100 | 100 |
101 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, | 101 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, |
102 WebExceptionCode& ec) { | 102 WebExceptionCode& ec) { |
103 IndexedDBDispatcher* dispatcher = | 103 IndexedDBDispatcher* dispatcher = |
104 RenderThreadImpl::current()->indexed_db_dispatcher(); | 104 IndexedDBDispatcher::ThreadSpecificInstance(); |
105 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); | 105 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); |
106 } | 106 } |
107 | 107 |
108 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() | 108 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() |
109 { | 109 { |
110 pending_onsuccess_callbacks_--; | 110 pending_onsuccess_callbacks_--; |
111 | 111 |
112 // If the onsuccess callback called continue() on the cursor again, | 112 // If the onsuccess callback called continue() on the cursor again, |
113 // and that continue was served by the prefetch cache, then | 113 // and that continue was served by the prefetch cache, then |
114 // pending_onsuccess_callbacks_ would be incremented. | 114 // pending_onsuccess_callbacks_ would be incremented. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void RendererWebIDBCursorImpl::ResetPrefetchCache() { | 162 void RendererWebIDBCursorImpl::ResetPrefetchCache() { |
163 continue_count_ = 0; | 163 continue_count_ = 0; |
164 prefetch_amount_ = kMinPrefetchAmount; | 164 prefetch_amount_ = kMinPrefetchAmount; |
165 | 165 |
166 if (!prefetch_keys_.size()) { | 166 if (!prefetch_keys_.size()) { |
167 // No prefetch cache, so no need to reset the cursor in the back-end. | 167 // No prefetch cache, so no need to reset the cursor in the back-end. |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 IndexedDBDispatcher* dispatcher = | 171 IndexedDBDispatcher* dispatcher = |
172 RenderThreadImpl::current()->indexed_db_dispatcher(); | 172 IndexedDBDispatcher::ThreadSpecificInstance(); |
173 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_, | 173 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_, |
174 prefetch_keys_.size(), | 174 prefetch_keys_.size(), |
175 idb_cursor_id_); | 175 idb_cursor_id_); |
176 prefetch_keys_.clear(); | 176 prefetch_keys_.clear(); |
177 prefetch_primary_keys_.clear(); | 177 prefetch_primary_keys_.clear(); |
178 prefetch_values_.clear(); | 178 prefetch_values_.clear(); |
179 | 179 |
180 pending_onsuccess_callbacks_ = 0; | 180 pending_onsuccess_callbacks_ = 0; |
181 } | 181 } |
OLD | NEW |