| 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/indexed_db_dispatcher.h" | 5 #include "content/renderer/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "content/common/indexed_db_messages.h" | 7 #include "content/common/indexed_db_messages.h" |
| 8 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
| 9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 10 #include "content/renderer/renderer_webidbcursor_impl.h" | 10 #include "content/renderer/renderer_webidbcursor_impl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using WebKit::WebExceptionCode; | 24 using WebKit::WebExceptionCode; |
| 25 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
| 26 using WebKit::WebIDBCallbacks; | 26 using WebKit::WebIDBCallbacks; |
| 27 using WebKit::WebIDBKeyRange; | 27 using WebKit::WebIDBKeyRange; |
| 28 using WebKit::WebIDBDatabase; | 28 using WebKit::WebIDBDatabase; |
| 29 using WebKit::WebIDBDatabaseCallbacks; | 29 using WebKit::WebIDBDatabaseCallbacks; |
| 30 using WebKit::WebIDBDatabaseError; | 30 using WebKit::WebIDBDatabaseError; |
| 31 using WebKit::WebIDBTransaction; | 31 using WebKit::WebIDBTransaction; |
| 32 using WebKit::WebIDBTransactionCallbacks; | 32 using WebKit::WebIDBTransactionCallbacks; |
| 33 | 33 |
| 34 IndexedDBDispatcher::IndexedDBDispatcher() { | 34 IndexedDBDispatcher::IndexedDBDispatcher(IndexedDBMessageFilter* filter) : |
| 35 pending_callbacks_(filter), |
| 36 pending_transaction_callbacks_(filter), |
| 37 pending_database_callbacks_(filter) { |
| 35 } | 38 } |
| 36 | 39 |
| 37 IndexedDBDispatcher::~IndexedDBDispatcher() { | 40 IndexedDBDispatcher::~IndexedDBDispatcher() { |
| 38 } | 41 } |
| 39 | 42 |
| 40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { | 43 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 41 bool handled = true; | 44 bool handled = true; |
| 42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) | 45 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) |
| 43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, | 46 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, |
| 44 OnSuccessOpenCursor) | 47 OnSuccessOpenCursor) |
| 45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, | 48 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, |
| 46 OnSuccessCursorContinue) | 49 OnSuccessCursorContinue) |
| 47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, | 50 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, |
| 48 OnSuccessIDBDatabase) | 51 OnSuccessIDBDatabase) |
| 49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, | 52 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, |
| 50 OnSuccessIndexedDBKey) | 53 OnSuccessIndexedDBKey) |
| 51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, | 54 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, |
| 52 OnSuccessIDBTransaction) | 55 OnSuccessIDBTransaction) |
| 53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, | 56 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, |
| 54 OnSuccessStringList) | 57 OnSuccessStringList) |
| 55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, | 58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, |
| 56 OnSuccessSerializedScriptValue) | 59 OnSuccessSerializedScriptValue) |
| 57 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) | 60 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) |
| 58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) | 61 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) |
| 59 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) | 62 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) |
| 60 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) | 63 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) |
| 61 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, | 64 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, |
| 62 OnVersionChange) | 65 OnVersionChange) |
| 63 IPC_MESSAGE_UNHANDLED(handled = false) | 66 IPC_MESSAGE_UNHANDLED(handled = false) |
| 64 IPC_END_MESSAGE_MAP() | 67 IPC_END_MESSAGE_MAP() |
| 65 return handled; | 68 // If a message gets here, IndexedDBMessageFilter already determined that it |
| 69 // is an IndexedDB message. |
| 70 DCHECK(handled); |
| 71 } |
| 72 |
| 73 void IndexedDBDispatcher::Send(IPC::Message* msg) { |
| 74 ChildThread::current()->Send(msg); |
| 66 } | 75 } |
| 67 | 76 |
| 68 void IndexedDBDispatcher::RequestIDBCursorUpdate( | 77 void IndexedDBDispatcher::RequestIDBCursorUpdate( |
| 69 const content::SerializedScriptValue& value, | 78 const content::SerializedScriptValue& value, |
| 70 WebIDBCallbacks* callbacks_ptr, | 79 WebIDBCallbacks* callbacks_ptr, |
| 71 int32 idb_cursor_id, | 80 int32 idb_cursor_id, |
| 72 WebExceptionCode* ec) { | 81 WebExceptionCode* ec) { |
| 73 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 82 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 74 | 83 |
| 75 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 84 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 76 RenderThreadImpl::current()->Send( | 85 Send( |
| 77 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); | 86 new IndexedDBHostMsg_CursorUpdate(idb_cursor_id, response_id, value, ec)); |
| 78 if (*ec) | 87 if (*ec) |
| 79 pending_callbacks_.Remove(response_id); | 88 pending_callbacks_.Remove(response_id); |
| 80 } | 89 } |
| 81 | 90 |
| 82 void IndexedDBDispatcher::RequestIDBCursorContinue( | 91 void IndexedDBDispatcher::RequestIDBCursorContinue( |
| 83 const IndexedDBKey& key, | 92 const IndexedDBKey& key, |
| 84 WebIDBCallbacks* callbacks_ptr, | 93 WebIDBCallbacks* callbacks_ptr, |
| 85 int32 idb_cursor_id, | 94 int32 idb_cursor_id, |
| 86 WebExceptionCode* ec) { | 95 WebExceptionCode* ec) { |
| 87 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 96 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 88 | 97 |
| 89 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 98 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 90 RenderThreadImpl::current()->Send( | 99 Send( |
| 91 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); | 100 new IndexedDBHostMsg_CursorContinue(idb_cursor_id, response_id, key, ec)); |
| 92 if (*ec) | 101 if (*ec) |
| 93 pending_callbacks_.Remove(response_id); | 102 pending_callbacks_.Remove(response_id); |
| 94 } | 103 } |
| 95 | 104 |
| 96 void IndexedDBDispatcher::RequestIDBCursorDelete( | 105 void IndexedDBDispatcher::RequestIDBCursorDelete( |
| 97 WebIDBCallbacks* callbacks_ptr, | 106 WebIDBCallbacks* callbacks_ptr, |
| 98 int32 idb_cursor_id, | 107 int32 idb_cursor_id, |
| 99 WebExceptionCode* ec) { | 108 WebExceptionCode* ec) { |
| 100 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 109 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 101 | 110 |
| 102 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 111 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 103 RenderThreadImpl::current()->Send( | 112 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); |
| 104 new IndexedDBHostMsg_CursorDelete(idb_cursor_id, response_id, ec)); | |
| 105 if (*ec) | 113 if (*ec) |
| 106 pending_callbacks_.Remove(response_id); | 114 pending_callbacks_.Remove(response_id); |
| 107 } | 115 } |
| 108 | 116 |
| 109 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 117 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 110 const string16& name, | 118 const string16& name, |
| 111 WebIDBCallbacks* callbacks_ptr, | 119 WebIDBCallbacks* callbacks_ptr, |
| 112 const string16& origin, | 120 const string16& origin, |
| 113 WebFrame* web_frame) { | 121 WebFrame* web_frame) { |
| 114 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 122 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 115 | 123 |
| 116 if (!web_frame) | |
| 117 return; // We must be shutting down. | |
| 118 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | |
| 119 if (!render_view) | |
| 120 return; // We must be shutting down. | |
| 121 | |
| 122 IndexedDBHostMsg_FactoryOpen_Params params; | 124 IndexedDBHostMsg_FactoryOpen_Params params; |
| 123 params.response_id = pending_callbacks_.Add(callbacks.release()); | 125 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 124 params.origin = origin; | 126 params.origin = origin; |
| 125 params.name = name; | 127 params.name = name; |
| 126 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_FactoryOpen(params)); | 128 Send(new IndexedDBHostMsg_FactoryOpen(params)); |
| 127 } | 129 } |
| 128 | 130 |
| 129 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( | 131 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( |
| 130 WebIDBCallbacks* callbacks_ptr, | 132 WebIDBCallbacks* callbacks_ptr, |
| 131 const string16& origin, | 133 const string16& origin, |
| 132 WebFrame* web_frame) { | 134 WebFrame* web_frame) { |
| 133 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 135 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 134 | 136 |
| 135 if (!web_frame) | 137 if (!web_frame) |
| 136 return; // We must be shutting down. | 138 return; // We must be shutting down. |
| 137 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 139 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 138 if (!render_view) | 140 if (!render_view) |
| 139 return; // We must be shutting down. | 141 return; // We must be shutting down. |
| 140 | 142 |
| 141 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; | 143 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; |
| 142 params.response_id = pending_callbacks_.Add(callbacks.release()); | 144 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 143 params.origin = origin; | 145 params.origin = origin; |
| 144 RenderThreadImpl::current()->Send( | 146 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); |
| 145 new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); | |
| 146 } | 147 } |
| 147 | 148 |
| 148 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( | 149 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
| 149 const string16& name, | 150 const string16& name, |
| 150 WebIDBCallbacks* callbacks_ptr, | 151 WebIDBCallbacks* callbacks_ptr, |
| 151 const string16& origin, | 152 const string16& origin, |
| 152 WebFrame* web_frame) { | 153 WebFrame* web_frame) { |
| 153 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 154 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 154 | 155 |
| 155 if (!web_frame) | 156 if (!web_frame) |
| 156 return; // We must be shutting down. | 157 return; // We must be shutting down. |
| 157 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); | 158 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view()); |
| 158 if (!render_view) | 159 if (!render_view) |
| 159 return; // We must be shutting down. | 160 return; // We must be shutting down. |
| 160 | 161 |
| 161 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; | 162 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; |
| 162 params.response_id = pending_callbacks_.Add(callbacks.release()); | 163 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 163 params.origin = origin; | 164 params.origin = origin; |
| 164 params.name = name; | 165 params.name = name; |
| 165 RenderThreadImpl::current()->Send( | 166 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); |
| 166 new IndexedDBHostMsg_FactoryDeleteDatabase(params)); | |
| 167 } | 167 } |
| 168 | 168 |
| 169 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { | 169 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { |
| 170 RenderThreadImpl::current()->Send( | 170 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); |
| 171 new IndexedDBHostMsg_DatabaseClose(idb_database_id)); | |
| 172 pending_database_callbacks_.Remove(idb_database_id); | 171 pending_database_callbacks_.Remove(idb_database_id); |
| 173 } | 172 } |
| 174 | 173 |
| 175 void IndexedDBDispatcher::RequestIDBDatabaseOpen( | 174 void IndexedDBDispatcher::RequestIDBDatabaseOpen( |
| 176 WebIDBDatabaseCallbacks* callbacks_ptr, | 175 WebIDBDatabaseCallbacks* callbacks_ptr, |
| 177 int32 idb_database_id) { | 176 int32 idb_database_id) { |
| 178 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); | 177 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); |
| 179 | 178 |
| 180 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); | 179 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id); |
| 181 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_DatabaseOpen( | 180 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, idb_database_id)); |
| 182 response_id, idb_database_id)); | |
| 183 } | 181 } |
| 184 | 182 |
| 185 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( | 183 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( |
| 186 const string16& version, | 184 const string16& version, |
| 187 WebIDBCallbacks* callbacks_ptr, | 185 WebIDBCallbacks* callbacks_ptr, |
| 188 int32 idb_database_id, | 186 int32 idb_database_id, |
| 189 WebExceptionCode* ec) { | 187 WebExceptionCode* ec) { |
| 190 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 188 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 191 | 189 |
| 192 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 190 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 193 RenderThreadImpl::current()->Send( | 191 Send(new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, |
| 194 new IndexedDBHostMsg_DatabaseSetVersion(idb_database_id, response_id, | 192 version, ec)); |
| 195 version, ec)); | |
| 196 if (*ec) | 193 if (*ec) |
| 197 pending_callbacks_.Remove(response_id); | 194 pending_callbacks_.Remove(response_id); |
| 198 } | 195 } |
| 199 | 196 |
| 200 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( | 197 void IndexedDBDispatcher::RequestIDBIndexOpenObjectCursor( |
| 201 const WebIDBKeyRange& idb_key_range, | 198 const WebIDBKeyRange& idb_key_range, |
| 202 unsigned short direction, | 199 unsigned short direction, |
| 203 WebIDBCallbacks* callbacks_ptr, | 200 WebIDBCallbacks* callbacks_ptr, |
| 204 int32 idb_index_id, | 201 int32 idb_index_id, |
| 205 const WebIDBTransaction& transaction, | 202 const WebIDBTransaction& transaction, |
| 206 WebExceptionCode* ec) { | 203 WebExceptionCode* ec) { |
| 207 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 204 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 208 IndexedDBHostMsg_IndexOpenCursor_Params params; | 205 IndexedDBHostMsg_IndexOpenCursor_Params params; |
| 209 params.response_id = pending_callbacks_.Add(callbacks.release()); | 206 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 210 params.lower_key.Set(idb_key_range.lower()); | 207 params.lower_key.Set(idb_key_range.lower()); |
| 211 params.upper_key.Set(idb_key_range.upper()); | 208 params.upper_key.Set(idb_key_range.upper()); |
| 212 params.lower_open = idb_key_range.lowerOpen(); | 209 params.lower_open = idb_key_range.lowerOpen(); |
| 213 params.upper_open = idb_key_range.upperOpen(); | 210 params.upper_open = idb_key_range.upperOpen(); |
| 214 params.direction = direction; | 211 params.direction = direction; |
| 215 params.idb_index_id = idb_index_id; | 212 params.idb_index_id = idb_index_id; |
| 216 params.transaction_id = TransactionId(transaction); | 213 params.transaction_id = TransactionId(transaction); |
| 217 RenderThreadImpl::current()->Send( | 214 Send(new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); |
| 218 new IndexedDBHostMsg_IndexOpenObjectCursor(params, ec)); | |
| 219 if (*ec) | 215 if (*ec) |
| 220 pending_callbacks_.Remove(params.response_id); | 216 pending_callbacks_.Remove(params.response_id); |
| 221 } | 217 } |
| 222 | 218 |
| 223 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( | 219 void IndexedDBDispatcher::RequestIDBIndexOpenKeyCursor( |
| 224 const WebIDBKeyRange& idb_key_range, | 220 const WebIDBKeyRange& idb_key_range, |
| 225 unsigned short direction, | 221 unsigned short direction, |
| 226 WebIDBCallbacks* callbacks_ptr, | 222 WebIDBCallbacks* callbacks_ptr, |
| 227 int32 idb_index_id, | 223 int32 idb_index_id, |
| 228 const WebIDBTransaction& transaction, | 224 const WebIDBTransaction& transaction, |
| 229 WebExceptionCode* ec) { | 225 WebExceptionCode* ec) { |
| 230 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 226 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 231 IndexedDBHostMsg_IndexOpenCursor_Params params; | 227 IndexedDBHostMsg_IndexOpenCursor_Params params; |
| 232 params.response_id = pending_callbacks_.Add(callbacks.release()); | 228 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 233 // TODO(jorlow): We really should just create a Chromium abstraction for | 229 // TODO(jorlow): We really should just create a Chromium abstraction for |
| 234 // KeyRange rather than doing it ad-hoc like this. | 230 // KeyRange rather than doing it ad-hoc like this. |
| 235 params.lower_key.Set(idb_key_range.lower()); | 231 params.lower_key.Set(idb_key_range.lower()); |
| 236 params.upper_key.Set(idb_key_range.upper()); | 232 params.upper_key.Set(idb_key_range.upper()); |
| 237 params.lower_open = idb_key_range.lowerOpen(); | 233 params.lower_open = idb_key_range.lowerOpen(); |
| 238 params.upper_open = idb_key_range.upperOpen(); | 234 params.upper_open = idb_key_range.upperOpen(); |
| 239 params.direction = direction; | 235 params.direction = direction; |
| 240 params.idb_index_id = idb_index_id; | 236 params.idb_index_id = idb_index_id; |
| 241 params.transaction_id = TransactionId(transaction); | 237 params.transaction_id = TransactionId(transaction); |
| 242 RenderThreadImpl::current()->Send( | 238 Send(new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); |
| 243 new IndexedDBHostMsg_IndexOpenKeyCursor(params, ec)); | |
| 244 if (*ec) | 239 if (*ec) |
| 245 pending_callbacks_.Remove(params.response_id); | 240 pending_callbacks_.Remove(params.response_id); |
| 246 } | 241 } |
| 247 | 242 |
| 248 void IndexedDBDispatcher::RequestIDBIndexGetObject( | 243 void IndexedDBDispatcher::RequestIDBIndexGetObject( |
| 249 const IndexedDBKey& key, | 244 const IndexedDBKey& key, |
| 250 WebIDBCallbacks* callbacks_ptr, | 245 WebIDBCallbacks* callbacks_ptr, |
| 251 int32 idb_index_id, | 246 int32 idb_index_id, |
| 252 const WebIDBTransaction& transaction, | 247 const WebIDBTransaction& transaction, |
| 253 WebExceptionCode* ec) { | 248 WebExceptionCode* ec) { |
| 254 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 249 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 255 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 250 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 256 RenderThreadImpl::current()->Send( | 251 Send(new IndexedDBHostMsg_IndexGetObject(idb_index_id, response_id, key, |
| 257 new IndexedDBHostMsg_IndexGetObject( | 252 TransactionId(transaction), ec)); |
| 258 idb_index_id, response_id, key, | |
| 259 TransactionId(transaction), ec)); | |
| 260 if (*ec) | 253 if (*ec) |
| 261 pending_callbacks_.Remove(response_id); | 254 pending_callbacks_.Remove(response_id); |
| 262 } | 255 } |
| 263 | 256 |
| 264 void IndexedDBDispatcher::RequestIDBIndexGetKey( | 257 void IndexedDBDispatcher::RequestIDBIndexGetKey( |
| 265 const IndexedDBKey& key, | 258 const IndexedDBKey& key, |
| 266 WebIDBCallbacks* callbacks_ptr, | 259 WebIDBCallbacks* callbacks_ptr, |
| 267 int32 idb_index_id, | 260 int32 idb_index_id, |
| 268 const WebIDBTransaction& transaction, | 261 const WebIDBTransaction& transaction, |
| 269 WebExceptionCode* ec) { | 262 WebExceptionCode* ec) { |
| 270 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 263 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 271 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 264 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 272 RenderThreadImpl::current()->Send( | 265 Send(new IndexedDBHostMsg_IndexGetKey( |
| 273 new IndexedDBHostMsg_IndexGetKey( | 266 idb_index_id, response_id, key, |
| 274 idb_index_id, response_id, key, | 267 TransactionId(transaction), ec)); |
| 275 TransactionId(transaction), ec)); | |
| 276 if (*ec) | 268 if (*ec) |
| 277 pending_callbacks_.Remove(response_id); | 269 pending_callbacks_.Remove(response_id); |
| 278 } | 270 } |
| 279 | 271 |
| 280 void IndexedDBDispatcher::RequestIDBObjectStoreGet( | 272 void IndexedDBDispatcher::RequestIDBObjectStoreGet( |
| 281 const IndexedDBKey& key, | 273 const IndexedDBKey& key, |
| 282 WebIDBCallbacks* callbacks_ptr, | 274 WebIDBCallbacks* callbacks_ptr, |
| 283 int32 idb_object_store_id, | 275 int32 idb_object_store_id, |
| 284 const WebIDBTransaction& transaction, | 276 const WebIDBTransaction& transaction, |
| 285 WebExceptionCode* ec) { | 277 WebExceptionCode* ec) { |
| 286 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 278 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 287 | 279 |
| 288 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 280 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 289 RenderThreadImpl::current()->Send( | 281 Send(new IndexedDBHostMsg_ObjectStoreGet( |
| 290 new IndexedDBHostMsg_ObjectStoreGet( | 282 idb_object_store_id, response_id, |
| 291 idb_object_store_id, response_id, | 283 key, TransactionId(transaction), ec)); |
| 292 key, TransactionId(transaction), ec)); | |
| 293 if (*ec) | 284 if (*ec) |
| 294 pending_callbacks_.Remove(response_id); | 285 pending_callbacks_.Remove(response_id); |
| 295 } | 286 } |
| 296 | 287 |
| 297 void IndexedDBDispatcher::RequestIDBObjectStorePut( | 288 void IndexedDBDispatcher::RequestIDBObjectStorePut( |
| 298 const content::SerializedScriptValue& value, | 289 const content::SerializedScriptValue& value, |
| 299 const IndexedDBKey& key, | 290 const IndexedDBKey& key, |
| 300 WebKit::WebIDBObjectStore::PutMode put_mode, | 291 WebKit::WebIDBObjectStore::PutMode put_mode, |
| 301 WebIDBCallbacks* callbacks_ptr, | 292 WebIDBCallbacks* callbacks_ptr, |
| 302 int32 idb_object_store_id, | 293 int32 idb_object_store_id, |
| 303 const WebIDBTransaction& transaction, | 294 const WebIDBTransaction& transaction, |
| 304 WebExceptionCode* ec) { | 295 WebExceptionCode* ec) { |
| 305 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 296 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 306 IndexedDBHostMsg_ObjectStorePut_Params params; | 297 IndexedDBHostMsg_ObjectStorePut_Params params; |
| 307 params.idb_object_store_id = idb_object_store_id; | 298 params.idb_object_store_id = idb_object_store_id; |
| 308 params.response_id = pending_callbacks_.Add(callbacks.release()); | 299 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 309 params.serialized_value = value; | 300 params.serialized_value = value; |
| 310 params.key = key; | 301 params.key = key; |
| 311 params.put_mode = put_mode; | 302 params.put_mode = put_mode; |
| 312 params.transaction_id = TransactionId(transaction); | 303 params.transaction_id = TransactionId(transaction); |
| 313 RenderThreadImpl::current()->Send(new IndexedDBHostMsg_ObjectStorePut( | 304 Send(new IndexedDBHostMsg_ObjectStorePut(params, ec)); |
| 314 params, ec)); | |
| 315 if (*ec) | 305 if (*ec) |
| 316 pending_callbacks_.Remove(params.response_id); | 306 pending_callbacks_.Remove(params.response_id); |
| 317 } | 307 } |
| 318 | 308 |
| 319 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( | 309 void IndexedDBDispatcher::RequestIDBObjectStoreDelete( |
| 320 const IndexedDBKey& key, | 310 const IndexedDBKey& key, |
| 321 WebIDBCallbacks* callbacks_ptr, | 311 WebIDBCallbacks* callbacks_ptr, |
| 322 int32 idb_object_store_id, | 312 int32 idb_object_store_id, |
| 323 const WebIDBTransaction& transaction, | 313 const WebIDBTransaction& transaction, |
| 324 WebExceptionCode* ec) { | 314 WebExceptionCode* ec) { |
| 325 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 315 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 326 | 316 |
| 327 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 317 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 328 RenderThreadImpl::current()->Send( | 318 Send(new IndexedDBHostMsg_ObjectStoreDelete( |
| 329 new IndexedDBHostMsg_ObjectStoreDelete( | 319 idb_object_store_id, response_id, |
| 330 idb_object_store_id, response_id, | 320 key, TransactionId(transaction), ec)); |
| 331 key, TransactionId(transaction), ec)); | |
| 332 if (*ec) | 321 if (*ec) |
| 333 pending_callbacks_.Remove(response_id); | 322 pending_callbacks_.Remove(response_id); |
| 334 } | 323 } |
| 335 | 324 |
| 336 void IndexedDBDispatcher::RequestIDBObjectStoreClear( | 325 void IndexedDBDispatcher::RequestIDBObjectStoreClear( |
| 337 WebIDBCallbacks* callbacks_ptr, | 326 WebIDBCallbacks* callbacks_ptr, |
| 338 int32 idb_object_store_id, | 327 int32 idb_object_store_id, |
| 339 const WebIDBTransaction& transaction, | 328 const WebIDBTransaction& transaction, |
| 340 WebExceptionCode* ec) { | 329 WebExceptionCode* ec) { |
| 341 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 330 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 342 | 331 |
| 343 int32 response_id = pending_callbacks_.Add(callbacks.release()); | 332 int32 response_id = pending_callbacks_.Add(callbacks.release()); |
| 344 RenderThreadImpl::current()->Send( | 333 Send(new IndexedDBHostMsg_ObjectStoreClear( |
| 345 new IndexedDBHostMsg_ObjectStoreClear( | 334 idb_object_store_id, response_id, |
| 346 idb_object_store_id, response_id, | 335 TransactionId(transaction), ec)); |
| 347 TransactionId(transaction), ec)); | |
| 348 if (*ec) | 336 if (*ec) |
| 349 pending_callbacks_.Remove(response_id); | 337 pending_callbacks_.Remove(response_id); |
| 350 } | 338 } |
| 351 | 339 |
| 352 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( | 340 void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( |
| 353 const WebIDBKeyRange& idb_key_range, | 341 const WebIDBKeyRange& idb_key_range, |
| 354 unsigned short direction, | 342 unsigned short direction, |
| 355 WebIDBCallbacks* callbacks_ptr, | 343 WebIDBCallbacks* callbacks_ptr, |
| 356 int32 idb_object_store_id, | 344 int32 idb_object_store_id, |
| 357 const WebIDBTransaction& transaction, | 345 const WebIDBTransaction& transaction, |
| 358 WebExceptionCode* ec) { | 346 WebExceptionCode* ec) { |
| 359 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 347 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 360 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; | 348 IndexedDBHostMsg_ObjectStoreOpenCursor_Params params; |
| 361 params.response_id = pending_callbacks_.Add(callbacks.release()); | 349 params.response_id = pending_callbacks_.Add(callbacks.release()); |
| 362 params.lower_key.Set(idb_key_range.lower()); | 350 params.lower_key.Set(idb_key_range.lower()); |
| 363 params.upper_key.Set(idb_key_range.upper()); | 351 params.upper_key.Set(idb_key_range.upper()); |
| 364 params.lower_open = idb_key_range.lowerOpen(); | 352 params.lower_open = idb_key_range.lowerOpen(); |
| 365 params.upper_open = idb_key_range.upperOpen(); | 353 params.upper_open = idb_key_range.upperOpen(); |
| 366 params.direction = direction; | 354 params.direction = direction; |
| 367 params.idb_object_store_id = idb_object_store_id; | 355 params.idb_object_store_id = idb_object_store_id; |
| 368 params.transaction_id = TransactionId(transaction); | 356 params.transaction_id = TransactionId(transaction); |
| 369 RenderThreadImpl::current()->Send( | 357 Send(new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); |
| 370 new IndexedDBHostMsg_ObjectStoreOpenCursor(params, ec)); | |
| 371 if (*ec) | 358 if (*ec) |
| 372 pending_callbacks_.Remove(params.response_id); | 359 pending_callbacks_.Remove(params.response_id); |
| 373 } | 360 } |
| 374 | 361 |
| 375 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( | 362 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( |
| 376 WebIDBTransactionCallbacks* callbacks, | 363 WebIDBTransactionCallbacks* callbacks, |
| 377 int32 id) { | 364 int32 id) { |
| 378 pending_transaction_callbacks_.AddWithID(callbacks, id); | 365 pending_transaction_callbacks_.AddWithID(callbacks, id); |
| 379 } | 366 } |
| 380 | 367 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 void IndexedDBDispatcher::OnVersionChange(int32 database_id, | 494 void IndexedDBDispatcher::OnVersionChange(int32 database_id, |
| 508 const string16& newVersion) { | 495 const string16& newVersion) { |
| 509 WebIDBDatabaseCallbacks* callbacks = | 496 WebIDBDatabaseCallbacks* callbacks = |
| 510 pending_database_callbacks_.Lookup(database_id); | 497 pending_database_callbacks_.Lookup(database_id); |
| 511 // callbacks would be NULL if a versionchange event is received after close | 498 // callbacks would be NULL if a versionchange event is received after close |
| 512 // has been called. | 499 // has been called. |
| 513 if (!callbacks) | 500 if (!callbacks) |
| 514 return; | 501 return; |
| 515 callbacks->onVersionChange(newVersion); | 502 callbacks->onVersionChange(newVersion); |
| 516 } | 503 } |
| OLD | NEW |