| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "webkit/base/file_path_string_conversions.h" | 34 #include "webkit/base/file_path_string_conversions.h" |
| 35 #include "webkit/base/origin_url_conversions.h" | 35 #include "webkit/base/origin_url_conversions.h" |
| 36 #include "webkit/browser/database/database_util.h" | 36 #include "webkit/browser/database/database_util.h" |
| 37 | 37 |
| 38 using webkit_database::DatabaseUtil; | 38 using webkit_database::DatabaseUtil; |
| 39 using WebKit::WebData; | 39 using WebKit::WebData; |
| 40 using WebKit::WebIDBCallbacks; | 40 using WebKit::WebIDBCallbacks; |
| 41 using WebKit::WebIDBCursor; | 41 using WebKit::WebIDBCursor; |
| 42 using WebKit::WebIDBDatabase; | 42 using WebKit::WebIDBDatabase; |
| 43 using WebKit::WebIDBDatabaseError; | 43 using WebKit::WebIDBDatabaseError; |
| 44 using WebKit::WebIDBIndex; | |
| 45 using WebKit::WebIDBKey; | 44 using WebKit::WebIDBKey; |
| 46 using WebKit::WebIDBMetadata; | 45 using WebKit::WebIDBMetadata; |
| 47 using WebKit::WebIDBObjectStore; | |
| 48 using WebKit::WebString; | 46 using WebKit::WebString; |
| 49 using WebKit::WebVector; | 47 using WebKit::WebVector; |
| 50 | 48 |
| 51 namespace content { | 49 namespace content { |
| 52 namespace { | 50 namespace { |
| 53 | 51 |
| 54 template <class T> | 52 template <class T> void DeleteOnWebKitThread(T* obj) { |
| 55 void DeleteOnWebKitThread(T* obj) { | 53 if (!BrowserThread::DeleteSoon( |
| 56 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, | 54 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, obj)) |
| 57 FROM_HERE, obj)) | |
| 58 delete obj; | 55 delete obj; |
| 59 } | 56 } |
| 60 } | 57 } |
| 61 | 58 |
| 62 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 59 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
| 63 int ipc_process_id, IndexedDBContextImpl* indexed_db_context) | 60 int ipc_process_id, |
| 61 IndexedDBContextImpl* indexed_db_context) |
| 64 : indexed_db_context_(indexed_db_context), | 62 : indexed_db_context_(indexed_db_context), |
| 65 database_dispatcher_host_(new DatabaseDispatcherHost(this)), | 63 database_dispatcher_host_(new DatabaseDispatcherHost(this)), |
| 66 cursor_dispatcher_host_(new CursorDispatcherHost(this)), | 64 cursor_dispatcher_host_(new CursorDispatcherHost(this)), |
| 67 ipc_process_id_(ipc_process_id) { | 65 ipc_process_id_(ipc_process_id) { |
| 68 DCHECK(indexed_db_context_.get()); | 66 DCHECK(indexed_db_context_.get()); |
| 69 } | 67 } |
| 70 | 68 |
| 71 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 69 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {} |
| 72 } | |
| 73 | 70 |
| 74 void IndexedDBDispatcherHost::OnChannelClosing() { | 71 void IndexedDBDispatcherHost::OnChannelClosing() { |
| 75 BrowserMessageFilter::OnChannelClosing(); | 72 BrowserMessageFilter::OnChannelClosing(); |
| 76 | 73 |
| 77 bool success = BrowserThread::PostTask( | 74 bool success = BrowserThread::PostTask( |
| 78 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 75 BrowserThread::WEBKIT_DEPRECATED, |
| 76 FROM_HERE, |
| 79 base::Bind(&IndexedDBDispatcherHost::ResetDispatcherHosts, this)); | 77 base::Bind(&IndexedDBDispatcherHost::ResetDispatcherHosts, this)); |
| 80 | 78 |
| 81 if (!success) | 79 if (!success) |
| 82 ResetDispatcherHosts(); | 80 ResetDispatcherHosts(); |
| 83 } | 81 } |
| 84 | 82 |
| 85 void IndexedDBDispatcherHost::ResetDispatcherHosts() { | 83 void IndexedDBDispatcherHost::ResetDispatcherHosts() { |
| 86 // It is important that the various *_dispatcher_host_ members are reset | 84 // It is important that the various *_dispatcher_host_ members are reset |
| 87 // on the WebKit thread, since there might be incoming messages on that | 85 // on the WebKit thread, since there might be incoming messages on that |
| 88 // thread, and we must not reset the dispatcher hosts until after those | 86 // thread, and we must not reset the dispatcher hosts until after those |
| (...skipping 23 matching lines...) Expand all Loading... |
| 112 | 110 |
| 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 114 | 112 |
| 115 bool handled = | 113 bool handled = |
| 116 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | 114 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 117 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok); | 115 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok); |
| 118 | 116 |
| 119 if (!handled) { | 117 if (!handled) { |
| 120 handled = true; | 118 handled = true; |
| 121 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) | 119 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) |
| 122 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, | 120 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, |
| 123 OnIDBFactoryGetDatabaseNames) | 121 OnIDBFactoryGetDatabaseNames) |
| 124 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | 122 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
| 125 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | 123 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, |
| 126 OnIDBFactoryDeleteDatabase) | 124 OnIDBFactoryDeleteDatabase) |
| 127 IPC_MESSAGE_UNHANDLED(handled = false) | 125 IPC_MESSAGE_UNHANDLED(handled = false) |
| 128 IPC_END_MESSAGE_MAP() | 126 IPC_END_MESSAGE_MAP() |
| 129 } | 127 } |
| 130 return handled; | 128 return handled; |
| 131 } | 129 } |
| 132 | 130 |
| 133 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 131 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
| 134 if (!cursor_dispatcher_host_) { | 132 if (!cursor_dispatcher_host_) { |
| 135 delete idb_cursor; | 133 delete idb_cursor; |
| 136 return 0; | 134 return 0; |
| 137 } | 135 } |
| 138 return cursor_dispatcher_host_->map_.Add(idb_cursor); | 136 return cursor_dispatcher_host_->map_.Add(idb_cursor); |
| 139 } | 137 } |
| 140 | 138 |
| 141 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, | 139 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, |
| 142 int32 ipc_thread_id, | 140 int32 ipc_thread_id, |
| 143 const GURL& origin_url) { | 141 const GURL& origin_url) { |
| 144 if (!database_dispatcher_host_) { | 142 if (!database_dispatcher_host_) { |
| 145 delete idb_database; | 143 delete idb_database; |
| 146 return 0; | 144 return 0; |
| 147 } | 145 } |
| 148 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database); | 146 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database); |
| 149 Context()->ConnectionOpened(origin_url, idb_database); | 147 Context()->ConnectionOpened(origin_url, idb_database); |
| 150 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; | 148 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; |
| 151 return ipc_database_id; | 149 return ipc_database_id; |
| 152 } | 150 } |
| 153 | 151 |
| 154 void IndexedDBDispatcherHost::RegisterTransactionId( | 152 void IndexedDBDispatcherHost::RegisterTransactionId(int64 host_transaction_id, |
| 155 int64 host_transaction_id, | 153 const GURL& url) { |
| 156 const GURL& url) | |
| 157 { | |
| 158 if (!database_dispatcher_host_) | 154 if (!database_dispatcher_host_) |
| 159 return; | 155 return; |
| 160 database_dispatcher_host_->transaction_url_map_[host_transaction_id] = url; | 156 database_dispatcher_host_->transaction_url_map_[host_transaction_id] = url; |
| 161 } | 157 } |
| 162 | 158 |
| 163 int64 IndexedDBDispatcherHost::HostTransactionId(int64 transaction_id) { | 159 int64 IndexedDBDispatcherHost::HostTransactionId(int64 transaction_id) { |
| 164 // Inject the renderer process id into the transaction id, to | 160 // Inject the renderer process id into the transaction id, to |
| 165 // uniquely identify this transaction, and effectively bind it to | 161 // uniquely identify this transaction, and effectively bind it to |
| 166 // the renderer that initiated it. The lower 32 bits of | 162 // the renderer that initiated it. The lower 32 bits of |
| 167 // transaction_id are guaranteed to be unique within that renderer. | 163 // transaction_id are guaranteed to be unique within that renderer. |
| 168 base::ProcessId pid = base::GetProcId(peer_handle()); | 164 base::ProcessId pid = base::GetProcId(peer_handle()); |
| 169 DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits"; | 165 DCHECK(!(transaction_id >> 32)) << "Transaction ids can only be 32 bits"; |
| 170 COMPILE_ASSERT(sizeof(base::ProcessId) <= sizeof(int32), | 166 COMPILE_ASSERT(sizeof(base::ProcessId) <= sizeof(int32), |
| 171 Process_ID_must_fit_in_32_bits); | 167 Process_ID_must_fit_in_32_bits); |
| 172 | 168 |
| 173 return transaction_id | (static_cast<uint64>(pid) << 32); | 169 return transaction_id | (static_cast<uint64>(pid) << 32); |
| 174 } | 170 } |
| 175 | 171 |
| 176 int64 IndexedDBDispatcherHost::RendererTransactionId( | 172 int64 IndexedDBDispatcherHost::RendererTransactionId( |
| 177 int64 host_transaction_id) { | 173 int64 host_transaction_id) { |
| 178 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle())) << | 174 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle())) |
| 179 "Invalid renderer target for transaction id"; | 175 << "Invalid renderer target for transaction id"; |
| 180 return host_transaction_id & 0xffffffff; | 176 return host_transaction_id & 0xffffffff; |
| 181 } | 177 } |
| 182 | 178 |
| 183 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { | 179 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { |
| 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 185 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); | 181 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); |
| 186 } | 182 } |
| 187 | 183 |
| 188 IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( | 184 IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( |
| 189 const WebIDBMetadata& web_metadata) | 185 const WebIDBMetadata& web_metadata) { |
| 190 { | |
| 191 IndexedDBDatabaseMetadata metadata; | 186 IndexedDBDatabaseMetadata metadata; |
| 192 metadata.id = web_metadata.id; | 187 metadata.id = web_metadata.id; |
| 193 metadata.name = web_metadata.name; | 188 metadata.name = web_metadata.name; |
| 194 metadata.version = web_metadata.version; | 189 metadata.version = web_metadata.version; |
| 195 metadata.int_version = web_metadata.intVersion; | 190 metadata.int_version = web_metadata.intVersion; |
| 196 metadata.max_object_store_id = web_metadata.maxObjectStoreId; | 191 metadata.max_object_store_id = web_metadata.maxObjectStoreId; |
| 197 | 192 |
| 198 for (size_t i = 0; i < web_metadata.objectStores.size(); ++i) { | 193 for (size_t i = 0; i < web_metadata.objectStores.size(); ++i) { |
| 199 const WebIDBMetadata::ObjectStore& web_store_metadata = | 194 const WebIDBMetadata::ObjectStore& web_store_metadata = |
| 200 web_metadata.objectStores[i]; | 195 web_metadata.objectStores[i]; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 220 } | 215 } |
| 221 return metadata; | 216 return metadata; |
| 222 } | 217 } |
| 223 | 218 |
| 224 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 219 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
| 225 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 220 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { |
| 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 227 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 222 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 228 | 223 |
| 229 Context()->GetIDBFactory()->getDatabaseNames( | 224 Context()->GetIDBFactory()->getDatabaseNames( |
| 230 new IndexedDBCallbacks<WebVector<WebString> >(this, params.ipc_thread_id, | 225 new IndexedDBCallbacks<WebVector<WebString> >( |
| 231 params.ipc_callbacks_id), params.database_identifier, | 226 this, params.ipc_thread_id, params.ipc_callbacks_id), |
| 227 params.database_identifier, |
| 232 webkit_base::FilePathToWebString(indexed_db_path)); | 228 webkit_base::FilePathToWebString(indexed_db_path)); |
| 233 } | 229 } |
| 234 | 230 |
| 235 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 231 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 236 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 232 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 238 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 234 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 239 | 235 |
| 240 GURL origin_url = | 236 GURL origin_url = |
| 241 webkit_base::GetOriginURLFromIdentifier(params.database_identifier); | 237 webkit_base::GetOriginURLFromIdentifier(params.database_identifier); |
| 242 | 238 |
| 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 244 | 240 |
| 245 int64 host_transaction_id = HostTransactionId(params.transaction_id); | 241 int64 host_transaction_id = HostTransactionId(params.transaction_id); |
| 246 | 242 |
| 247 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 243 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
| 248 // created) if this origin is already over quota. | 244 // created) if this origin is already over quota. |
| 249 Context()->GetIDBFactory()->open( | 245 Context()->GetIDBFactory() |
| 250 params.name, | 246 ->open(params.name, |
| 251 params.version, | 247 params.version, |
| 252 host_transaction_id, | 248 host_transaction_id, |
| 253 new IndexedDBCallbacksDatabase(this, params.ipc_thread_id, | 249 new IndexedDBCallbacksDatabase(this, |
| 254 params.ipc_callbacks_id, | 250 params.ipc_thread_id, |
| 255 params.ipc_database_callbacks_id, | 251 params.ipc_callbacks_id, |
| 256 host_transaction_id, | 252 params.ipc_database_callbacks_id, |
| 257 origin_url), | 253 host_transaction_id, |
| 258 new IndexedDBDatabaseCallbacks(this, params.ipc_thread_id, | 254 origin_url), |
| 259 params.ipc_database_callbacks_id), | 255 new IndexedDBDatabaseCallbacks( |
| 260 params.database_identifier, | 256 this, params.ipc_thread_id, params.ipc_database_callbacks_id), |
| 261 webkit_base::FilePathToWebString(indexed_db_path)); | 257 params.database_identifier, |
| 258 webkit_base::FilePathToWebString(indexed_db_path)); |
| 262 } | 259 } |
| 263 | 260 |
| 264 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 261 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
| 265 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 262 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
| 266 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 263 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 267 | 264 |
| 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 269 Context()->GetIDBFactory()->deleteDatabase( | 266 Context()->GetIDBFactory() |
| 270 params.name, | 267 ->deleteDatabase(params.name, |
| 271 new IndexedDBCallbacks<WebData>(this, | 268 new IndexedDBCallbacks<WebData>( |
| 272 params.ipc_thread_id, | 269 this, params.ipc_thread_id, params.ipc_callbacks_id), |
| 273 params.ipc_callbacks_id), | 270 params.database_identifier, |
| 274 params.database_identifier, | 271 webkit_base::FilePathToWebString(indexed_db_path)); |
| 275 webkit_base::FilePathToWebString(indexed_db_path)); | |
| 276 } | 272 } |
| 277 | 273 |
| 278 void IndexedDBDispatcherHost::FinishTransaction( | 274 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, |
| 279 int64 host_transaction_id, bool committed) { | 275 bool committed) { |
| 280 TransactionIDToURLMap& transaction_url_map = | 276 TransactionIDToURLMap& transaction_url_map = |
| 281 database_dispatcher_host_->transaction_url_map_; | 277 database_dispatcher_host_->transaction_url_map_; |
| 282 TransactionIDToSizeMap& transaction_size_map = | 278 TransactionIDToSizeMap& transaction_size_map = |
| 283 database_dispatcher_host_->transaction_size_map_; | 279 database_dispatcher_host_->transaction_size_map_; |
| 284 TransactionIDToDatabaseIDMap& transaction_database_map = | 280 TransactionIDToDatabaseIDMap& transaction_database_map = |
| 285 database_dispatcher_host_->transaction_database_map_; | 281 database_dispatcher_host_->transaction_database_map_; |
| 286 if (committed) | 282 if (committed) |
| 287 Context()->TransactionComplete(transaction_url_map[host_transaction_id]); | 283 Context()->TransactionComplete(transaction_url_map[host_transaction_id]); |
| 288 // It's unclear if std::map::erase(key) has defined behavior if the | 284 // It's unclear if std::map::erase(key) has defined behavior if the |
| 289 // key is not found. | 285 // key is not found. |
| 290 // TODO(alecflett): Remove if it is proven that it is safe. | 286 // TODO(alecflett): Remove if it is proven that it is safe. |
| 291 if (transaction_url_map.find(host_transaction_id) != | 287 if (transaction_url_map.find(host_transaction_id) != |
| 292 transaction_url_map.end()) | 288 transaction_url_map.end()) |
| 293 transaction_url_map.erase(host_transaction_id); | 289 transaction_url_map.erase(host_transaction_id); |
| 294 if (transaction_size_map.find(host_transaction_id) != | 290 if (transaction_size_map.find(host_transaction_id) != |
| 295 transaction_size_map.end()) | 291 transaction_size_map.end()) |
| 296 transaction_size_map.erase(host_transaction_id); | 292 transaction_size_map.erase(host_transaction_id); |
| 297 if (transaction_database_map.find(host_transaction_id) != | 293 if (transaction_database_map.find(host_transaction_id) != |
| 298 transaction_database_map.end()) | 294 transaction_database_map.end()) |
| 299 transaction_database_map.erase(host_transaction_id); | 295 transaction_database_map.erase(host_transaction_id); |
| 300 } | 296 } |
| 301 | 297 |
| 302 ////////////////////////////////////////////////////////////////////// | 298 ////////////////////////////////////////////////////////////////////// |
| 303 // Helper templates. | 299 // Helper templates. |
| 304 // | 300 // |
| 305 | 301 |
| 306 template <typename ObjectType> | 302 template <typename ObjectType> |
| 307 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 303 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
| 308 IDMap<ObjectType, IDMapOwnPointer>* map, int32 ipc_return_object_id) { | 304 IDMap<ObjectType, IDMapOwnPointer>* map, |
| 305 int32 ipc_return_object_id) { |
| 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 310 ObjectType* return_object = map->Lookup(ipc_return_object_id); | 307 ObjectType* return_object = map->Lookup(ipc_return_object_id); |
| 311 if (!return_object) { | 308 if (!return_object) { |
| 312 NOTREACHED() << "Uh oh, couldn't find object with id " | 309 NOTREACHED() << "Uh oh, couldn't find object with id " |
| 313 << ipc_return_object_id; | 310 << ipc_return_object_id; |
| 314 RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF")); | 311 RecordAction(UserMetricsAction("BadMessageTerminate_IDBMF")); |
| 315 BadMessageReceived(); | 312 BadMessageReceived(); |
| 316 } | 313 } |
| 317 return return_object; | 314 return return_object; |
| 318 } | 315 } |
| 319 | 316 |
| 320 template <typename ObjectType> | 317 template <typename ObjectType> |
| 321 void IndexedDBDispatcherHost::DestroyObject( | 318 void IndexedDBDispatcherHost::DestroyObject( |
| 322 IDMap<ObjectType, IDMapOwnPointer>* map, int32 ipc_object_id) { | 319 IDMap<ObjectType, IDMapOwnPointer>* map, |
| 320 int32 ipc_object_id) { |
| 323 GetOrTerminateProcess(map, ipc_object_id); | 321 GetOrTerminateProcess(map, ipc_object_id); |
| 324 map->Remove(ipc_object_id); | 322 map->Remove(ipc_object_id); |
| 325 } | 323 } |
| 326 | 324 |
| 327 | |
| 328 ////////////////////////////////////////////////////////////////////// | 325 ////////////////////////////////////////////////////////////////////// |
| 329 // IndexedDBDispatcherHost::DatabaseDispatcherHost | 326 // IndexedDBDispatcherHost::DatabaseDispatcherHost |
| 330 // | 327 // |
| 331 | 328 |
| 332 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( | 329 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( |
| 333 IndexedDBDispatcherHost* parent) | 330 IndexedDBDispatcherHost* parent) |
| 334 : parent_(parent) { | 331 : parent_(parent) { |
| 335 map_.set_check_on_null_data(true); | 332 map_.set_check_on_null_data(true); |
| 336 } | 333 } |
| 337 | 334 |
| 338 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { | 335 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { |
| 339 // TODO(alecflett): uncomment these when we find the source of these leaks. | 336 // TODO(alecflett): uncomment these when we find the source of these leaks. |
| 340 // DCHECK(transaction_size_map_.empty()); | 337 // DCHECK(transaction_size_map_.empty()); |
| 341 // DCHECK(transaction_url_map_.empty()); | 338 // DCHECK(transaction_url_map_.empty()); |
| 342 } | 339 } |
| 343 | 340 |
| 344 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { | 341 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { |
| 345 // Abort outstanding transactions started by connections in the associated | 342 // Abort outstanding transactions started by connections in the associated |
| 346 // front-end to unblock later transactions. This should only occur on unclean | 343 // front-end to unblock later transactions. This should only occur on unclean |
| 347 // (crash) or abrupt (process-kill) shutdowns. | 344 // (crash) or abrupt (process-kill) shutdowns. |
| 348 for (TransactionIDToDatabaseIDMap::iterator iter = | 345 for (TransactionIDToDatabaseIDMap::iterator iter = |
| 349 transaction_database_map_.begin(); | 346 transaction_database_map_.begin(); |
| 350 iter != transaction_database_map_.end();) { | 347 iter != transaction_database_map_.end();) { |
| 351 int64 transaction_id = iter->first; | 348 int64 transaction_id = iter->first; |
| 352 int32 ipc_database_id = iter->second; | 349 int32 ipc_database_id = iter->second; |
| 353 ++iter; | 350 ++iter; |
| 354 WebIDBDatabase* database = map_.Lookup(ipc_database_id); | 351 WebIDBDatabase* database = map_.Lookup(ipc_database_id); |
| 355 if (database) { | 352 if (database) { |
| 356 database->abort(transaction_id, WebIDBDatabaseError( | 353 database->abort( |
| 357 WebKit::WebIDBDatabaseExceptionUnknownError)); | 354 transaction_id, |
| 355 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError)); |
| 358 } | 356 } |
| 359 } | 357 } |
| 360 DCHECK(transaction_database_map_.empty()); | 358 DCHECK(transaction_database_map_.empty()); |
| 361 | 359 |
| 362 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); | 360 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); |
| 363 iter != database_url_map_.end(); iter++) { | 361 iter != database_url_map_.end(); |
| 362 iter++) { |
| 364 WebIDBDatabase* database = map_.Lookup(iter->first); | 363 WebIDBDatabase* database = map_.Lookup(iter->first); |
| 365 if (database) { | 364 if (database) { |
| 366 database->close(); | 365 database->close(); |
| 367 parent_->Context()->ConnectionClosed(iter->second, database); | 366 parent_->Context()->ConnectionClosed(iter->second, database); |
| 368 } | 367 } |
| 369 } | 368 } |
| 370 } | 369 } |
| 371 | 370 |
| 372 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 371 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 373 const IPC::Message& message, bool* msg_is_ok) { | 372 const IPC::Message& message, |
| 373 bool* msg_is_ok) { |
| 374 bool handled = true; | 374 bool handled = true; |
| 375 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 375 IPC_BEGIN_MESSAGE_MAP_EX( |
| 376 message, *msg_is_ok) | 376 IndexedDBDispatcherHost::DatabaseDispatcherHost, message, *msg_is_ok) |
| 377 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 377 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 378 OnCreateObjectStore) | 378 OnCreateObjectStore) |
| 379 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 379 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 380 OnDeleteObjectStore) | 380 OnDeleteObjectStore) |
| 381 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 381 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
| 382 OnCreateTransaction) | 382 OnCreateTransaction) |
| 383 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 383 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 384 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 384 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 385 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 385 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| 386 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | 386 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
| 387 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | 387 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, OnSetIndexKeys) |
| 388 OnSetIndexKeys) | 388 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
| 389 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | 389 OnSetIndexesReady) |
| 390 OnSetIndexesReady) | 390 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) |
| 391 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) | 391 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) |
| 392 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) | 392 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) |
| 393 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) | 393 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) |
| 394 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) | 394 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, OnCreateIndex) |
| 395 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, | 395 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex, OnDeleteIndex) |
| 396 OnCreateIndex) | 396 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseAbort, OnAbort) |
| 397 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex, | 397 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCommit, OnCommit) |
| 398 OnDeleteIndex) | 398 IPC_MESSAGE_UNHANDLED(handled = false) |
| 399 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseAbort, | |
| 400 OnAbort) | |
| 401 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCommit, | |
| 402 OnCommit) | |
| 403 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 404 IPC_END_MESSAGE_MAP() | 399 IPC_END_MESSAGE_MAP() |
| 405 return handled; | 400 return handled; |
| 406 } | 401 } |
| 407 | 402 |
| 408 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( | 403 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( |
| 409 IPC::Message* message) { | 404 IPC::Message* message) { |
| 410 parent_->Send(message); | 405 parent_->Send(message); |
| 411 } | 406 } |
| 412 | 407 |
| 413 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 408 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| 414 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { | 409 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { |
| 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 416 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 411 WebIDBDatabase* database = |
| 417 &map_, params.ipc_database_id); | 412 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 418 if (!database) | 413 if (!database) |
| 419 return; | 414 return; |
| 420 | 415 |
| 421 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 416 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 422 database->createObjectStore( | 417 database->createObjectStore(host_transaction_id, |
| 423 host_transaction_id, | 418 params.object_store_id, |
| 424 params.object_store_id, | 419 params.name, |
| 425 params.name, params.key_path, params.auto_increment); | 420 params.key_path, |
| 421 params.auto_increment); |
| 426 if (parent_->Context()->IsOverQuota( | 422 if (parent_->Context()->IsOverQuota( |
| 427 database_url_map_[params.ipc_database_id])) { | 423 database_url_map_[params.ipc_database_id])) { |
| 428 database->abort(host_transaction_id, WebIDBDatabaseError( | 424 database->abort( |
| 429 WebKit::WebIDBDatabaseExceptionQuotaError)); | 425 host_transaction_id, |
| 426 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); |
| 430 } | 427 } |
| 431 } | 428 } |
| 432 | 429 |
| 433 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 430 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
| 434 int32 ipc_database_id, | 431 int32 ipc_database_id, |
| 435 int64 transaction_id, | 432 int64 transaction_id, |
| 436 int64 object_store_id) { | 433 int64 object_store_id) { |
| 437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 438 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 435 WebIDBDatabase* database = |
| 439 &map_, ipc_database_id); | 436 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 440 if (!database) | 437 if (!database) |
| 441 return; | 438 return; |
| 442 | 439 |
| 443 database->deleteObjectStore(parent_->HostTransactionId(transaction_id), | 440 database->deleteObjectStore(parent_->HostTransactionId(transaction_id), |
| 444 object_store_id); | 441 object_store_id); |
| 445 } | 442 } |
| 446 | 443 |
| 447 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( | 444 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( |
| 448 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { | 445 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { |
| 449 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 446 WebIDBDatabase* database = |
| 450 &map_, params.ipc_database_id); | 447 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 451 if (!database) | 448 if (!database) |
| 452 return; | 449 return; |
| 453 | 450 |
| 454 WebVector<long long> object_stores(params.object_store_ids.size()); | 451 WebVector<long long> object_stores(params.object_store_ids.size()); |
| 455 for (size_t i = 0; i < params.object_store_ids.size(); ++i) | 452 for (size_t i = 0; i < params.object_store_ids.size(); ++i) |
| 456 object_stores[i] = params.object_store_ids[i]; | 453 object_stores[i] = params.object_store_ids[i]; |
| 457 | 454 |
| 458 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 455 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 459 | 456 |
| 460 database->createTransaction( | 457 database->createTransaction( |
| 461 host_transaction_id, | 458 host_transaction_id, |
| 462 new IndexedDBDatabaseCallbacks(parent_, params.ipc_thread_id, | 459 new IndexedDBDatabaseCallbacks( |
| 463 params.ipc_database_callbacks_id), | 460 parent_, params.ipc_thread_id, params.ipc_database_callbacks_id), |
| 464 object_stores, params.mode); | 461 object_stores, |
| 462 params.mode); |
| 465 transaction_database_map_[host_transaction_id] = params.ipc_database_id; | 463 transaction_database_map_[host_transaction_id] = params.ipc_database_id; |
| 466 parent_->RegisterTransactionId(host_transaction_id, | 464 parent_->RegisterTransactionId(host_transaction_id, |
| 467 database_url_map_[params.ipc_database_id]); | 465 database_url_map_[params.ipc_database_id]); |
| 468 } | 466 } |
| 469 | 467 |
| 470 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( | 468 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
| 471 int32 ipc_database_id) { | 469 int32 ipc_database_id) { |
| 472 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 470 WebIDBDatabase* database = |
| 473 &map_, ipc_database_id); | 471 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 474 if (!database) | 472 if (!database) |
| 475 return; | 473 return; |
| 476 database->close(); | 474 database->close(); |
| 477 } | 475 } |
| 478 | 476 |
| 479 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 477 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
| 480 int32 ipc_object_id) { | 478 int32 ipc_object_id) { |
| 481 WebIDBDatabase* database = map_.Lookup(ipc_object_id); | 479 WebIDBDatabase* database = map_.Lookup(ipc_object_id); |
| 482 parent_->Context()->ConnectionClosed(database_url_map_[ipc_object_id], | 480 parent_->Context() |
| 483 database); | 481 ->ConnectionClosed(database_url_map_[ipc_object_id], database); |
| 484 database_url_map_.erase(ipc_object_id); | 482 database_url_map_.erase(ipc_object_id); |
| 485 parent_->DestroyObject(&map_, ipc_object_id); | 483 parent_->DestroyObject(&map_, ipc_object_id); |
| 486 } | 484 } |
| 487 | 485 |
| 488 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( | 486 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( |
| 489 const IndexedDBHostMsg_DatabaseGet_Params& params) { | 487 const IndexedDBHostMsg_DatabaseGet_Params& params) { |
| 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 491 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 489 WebIDBDatabase* database = |
| 492 &map_, params.ipc_database_id); | 490 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 493 if (!database) | 491 if (!database) |
| 494 return; | 492 return; |
| 495 | 493 |
| 496 scoped_ptr<WebIDBCallbacks> callbacks( | 494 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( |
| 497 new IndexedDBCallbacks<WebData>( | 495 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 498 parent_, params.ipc_thread_id, | |
| 499 params.ipc_callbacks_id)); | |
| 500 database->get(parent_->HostTransactionId(params.transaction_id), | 496 database->get(parent_->HostTransactionId(params.transaction_id), |
| 501 params.object_store_id, | 497 params.object_store_id, |
| 502 params.index_id, | 498 params.index_id, |
| 503 params.key_range, params.key_only, callbacks.release()); | 499 params.key_range, |
| 500 params.key_only, |
| 501 callbacks.release()); |
| 504 } | 502 } |
| 505 | 503 |
| 506 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | 504 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| 507 const IndexedDBHostMsg_DatabasePut_Params& params) { | 505 const IndexedDBHostMsg_DatabasePut_Params& params) { |
| 508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 509 | 507 |
| 510 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 508 WebIDBDatabase* database = |
| 511 &map_, params.ipc_database_id); | 509 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 512 if (!database) | 510 if (!database) |
| 513 return; | 511 return; |
| 514 scoped_ptr<WebIDBCallbacks> callbacks( | 512 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebIDBKey>( |
| 515 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | 513 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 516 params.ipc_callbacks_id)); | |
| 517 // Be careful with empty vectors. | 514 // Be careful with empty vectors. |
| 518 WebData value; | 515 WebData value; |
| 519 if (params.value.size()) | 516 if (params.value.size()) |
| 520 value.assign(¶ms.value.front(), params.value.size()); | 517 value.assign(¶ms.value.front(), params.value.size()); |
| 521 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 518 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 522 database->put(host_transaction_id, | 519 database->put(host_transaction_id, |
| 523 params.object_store_id, | 520 params.object_store_id, |
| 524 value, params.key, | 521 value, |
| 525 params.put_mode, callbacks.release(), | 522 params.key, |
| 523 params.put_mode, |
| 524 callbacks.release(), |
| 526 params.index_ids, | 525 params.index_ids, |
| 527 params.index_keys); | 526 params.index_keys); |
| 528 TransactionIDToSizeMap* map = | 527 TransactionIDToSizeMap* map = |
| 529 &parent_->database_dispatcher_host_->transaction_size_map_; | 528 &parent_->database_dispatcher_host_->transaction_size_map_; |
| 530 // Size can't be big enough to overflow because it represents the | 529 // Size can't be big enough to overflow because it represents the |
| 531 // actual bytes passed through IPC. | 530 // actual bytes passed through IPC. |
| 532 (*map)[host_transaction_id] += params.value.size(); | 531 (*map)[host_transaction_id] += params.value.size(); |
| 533 } | 532 } |
| 534 | 533 |
| 535 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 534 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| 536 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | 535 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
| 537 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 536 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 538 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 537 WebIDBDatabase* database = |
| 539 &map_, params.ipc_database_id); | 538 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 540 if (!database) | 539 if (!database) |
| 541 return; | 540 return; |
| 542 | 541 |
| 543 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 542 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 544 if (params.index_ids.size() != params.index_keys.size()) { | 543 if (params.index_ids.size() != params.index_keys.size()) { |
| 545 database->abort(host_transaction_id, WebIDBDatabaseError( | 544 database->abort( |
| 546 WebKit::WebIDBDatabaseExceptionUnknownError, | 545 host_transaction_id, |
| 547 "Malformed IPC message: index_ids.size() != index_keys.size()")); | 546 WebIDBDatabaseError( |
| 547 WebKit::WebIDBDatabaseExceptionUnknownError, |
| 548 "Malformed IPC message: index_ids.size() != index_keys.size()")); |
| 548 return; | 549 return; |
| 549 } | 550 } |
| 550 | 551 |
| 551 database->setIndexKeys(host_transaction_id, | 552 database->setIndexKeys(host_transaction_id, |
| 552 params.object_store_id, | 553 params.object_store_id, |
| 553 params.primary_key, params.index_ids, | 554 params.primary_key, |
| 555 params.index_ids, |
| 554 params.index_keys); | 556 params.index_keys); |
| 555 } | 557 } |
| 556 | 558 |
| 557 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( | 559 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( |
| 558 int32 ipc_database_id, | 560 int32 ipc_database_id, |
| 559 int64 transaction_id, | 561 int64 transaction_id, |
| 560 int64 object_store_id, | 562 int64 object_store_id, |
| 561 const std::vector<int64>& index_ids) { | 563 const std::vector<int64>& index_ids) { |
| 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 563 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 565 WebIDBDatabase* database = |
| 564 &map_, ipc_database_id); | 566 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 565 if (!database) | 567 if (!database) |
| 566 return; | 568 return; |
| 567 | 569 |
| 568 database->setIndexesReady(parent_->HostTransactionId(transaction_id), | 570 database->setIndexesReady(parent_->HostTransactionId(transaction_id), |
| 569 object_store_id, | 571 object_store_id, |
| 570 WebVector<long long>(index_ids)); | 572 WebVector<long long>(index_ids)); |
| 571 } | 573 } |
| 572 | 574 |
| 573 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( | 575 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( |
| 574 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { | 576 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { |
| 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 576 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 578 WebIDBDatabase* database = |
| 577 &map_, params.ipc_database_id); | 579 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 578 if (!database) | 580 if (!database) |
| 579 return; | 581 return; |
| 580 | 582 |
| 581 scoped_ptr<WebIDBCallbacks> callbacks( | 583 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebIDBCursor>( |
| 582 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, | 584 parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); |
| 583 params.ipc_callbacks_id, -1)); | 585 database->openCursor(parent_->HostTransactionId(params.transaction_id), |
| 584 database->openCursor( | 586 params.object_store_id, |
| 585 parent_->HostTransactionId(params.transaction_id), | 587 params.index_id, |
| 586 params.object_store_id, params.index_id, | 588 params.key_range, |
| 587 params.key_range, params.direction, params.key_only, params.task_type, | 589 params.direction, |
| 588 callbacks.release()); | 590 params.key_only, |
| 591 params.task_type, |
| 592 callbacks.release()); |
| 589 } | 593 } |
| 590 | 594 |
| 591 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( | 595 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
| 592 const IndexedDBHostMsg_DatabaseCount_Params& params) { | 596 const IndexedDBHostMsg_DatabaseCount_Params& params) { |
| 593 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 597 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 594 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 598 WebIDBDatabase* database = |
| 595 &map_, params.ipc_database_id); | 599 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 596 if (!database) | 600 if (!database) |
| 597 return; | 601 return; |
| 598 | 602 |
| 599 scoped_ptr<WebIDBCallbacks> callbacks( | 603 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( |
| 600 new IndexedDBCallbacks<WebData>( | 604 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 601 parent_, params.ipc_thread_id, | 605 database->count(parent_->HostTransactionId(params.transaction_id), |
| 602 params.ipc_callbacks_id)); | 606 params.object_store_id, |
| 603 database->count( | 607 params.index_id, |
| 604 parent_->HostTransactionId(params.transaction_id), | 608 params.key_range, |
| 605 params.object_store_id, params.index_id, | 609 callbacks.release()); |
| 606 params.key_range, callbacks.release()); | |
| 607 } | 610 } |
| 608 | 611 |
| 609 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( | 612 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( |
| 610 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { | 613 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { |
| 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 612 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 615 WebIDBDatabase* database = |
| 613 &map_, params.ipc_database_id); | 616 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 614 if (!database) | 617 if (!database) |
| 615 return; | 618 return; |
| 616 | 619 |
| 617 scoped_ptr<WebIDBCallbacks> callbacks( | 620 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( |
| 618 new IndexedDBCallbacks<WebData>( | 621 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); |
| 619 parent_, params.ipc_thread_id, | |
| 620 params.ipc_callbacks_id)); | |
| 621 database->deleteRange(parent_->HostTransactionId(params.transaction_id), | 622 database->deleteRange(parent_->HostTransactionId(params.transaction_id), |
| 622 params.object_store_id, | 623 params.object_store_id, |
| 623 params.key_range, callbacks.release()); | 624 params.key_range, |
| 625 callbacks.release()); |
| 624 } | 626 } |
| 625 | 627 |
| 626 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( | 628 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
| 627 int32 ipc_thread_id, | 629 int32 ipc_thread_id, |
| 628 int32 ipc_callbacks_id, | 630 int32 ipc_callbacks_id, |
| 629 int32 ipc_database_id, | 631 int32 ipc_database_id, |
| 630 int64 transaction_id, | 632 int64 transaction_id, |
| 631 int64 object_store_id) { | 633 int64 object_store_id) { |
| 632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 633 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 635 WebIDBDatabase* database = |
| 634 &map_, ipc_database_id); | 636 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 635 if (!database) | 637 if (!database) |
| 636 return; | 638 return; |
| 637 | 639 |
| 638 scoped_ptr<WebIDBCallbacks> callbacks( | 640 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( |
| 639 new IndexedDBCallbacks<WebData>( | 641 parent_, ipc_thread_id, ipc_callbacks_id)); |
| 640 parent_, ipc_thread_id, | |
| 641 ipc_callbacks_id)); | |
| 642 | 642 |
| 643 database->clear(parent_->HostTransactionId(transaction_id), | 643 database->clear(parent_->HostTransactionId(transaction_id), |
| 644 object_store_id, callbacks.release()); | 644 object_store_id, |
| 645 callbacks.release()); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( | 648 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
| 648 int32 ipc_database_id, | 649 int32 ipc_database_id, |
| 649 int64 transaction_id) { | 650 int64 transaction_id) { |
| 650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 651 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 651 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 652 WebIDBDatabase* database = |
| 652 &map_, ipc_database_id); | 653 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 653 if (!database) | 654 if (!database) |
| 654 return; | 655 return; |
| 655 | 656 |
| 656 database->abort(parent_->HostTransactionId(transaction_id)); | 657 database->abort(parent_->HostTransactionId(transaction_id)); |
| 657 } | 658 } |
| 658 | 659 |
| 659 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( | 660 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( |
| 660 int32 ipc_database_id, | 661 int32 ipc_database_id, |
| 661 int64 transaction_id) { | 662 int64 transaction_id) { |
| 662 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 663 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 663 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 664 WebIDBDatabase* database = |
| 664 &map_, ipc_database_id); | 665 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 665 if (!database) | 666 if (!database) |
| 666 return; | 667 return; |
| 667 | 668 |
| 668 int64 host_transaction_id = parent_->HostTransactionId(transaction_id); | 669 int64 host_transaction_id = parent_->HostTransactionId(transaction_id); |
| 669 int64 transaction_size = transaction_size_map_[host_transaction_id]; | 670 int64 transaction_size = transaction_size_map_[host_transaction_id]; |
| 670 if (transaction_size && parent_->Context()->WouldBeOverQuota( | 671 if (transaction_size && |
| 671 transaction_url_map_[host_transaction_id], transaction_size)) { | 672 parent_->Context()->WouldBeOverQuota( |
| 672 database->abort(host_transaction_id, WebIDBDatabaseError( | 673 transaction_url_map_[host_transaction_id], transaction_size)) { |
| 673 WebKit::WebIDBDatabaseExceptionQuotaError)); | 674 database->abort( |
| 675 host_transaction_id, |
| 676 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); |
| 674 return; | 677 return; |
| 675 } | 678 } |
| 676 | 679 |
| 677 database->commit(host_transaction_id); | 680 database->commit(host_transaction_id); |
| 678 } | 681 } |
| 679 | 682 |
| 680 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( | 683 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( |
| 681 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { | 684 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { |
| 682 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 685 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 683 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 686 WebIDBDatabase* database = |
| 684 &map_, params.ipc_database_id); | 687 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); |
| 685 if (!database) | 688 if (!database) |
| 686 return; | 689 return; |
| 687 | 690 |
| 688 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 691 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 689 database->createIndex( | 692 database->createIndex(host_transaction_id, |
| 690 host_transaction_id, | 693 params.object_store_id, |
| 691 params.object_store_id, | 694 params.index_id, |
| 692 params.index_id, | 695 params.name, |
| 693 params.name, | 696 params.key_path, |
| 694 params.key_path, | 697 params.unique, |
| 695 params.unique, | 698 params.multi_entry); |
| 696 params.multi_entry); | |
| 697 if (parent_->Context()->IsOverQuota( | 699 if (parent_->Context()->IsOverQuota( |
| 698 database_url_map_[params.ipc_database_id])) { | 700 database_url_map_[params.ipc_database_id])) { |
| 699 database->abort(host_transaction_id, WebIDBDatabaseError( | 701 database->abort( |
| 700 WebKit::WebIDBDatabaseExceptionQuotaError)); | 702 host_transaction_id, |
| 703 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); |
| 701 } | 704 } |
| 702 } | 705 } |
| 703 | 706 |
| 704 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( | 707 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( |
| 705 int32 ipc_database_id, | 708 int32 ipc_database_id, |
| 706 int64 transaction_id, | 709 int64 transaction_id, |
| 707 int64 object_store_id, | 710 int64 object_store_id, |
| 708 int64 index_id) { | 711 int64 index_id) { |
| 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 710 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 713 WebIDBDatabase* database = |
| 711 &map_, ipc_database_id); | 714 parent_->GetOrTerminateProcess(&map_, ipc_database_id); |
| 712 if (!database) | 715 if (!database) |
| 713 return; | 716 return; |
| 714 | 717 |
| 715 database->deleteIndex(parent_->HostTransactionId(transaction_id), | 718 database->deleteIndex( |
| 716 object_store_id, index_id); | 719 parent_->HostTransactionId(transaction_id), object_store_id, index_id); |
| 717 } | 720 } |
| 718 | 721 |
| 719 ////////////////////////////////////////////////////////////////////// | 722 ////////////////////////////////////////////////////////////////////// |
| 720 // IndexedDBDispatcherHost::CursorDispatcherHost | 723 // IndexedDBDispatcherHost::CursorDispatcherHost |
| 721 // | 724 // |
| 722 | 725 |
| 723 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 726 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
| 724 IndexedDBDispatcherHost* parent) | 727 IndexedDBDispatcherHost* parent) |
| 725 : parent_(parent) { | 728 : parent_(parent) { |
| 726 map_.set_check_on_null_data(true); | 729 map_.set_check_on_null_data(true); |
| 727 } | 730 } |
| 728 | 731 |
| 729 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() { | 732 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() {} |
| 730 } | |
| 731 | 733 |
| 732 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( | 734 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( |
| 733 const IPC::Message& message, bool* msg_is_ok) { | 735 const IPC::Message& message, |
| 736 bool* msg_is_ok) { |
| 734 bool handled = true; | 737 bool handled = true; |
| 735 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::CursorDispatcherHost, | 738 IPC_BEGIN_MESSAGE_MAP_EX( |
| 736 message, *msg_is_ok) | 739 IndexedDBDispatcherHost::CursorDispatcherHost, message, *msg_is_ok) |
| 737 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance) | 740 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance) |
| 738 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue) | 741 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue) |
| 739 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch) | 742 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch) |
| 740 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset) | 743 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset) |
| 741 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDelete, OnDelete) | 744 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDelete, OnDelete) |
| 742 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) | 745 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) |
| 743 IPC_MESSAGE_UNHANDLED(handled = false) | 746 IPC_MESSAGE_UNHANDLED(handled = false) |
| 744 IPC_END_MESSAGE_MAP() | 747 IPC_END_MESSAGE_MAP() |
| 745 return handled; | 748 return handled; |
| 746 } | 749 } |
| 747 | 750 |
| 748 | |
| 749 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( | 751 void IndexedDBDispatcherHost::CursorDispatcherHost::Send( |
| 750 IPC::Message* message) { | 752 IPC::Message* message) { |
| 751 parent_->Send(message); | 753 parent_->Send(message); |
| 752 } | 754 } |
| 753 | 755 |
| 754 | |
| 755 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( | 756 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( |
| 756 int32 ipc_cursor_id, | 757 int32 ipc_cursor_id, |
| 757 int32 ipc_thread_id, | 758 int32 ipc_thread_id, |
| 758 int32 ipc_callbacks_id, | 759 int32 ipc_callbacks_id, |
| 759 unsigned long count) { | 760 unsigned long count) { |
| 760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 761 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 761 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess( | 762 WebIDBCursor* idb_cursor = |
| 762 &map_, ipc_cursor_id); | 763 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| 763 if (!idb_cursor) | 764 if (!idb_cursor) |
| 764 return; | 765 return; |
| 765 | 766 |
| 766 idb_cursor->advance(count, | 767 idb_cursor->advance( |
| 767 new IndexedDBCallbacks<WebIDBCursor>(parent_, | 768 count, |
| 768 ipc_thread_id, | 769 new IndexedDBCallbacks<WebIDBCursor>( |
| 769 ipc_callbacks_id, | 770 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
| 770 ipc_cursor_id)); | |
| 771 } | 771 } |
| 772 | 772 |
| 773 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 773 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
| 774 int32 ipc_cursor_id, | 774 int32 ipc_cursor_id, |
| 775 int32 ipc_thread_id, | 775 int32 ipc_thread_id, |
| 776 int32 ipc_callbacks_id, | 776 int32 ipc_callbacks_id, |
| 777 const IndexedDBKey& key) { | 777 const IndexedDBKey& key) { |
| 778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 779 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, | 779 WebIDBCursor* idb_cursor = |
| 780 ipc_cursor_id); | 780 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| 781 if (!idb_cursor) | 781 if (!idb_cursor) |
| 782 return; | 782 return; |
| 783 | 783 |
| 784 idb_cursor->continueFunction( | 784 idb_cursor->continueFunction( |
| 785 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, ipc_thread_id, | 785 key, |
| 786 ipc_callbacks_id, | 786 new IndexedDBCallbacks<WebIDBCursor>( |
| 787 ipc_cursor_id)); | 787 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( | 790 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( |
| 791 int32 ipc_cursor_id, | 791 int32 ipc_cursor_id, |
| 792 int32 ipc_thread_id, | 792 int32 ipc_thread_id, |
| 793 int32 ipc_callbacks_id, | 793 int32 ipc_callbacks_id, |
| 794 int n) { | 794 int n) { |
| 795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 796 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, | 796 WebIDBCursor* idb_cursor = |
| 797 ipc_cursor_id); | 797 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| 798 if (!idb_cursor) | 798 if (!idb_cursor) |
| 799 return; | 799 return; |
| 800 | 800 |
| 801 idb_cursor->prefetchContinue( | 801 idb_cursor->prefetchContinue( |
| 802 n, new IndexedDBCallbacks<WebIDBCursor>(parent_, ipc_thread_id, | 802 n, |
| 803 ipc_callbacks_id, | 803 new IndexedDBCallbacks<WebIDBCursor>( |
| 804 ipc_cursor_id)); | 804 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); |
| 805 } | 805 } |
| 806 | 806 |
| 807 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( | 807 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( |
| 808 int32 ipc_cursor_id, int used_prefetches, int unused_prefetches) { | 808 int32 ipc_cursor_id, |
| 809 int used_prefetches, |
| 810 int unused_prefetches) { |
| 809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 810 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, | 812 WebIDBCursor* idb_cursor = |
| 811 ipc_cursor_id); | 813 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| 812 if (!idb_cursor) | 814 if (!idb_cursor) |
| 813 return; | 815 return; |
| 814 | 816 |
| 815 idb_cursor->prefetchReset(used_prefetches, unused_prefetches); | 817 idb_cursor->prefetchReset(used_prefetches, unused_prefetches); |
| 816 } | 818 } |
| 817 | 819 |
| 818 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( | 820 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( |
| 819 int32 ipc_cursor_id, | 821 int32 ipc_cursor_id, |
| 820 int32 ipc_thread_id, | 822 int32 ipc_thread_id, |
| 821 int32 ipc_callbacks_id) { | 823 int32 ipc_callbacks_id) { |
| 822 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 824 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 823 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, | 825 WebIDBCursor* idb_cursor = |
| 824 ipc_cursor_id); | 826 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); |
| 825 if (!idb_cursor) | 827 if (!idb_cursor) |
| 826 return; | 828 return; |
| 827 | 829 |
| 828 idb_cursor->deleteFunction( | 830 idb_cursor->deleteFunction(new IndexedDBCallbacks<WebData>( |
| 829 new IndexedDBCallbacks<WebData>(parent_, ipc_thread_id, | 831 parent_, ipc_thread_id, ipc_callbacks_id)); |
| 830 ipc_callbacks_id)); | |
| 831 } | 832 } |
| 832 | 833 |
| 833 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 834 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 834 int32 ipc_object_id) { | 835 int32 ipc_object_id) { |
| 835 parent_->DestroyObject(&map_, ipc_object_id); | 836 parent_->DestroyObject(&map_, ipc_object_id); |
| 836 } | 837 } |
| 837 | 838 |
| 838 } // namespace content | 839 } // namespace content |
| OLD | NEW |