| 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 10 matching lines...) Expand all Loading... |
| 21 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/result_codes.h" | 23 #include "content/public/common/result_codes.h" |
| 24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac
ks.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" | |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" |
| 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" | |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 36 #include "webkit/base/file_path_string_conversions.h" | 34 #include "webkit/base/file_path_string_conversions.h" |
| 37 #include "webkit/database/database_util.h" | 35 #include "webkit/database/database_util.h" |
| 38 | 36 |
| 39 using webkit_database::DatabaseUtil; | 37 using webkit_database::DatabaseUtil; |
| 40 using WebKit::WebDOMStringList; | 38 using WebKit::WebDOMStringList; |
| 41 using WebKit::WebExceptionCode; | 39 using WebKit::WebExceptionCode; |
| 42 using WebKit::WebIDBCallbacks; | 40 using WebKit::WebIDBCallbacks; |
| 43 using WebKit::WebIDBCursor; | 41 using WebKit::WebIDBCursor; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 FROM_HERE, obj)) | 58 FROM_HERE, obj)) |
| 61 delete obj; | 59 delete obj; |
| 62 } | 60 } |
| 63 } | 61 } |
| 64 | 62 |
| 65 IndexedDBDispatcherHost::IndexedDBDispatcherHost( | 63 IndexedDBDispatcherHost::IndexedDBDispatcherHost( |
| 66 int ipc_process_id, IndexedDBContextImpl* indexed_db_context) | 64 int ipc_process_id, IndexedDBContextImpl* indexed_db_context) |
| 67 : indexed_db_context_(indexed_db_context), | 65 : indexed_db_context_(indexed_db_context), |
| 68 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( | 66 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( |
| 69 new DatabaseDispatcherHost(this))), | 67 new DatabaseDispatcherHost(this))), |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( | |
| 71 new IndexDispatcherHost(this))), | |
| 72 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( | |
| 73 new ObjectStoreDispatcherHost(this))), | |
| 74 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( | 68 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( |
| 75 new CursorDispatcherHost(this))), | 69 new CursorDispatcherHost(this))), |
| 76 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( | 70 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( |
| 77 new TransactionDispatcherHost(this))), | 71 new TransactionDispatcherHost(this))), |
| 78 ipc_process_id_(ipc_process_id) { | 72 ipc_process_id_(ipc_process_id) { |
| 79 DCHECK(indexed_db_context_.get()); | 73 DCHECK(indexed_db_context_.get()); |
| 80 } | 74 } |
| 81 | 75 |
| 82 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { | 76 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { |
| 83 } | 77 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 95 | 89 |
| 96 void IndexedDBDispatcherHost::ResetDispatcherHosts() { | 90 void IndexedDBDispatcherHost::ResetDispatcherHosts() { |
| 97 // It is important that the various *_dispatcher_host_ members are reset | 91 // It is important that the various *_dispatcher_host_ members are reset |
| 98 // on the WebKit thread, since there might be incoming messages on that | 92 // on the WebKit thread, since there might be incoming messages on that |
| 99 // thread, and we must not reset the dispatcher hosts until after those | 93 // thread, and we must not reset the dispatcher hosts until after those |
| 100 // messages are processed. | 94 // messages are processed. |
| 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED) || | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED) || |
| 102 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); | 96 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); |
| 103 | 97 |
| 104 database_dispatcher_host_.reset(); | 98 database_dispatcher_host_.reset(); |
| 105 index_dispatcher_host_.reset(); | |
| 106 object_store_dispatcher_host_.reset(); | |
| 107 cursor_dispatcher_host_.reset(); | 99 cursor_dispatcher_host_.reset(); |
| 108 transaction_dispatcher_host_.reset(); | 100 transaction_dispatcher_host_.reset(); |
| 109 } | 101 } |
| 110 | 102 |
| 111 void IndexedDBDispatcherHost::OverrideThreadForMessage( | 103 void IndexedDBDispatcherHost::OverrideThreadForMessage( |
| 112 const IPC::Message& message, | 104 const IPC::Message& message, |
| 113 BrowserThread::ID* thread) { | 105 BrowserThread::ID* thread) { |
| 114 if (IPC_MESSAGE_CLASS(message) == IndexedDBMsgStart) | 106 if (IPC_MESSAGE_CLASS(message) == IndexedDBMsgStart) |
| 115 *thread = BrowserThread::WEBKIT_DEPRECATED; | 107 *thread = BrowserThread::WEBKIT_DEPRECATED; |
| 116 } | 108 } |
| 117 | 109 |
| 118 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message, | 110 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 119 bool* message_was_ok) { | 111 bool* message_was_ok) { |
| 120 if (IPC_MESSAGE_CLASS(message) != IndexedDBMsgStart) | 112 if (IPC_MESSAGE_CLASS(message) != IndexedDBMsgStart) |
| 121 return false; | 113 return false; |
| 122 | 114 |
| 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 124 | 116 |
| 125 bool handled = | 117 bool handled = |
| 126 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | 118 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 127 index_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | |
| 128 object_store_dispatcher_host_->OnMessageReceived( | |
| 129 message, message_was_ok) || | |
| 130 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | 119 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || |
| 131 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); | 120 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); |
| 132 | 121 |
| 133 if (!handled) { | 122 if (!handled) { |
| 134 handled = true; | 123 handled = true; |
| 135 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) | 124 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) |
| 136 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, | 125 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, |
| 137 OnIDBFactoryGetDatabaseNames) | 126 OnIDBFactoryGetDatabaseNames) |
| 138 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | 127 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
| 139 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpenOld, OnIDBFactoryOpenOld) | |
| 140 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | 128 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, |
| 141 OnIDBFactoryDeleteDatabase) | 129 OnIDBFactoryDeleteDatabase) |
| 142 IPC_MESSAGE_UNHANDLED(handled = false) | 130 IPC_MESSAGE_UNHANDLED(handled = false) |
| 143 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
| 144 } | 132 } |
| 145 return handled; | 133 return handled; |
| 146 } | 134 } |
| 147 | 135 |
| 148 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 136 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
| 149 if (!cursor_dispatcher_host_.get()) { | 137 if (!cursor_dispatcher_host_.get()) { |
| 150 delete idb_cursor; | 138 delete idb_cursor; |
| 151 return 0; | 139 return 0; |
| 152 } | 140 } |
| 153 return cursor_dispatcher_host_->map_.Add(idb_cursor); | 141 return cursor_dispatcher_host_->map_.Add(idb_cursor); |
| 154 } | 142 } |
| 155 | 143 |
| 156 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, | 144 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, |
| 157 int32 ipc_thread_id, | 145 int32 ipc_thread_id, |
| 158 const GURL& origin_url) { | 146 const GURL& origin_url) { |
| 159 if (!database_dispatcher_host_.get()) { | 147 if (!database_dispatcher_host_.get()) { |
| 160 delete idb_database; | 148 delete idb_database; |
| 161 return 0; | 149 return 0; |
| 162 } | 150 } |
| 163 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database); | 151 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database); |
| 164 Context()->ConnectionOpened(origin_url, idb_database); | 152 Context()->ConnectionOpened(origin_url, idb_database); |
| 165 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; | 153 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; |
| 166 return ipc_database_id; | 154 return ipc_database_id; |
| 167 } | 155 } |
| 168 | 156 |
| 169 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { | |
| 170 if (!index_dispatcher_host_.get()) { | |
| 171 delete idb_index; | |
| 172 return 0; | |
| 173 } | |
| 174 if (!idb_index) | |
| 175 return 0; | |
| 176 return index_dispatcher_host_->map_.Add(idb_index); | |
| 177 } | |
| 178 | |
| 179 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { | |
| 180 if (!object_store_dispatcher_host_.get()) { | |
| 181 delete idb_object_store; | |
| 182 return 0; | |
| 183 } | |
| 184 if (!idb_object_store) | |
| 185 return 0; | |
| 186 return object_store_dispatcher_host_->map_.Add(idb_object_store); | |
| 187 } | |
| 188 | |
| 189 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction, | 157 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction, |
| 190 int32 ipc_thread_id, | 158 int32 ipc_thread_id, |
| 191 const GURL& url) { | 159 const GURL& url) { |
| 192 if (!transaction_dispatcher_host_.get()) { | 160 if (!transaction_dispatcher_host_.get()) { |
| 193 delete idb_transaction; | 161 delete idb_transaction; |
| 194 return 0; | 162 return 0; |
| 195 } | 163 } |
| 196 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); | 164 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); |
| 197 idb_transaction->setCallbacks( | 165 idb_transaction->setCallbacks( |
| 198 new IndexedDBTransactionCallbacks(this, ipc_thread_id, id)); | 166 new IndexedDBTransactionCallbacks(this, ipc_thread_id, id)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 225 | 193 |
| 226 WebSecurityOrigin origin( | 194 WebSecurityOrigin origin( |
| 227 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 195 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
| 228 | 196 |
| 229 Context()->GetIDBFactory()->getDatabaseNames( | 197 Context()->GetIDBFactory()->getDatabaseNames( |
| 230 new IndexedDBCallbacks<WebDOMStringList>(this, params.ipc_thread_id, | 198 new IndexedDBCallbacks<WebDOMStringList>(this, params.ipc_thread_id, |
| 231 params.ipc_response_id), origin, NULL, | 199 params.ipc_response_id), origin, NULL, |
| 232 webkit_base::FilePathToWebString(indexed_db_path)); | 200 webkit_base::FilePathToWebString(indexed_db_path)); |
| 233 } | 201 } |
| 234 | 202 |
| 235 void IndexedDBDispatcherHost::OnIDBFactoryOpenOld( | |
| 236 const IndexedDBHostMsg_FactoryOpen_Params& params) { | |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 238 FilePath indexed_db_path = indexed_db_context_->data_path(); | |
| 239 | |
| 240 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); | |
| 241 WebSecurityOrigin origin( | |
| 242 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | |
| 243 | |
| 244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 245 | |
| 246 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | |
| 247 // created) if this origin is already over quota. | |
| 248 Context()->GetIDBFactory()->open( | |
| 249 params.name, | |
| 250 params.version, | |
| 251 new IndexedDBCallbacksDatabase(this, params.ipc_thread_id, | |
| 252 params.ipc_response_id, origin_url), | |
| 253 new IndexedDBDatabaseCallbacks(this, params.ipc_thread_id, | |
| 254 params.ipc_database_response_id), | |
| 255 origin, NULL, webkit_base::FilePathToWebString(indexed_db_path)); | |
| 256 } | |
| 257 | |
| 258 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 203 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
| 259 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 204 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
| 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 261 FilePath indexed_db_path = indexed_db_context_->data_path(); | 206 FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 262 | 207 |
| 263 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); | 208 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin); |
| 264 WebSecurityOrigin origin( | 209 WebSecurityOrigin origin( |
| 265 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 210 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
| 266 | 211 |
| 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 291 } |
| 347 } | 292 } |
| 348 } | 293 } |
| 349 | 294 |
| 350 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 295 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
| 351 const IPC::Message& message, bool* msg_is_ok) { | 296 const IPC::Message& message, bool* msg_is_ok) { |
| 352 bool handled = true; | 297 bool handled = true; |
| 353 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 298 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
| 354 message, *msg_is_ok) | 299 message, *msg_is_ok) |
| 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 300 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
| 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStoreOld, | |
| 357 OnCreateObjectStoreOld) | |
| 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 301 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 359 OnCreateObjectStore) | 302 OnCreateObjectStore) |
| 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 303 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 361 OnDeleteObjectStore) | 304 OnDeleteObjectStore) |
| 362 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStoreOld, | |
| 363 OnDeleteObjectStoreOld) | |
| 364 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 305 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
| 365 OnCreateTransaction) | 306 OnCreateTransaction) |
| 366 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 307 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 367 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 308 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 368 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 309 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| 369 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | 310 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
| 370 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | 311 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, |
| 371 OnSetIndexKeys) | 312 OnSetIndexKeys) |
| 372 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | 313 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
| 373 OnSetIndexesReady) | 314 OnSetIndexesReady) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 idb_index_metadata.name = web_index_metadata.name; | 362 idb_index_metadata.name = web_index_metadata.name; |
| 422 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); | 363 idb_index_metadata.keyPath = IndexedDBKeyPath(web_index_metadata.keyPath); |
| 423 idb_index_metadata.unique = web_index_metadata.unique; | 364 idb_index_metadata.unique = web_index_metadata.unique; |
| 424 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; | 365 idb_index_metadata.multiEntry = web_index_metadata.multiEntry; |
| 425 idb_store_metadata.indexes.push_back(idb_index_metadata); | 366 idb_store_metadata.indexes.push_back(idb_index_metadata); |
| 426 } | 367 } |
| 427 metadata->object_stores.push_back(idb_store_metadata); | 368 metadata->object_stores.push_back(idb_store_metadata); |
| 428 } | 369 } |
| 429 } | 370 } |
| 430 | 371 |
| 431 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStoreOld( | |
| 432 const IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params& params, | |
| 433 int32* object_store_id, WebKit::WebExceptionCode* ec) { | |
| 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 435 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | |
| 436 &map_, params.ipc_database_id); | |
| 437 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 438 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 439 if (!idb_database || !idb_transaction) | |
| 440 return; | |
| 441 | |
| 442 *ec = 0; | |
| 443 WebIDBObjectStore* object_store = idb_database->createObjectStore( | |
| 444 params.id, params.name, params.key_path, params.auto_increment, | |
| 445 *idb_transaction, *ec); | |
| 446 *object_store_id = *ec ? 0 : parent_->Add(object_store); | |
| 447 if (parent_->Context()->IsOverQuota( | |
| 448 database_url_map_[params.ipc_database_id])) { | |
| 449 idb_transaction->abort(); | |
| 450 } | |
| 451 } | |
| 452 | |
| 453 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( | 372 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( |
| 454 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { | 373 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { |
| 455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 456 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 375 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 457 &map_, params.ipc_database_id); | 376 &map_, params.ipc_database_id); |
| 458 if (!database) | 377 if (!database) |
| 459 return; | 378 return; |
| 460 | 379 |
| 461 database->createObjectStore( | 380 database->createObjectStore( |
| 462 parent_->HostTransactionId(params.transaction_id), | 381 parent_->HostTransactionId(params.transaction_id), |
| 463 params.object_store_id, | 382 params.object_store_id, |
| 464 params.name, params.key_path, params.auto_increment); | 383 params.name, params.key_path, params.auto_increment); |
| 465 if (parent_->Context()->IsOverQuota( | 384 if (parent_->Context()->IsOverQuota( |
| 466 database_url_map_[params.ipc_database_id])) { | 385 database_url_map_[params.ipc_database_id])) { |
| 467 database->abort(params.transaction_id); | 386 database->abort(params.transaction_id); |
| 468 } | 387 } |
| 469 } | 388 } |
| 470 | 389 |
| 471 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStoreOld( | |
| 472 int32 ipc_database_id, | |
| 473 int64 object_store_id, | |
| 474 int32 ipc_transaction_id, | |
| 475 WebKit::WebExceptionCode* ec) { | |
| 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 477 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | |
| 478 &map_, ipc_database_id); | |
| 479 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 480 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 481 if (!idb_database || !idb_transaction) | |
| 482 return; | |
| 483 | |
| 484 *ec = 0; | |
| 485 idb_database->deleteObjectStore(object_store_id, *idb_transaction, *ec); | |
| 486 } | |
| 487 | |
| 488 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( | 390 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( |
| 489 int32 ipc_database_id, | 391 int32 ipc_database_id, |
| 490 int64 transaction_id, | 392 int64 transaction_id, |
| 491 int64 object_store_id) { | 393 int64 object_store_id) { |
| 492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 493 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 395 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 494 &map_, ipc_database_id); | 396 &map_, ipc_database_id); |
| 495 if (!database) | 397 if (!database) |
| 496 return; | 398 return; |
| 497 | 399 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 622 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 721 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 623 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 722 &map_, ipc_database_id); | 624 &map_, ipc_database_id); |
| 723 if (!database) | 625 if (!database) |
| 724 return; | 626 return; |
| 725 | 627 |
| 726 database->deleteIndex(parent_->HostTransactionId(transaction_id), | 628 database->deleteIndex(parent_->HostTransactionId(transaction_id), |
| 727 object_store_id, index_id); | 629 object_store_id, index_id); |
| 728 } | 630 } |
| 729 | 631 |
| 730 | |
| 731 ////////////////////////////////////////////////////////////////////// | |
| 732 // IndexedDBDispatcherHost::IndexDispatcherHost | |
| 733 // | |
| 734 | |
| 735 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | |
| 736 IndexedDBDispatcherHost* parent) | |
| 737 : parent_(parent) { | |
| 738 map_.set_check_on_null_data(true); | |
| 739 } | |
| 740 | |
| 741 IndexedDBDispatcherHost::IndexDispatcherHost::~IndexDispatcherHost() { | |
| 742 } | |
| 743 | |
| 744 bool IndexedDBDispatcherHost::IndexDispatcherHost::OnMessageReceived( | |
| 745 const IPC::Message& message, bool* msg_is_ok) { | |
| 746 bool handled = true; | |
| 747 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::IndexDispatcherHost, | |
| 748 message, *msg_is_ok) | |
| 749 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenObjectCursor, | |
| 750 OnOpenObjectCursor) | |
| 751 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexOpenKeyCursor, OnOpenKeyCursor) | |
| 752 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexCount, OnCount) | |
| 753 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetObject, OnGetObject) | |
| 754 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexGetKey, OnGetKey) | |
| 755 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_IndexDestroyed, OnDestroyed) | |
| 756 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 757 IPC_END_MESSAGE_MAP() | |
| 758 return handled; | |
| 759 } | |
| 760 | |
| 761 void IndexedDBDispatcherHost::IndexDispatcherHost::Send( | |
| 762 IPC::Message* message) { | |
| 763 parent_->Send(message); | |
| 764 } | |
| 765 | |
| 766 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenObjectCursor( | |
| 767 const IndexedDBHostMsg_IndexOpenCursor_Params& params) { | |
| 768 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 769 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 770 &map_, params.ipc_index_id); | |
| 771 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 772 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 773 if (!idb_transaction || !idb_index) | |
| 774 return; | |
| 775 | |
| 776 WebKit::WebExceptionCode ec = 0; | |
| 777 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 778 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, | |
| 779 params.ipc_response_id, -1)); | |
| 780 idb_index->openObjectCursor( | |
| 781 params.key_range, params.direction, callbacks.release(), | |
| 782 *idb_transaction, ec); | |
| 783 DCHECK(!ec); | |
| 784 } | |
| 785 | |
| 786 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( | |
| 787 const IndexedDBHostMsg_IndexOpenCursor_Params& params) { | |
| 788 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 789 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 790 &map_, params.ipc_index_id); | |
| 791 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 792 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 793 if (!idb_transaction || !idb_index) | |
| 794 return; | |
| 795 | |
| 796 WebKit::WebExceptionCode ec = 0; | |
| 797 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 798 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, | |
| 799 params.ipc_response_id, -1)); | |
| 800 idb_index->openKeyCursor( | |
| 801 params.key_range, params.direction, callbacks.release(), | |
| 802 *idb_transaction, ec); | |
| 803 DCHECK(!ec); | |
| 804 } | |
| 805 | |
| 806 void IndexedDBDispatcherHost::IndexDispatcherHost::OnCount( | |
| 807 const IndexedDBHostMsg_IndexCount_Params& params) { | |
| 808 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 809 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 810 &map_, params.ipc_index_id); | |
| 811 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 812 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 813 if (!idb_transaction || !idb_index) | |
| 814 return; | |
| 815 | |
| 816 WebKit::WebExceptionCode ec = 0; | |
| 817 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 818 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, | |
| 819 params.ipc_thread_id, | |
| 820 params.ipc_response_id)); | |
| 821 idb_index->count( | |
| 822 params.key_range, callbacks.release(), *idb_transaction, ec); | |
| 823 DCHECK(!ec); | |
| 824 } | |
| 825 | |
| 826 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | |
| 827 int ipc_index_id, | |
| 828 int32 ipc_thread_id, | |
| 829 int32 ipc_response_id, | |
| 830 const IndexedDBKeyRange& key_range, | |
| 831 int32 ipc_transaction_id) { | |
| 832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 833 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 834 &map_, ipc_index_id); | |
| 835 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 836 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 837 if (!idb_transaction || !idb_index) | |
| 838 return; | |
| 839 | |
| 840 WebKit::WebExceptionCode ec = 0; | |
| 841 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 842 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, ipc_thread_id, | |
| 843 ipc_response_id)); | |
| 844 idb_index->getObject(key_range, callbacks.release(), *idb_transaction, ec); | |
| 845 DCHECK(!ec); | |
| 846 } | |
| 847 | |
| 848 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | |
| 849 int ipc_index_id, | |
| 850 int32 ipc_thread_id, | |
| 851 int32 ipc_response_id, | |
| 852 const IndexedDBKeyRange& key_range, | |
| 853 int32 ipc_transaction_id) { | |
| 854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 855 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | |
| 856 &map_, ipc_index_id); | |
| 857 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 858 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 859 if (!idb_transaction || !idb_index) | |
| 860 return; | |
| 861 | |
| 862 WebKit::WebExceptionCode ec = 0; | |
| 863 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 864 new IndexedDBCallbacks<WebIDBKey>(parent_, ipc_thread_id, | |
| 865 ipc_response_id)); | |
| 866 idb_index->getKey(key_range, callbacks.release(), *idb_transaction, ec); | |
| 867 DCHECK(!ec); | |
| 868 } | |
| 869 | |
| 870 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( | |
| 871 int32 ipc_object_id) { | |
| 872 parent_->DestroyObject(&map_, ipc_object_id); | |
| 873 } | |
| 874 | |
| 875 ////////////////////////////////////////////////////////////////////// | |
| 876 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost | |
| 877 // | |
| 878 | |
| 879 IndexedDBDispatcherHost::ObjectStoreDispatcherHost::ObjectStoreDispatcherHost( | |
| 880 IndexedDBDispatcherHost* parent) | |
| 881 : parent_(parent) { | |
| 882 map_.set_check_on_null_data(true); | |
| 883 } | |
| 884 | |
| 885 IndexedDBDispatcherHost:: | |
| 886 ObjectStoreDispatcherHost::~ObjectStoreDispatcherHost() { | |
| 887 } | |
| 888 | |
| 889 bool IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnMessageReceived( | |
| 890 const IPC::Message& message, bool* msg_is_ok) { | |
| 891 bool handled = true; | |
| 892 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::ObjectStoreDispatcherHost, | |
| 893 message, *msg_is_ok) | |
| 894 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreGet, OnGet) | |
| 895 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStorePut, OnPut) | |
| 896 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexKeys, | |
| 897 OnSetIndexKeys) | |
| 898 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreSetIndexesReady, | |
| 899 OnSetIndexesReady) | |
| 900 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDelete, OnDelete) | |
| 901 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreClear, OnClear) | |
| 902 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCreateIndex, OnCreateIndex) | |
| 903 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreIndex, OnIndex) | |
| 904 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDeleteIndex, OnDeleteIndex) | |
| 905 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreOpenCursor, OnOpenCursor) | |
| 906 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreCount, OnCount) | |
| 907 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_ObjectStoreDestroyed, OnDestroyed) | |
| 908 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 909 IPC_END_MESSAGE_MAP() | |
| 910 return handled; | |
| 911 } | |
| 912 | |
| 913 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::Send( | |
| 914 IPC::Message* message) { | |
| 915 parent_->Send(message); | |
| 916 } | |
| 917 | |
| 918 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( | |
| 919 int ipc_object_store_id, | |
| 920 int32 ipc_thread_id, | |
| 921 int32 ipc_response_id, | |
| 922 const IndexedDBKeyRange& key_range, | |
| 923 int32 ipc_transaction_id) { | |
| 924 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 925 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 926 &map_, ipc_object_store_id); | |
| 927 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 928 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 929 if (!idb_transaction || !idb_object_store) | |
| 930 return; | |
| 931 | |
| 932 WebKit::WebExceptionCode ec = 0; | |
| 933 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 934 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, ipc_thread_id, | |
| 935 ipc_response_id)); | |
| 936 idb_object_store->get(key_range, callbacks.release(), *idb_transaction, ec); | |
| 937 DCHECK(!ec); | |
| 938 } | |
| 939 | |
| 940 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( | |
| 941 const IndexedDBHostMsg_ObjectStorePut_Params& params) { | |
| 942 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 943 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 944 &map_, params.ipc_object_store_id); | |
| 945 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 946 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 947 if (!idb_transaction || !idb_object_store) | |
| 948 return; | |
| 949 | |
| 950 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 951 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | |
| 952 params.ipc_response_id)); | |
| 953 idb_object_store->put(params.serialized_value, params.key, | |
| 954 params.put_mode, callbacks.release(), | |
| 955 *idb_transaction, params.index_ids, | |
| 956 params.index_keys); | |
| 957 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); | |
| 958 WebIDBTransactionIPCIDToSizeMap* map = | |
| 959 &parent_->transaction_dispatcher_host_->transaction_ipc_size_map_; | |
| 960 (*map)[params.ipc_transaction_id] += size; | |
| 961 } | |
| 962 | |
| 963 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexKeys( | |
| 964 int32 ipc_object_store_id, | |
| 965 const IndexedDBKey& primary_key, | |
| 966 const std::vector<int64>& index_names, | |
| 967 const std::vector<std::vector<IndexedDBKey> >& index_keys, | |
| 968 int32 ipc_transaction_id) { | |
| 969 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 970 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 971 &map_, ipc_object_store_id); | |
| 972 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 973 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 974 if (!idb_transaction || !idb_object_store) | |
| 975 return; | |
| 976 idb_object_store->setIndexKeys(primary_key, | |
| 977 WebVector<long long>(index_names), | |
| 978 index_keys, *idb_transaction); | |
| 979 } | |
| 980 | |
| 981 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnSetIndexesReady( | |
| 982 int32 ipc_object_store_id, | |
| 983 const std::vector<int64>& index_ids, | |
| 984 int32 ipc_transaction_id) { | |
| 985 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 986 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 987 &map_, ipc_object_store_id); | |
| 988 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 989 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 990 if (!idb_transaction || !idb_object_store) | |
| 991 return; | |
| 992 | |
| 993 idb_object_store->setIndexesReady(WebVector<long long>(index_ids), | |
| 994 *idb_transaction); | |
| 995 } | |
| 996 | |
| 997 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( | |
| 998 int ipc_object_store_id, | |
| 999 int32 ipc_thread_id, | |
| 1000 int32 ipc_response_id, | |
| 1001 const IndexedDBKeyRange& key_range, | |
| 1002 int32 ipc_transaction_id) { | |
| 1003 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1004 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1005 &map_, ipc_object_store_id); | |
| 1006 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1007 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 1008 if (!idb_transaction || !idb_object_store) | |
| 1009 return; | |
| 1010 | |
| 1011 WebKit::WebExceptionCode ec = 0; | |
| 1012 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 1013 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, ipc_thread_id, | |
| 1014 ipc_response_id)); | |
| 1015 idb_object_store->deleteFunction( | |
| 1016 key_range, callbacks.release(), *idb_transaction, ec); | |
| 1017 DCHECK(!ec); | |
| 1018 } | |
| 1019 | |
| 1020 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnClear( | |
| 1021 int ipc_object_store_id, | |
| 1022 int32 ipc_thread_id, | |
| 1023 int32 ipc_response_id, | |
| 1024 int32 ipc_transaction_id) { | |
| 1025 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1026 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1027 &map_, ipc_object_store_id); | |
| 1028 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1029 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 1030 if (!idb_transaction || !idb_object_store) | |
| 1031 return; | |
| 1032 | |
| 1033 WebKit::WebExceptionCode ec = 0; | |
| 1034 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 1035 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, ipc_thread_id, | |
| 1036 ipc_response_id)); | |
| 1037 idb_object_store->clear(callbacks.release(), *idb_transaction, ec); | |
| 1038 DCHECK(!ec); | |
| 1039 } | |
| 1040 | |
| 1041 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( | |
| 1042 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, | |
| 1043 int32* index_id, WebKit::WebExceptionCode* ec) { | |
| 1044 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1045 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1046 &map_, params.ipc_object_store_id); | |
| 1047 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1048 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 1049 if (!idb_object_store || !idb_transaction) | |
| 1050 return; | |
| 1051 | |
| 1052 *ec = 0; | |
| 1053 WebIDBIndex* index = idb_object_store->createIndex( | |
| 1054 params.id, params.name, params.key_path, params.unique, | |
| 1055 params.multi_entry, *idb_transaction, *ec); | |
| 1056 *index_id = *ec ? 0 : parent_->Add(index); | |
| 1057 WebIDBObjectIDToURLMap* transaction_url_map = | |
| 1058 &parent_->transaction_dispatcher_host_->transaction_url_map_; | |
| 1059 if (parent_->Context()->IsOverQuota( | |
| 1060 (*transaction_url_map)[params.ipc_transaction_id])) { | |
| 1061 idb_transaction->abort(); | |
| 1062 } | |
| 1063 } | |
| 1064 | |
| 1065 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( | |
| 1066 int32 ipc_object_store_id, | |
| 1067 int64 index_id, | |
| 1068 int32* ipc_index_id) { | |
| 1069 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1070 &map_, ipc_object_store_id); | |
| 1071 if (!idb_object_store) | |
| 1072 return; | |
| 1073 | |
| 1074 WebIDBIndex* index = idb_object_store->index(index_id); | |
| 1075 *ipc_index_id = parent_->Add(index); | |
| 1076 } | |
| 1077 | |
| 1078 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDeleteIndex( | |
| 1079 int32 ipc_object_store_id, | |
| 1080 int64 index_id, | |
| 1081 int32 ipc_transaction_id, | |
| 1082 WebKit::WebExceptionCode* ec) { | |
| 1083 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1084 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1085 &map_, ipc_object_store_id); | |
| 1086 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1087 &parent_->transaction_dispatcher_host_->map_, ipc_transaction_id); | |
| 1088 if (!idb_object_store || !idb_transaction) | |
| 1089 return; | |
| 1090 | |
| 1091 *ec = 0; | |
| 1092 idb_object_store->deleteIndex(index_id, *idb_transaction, *ec); | |
| 1093 } | |
| 1094 | |
| 1095 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnOpenCursor( | |
| 1096 const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params) { | |
| 1097 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1098 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1099 &parent_->object_store_dispatcher_host_->map_, | |
| 1100 params.ipc_object_store_id); | |
| 1101 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1102 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 1103 if (!idb_transaction || !idb_object_store) | |
| 1104 return; | |
| 1105 | |
| 1106 WebKit::WebExceptionCode ec = 0; | |
| 1107 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 1108 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.ipc_thread_id, | |
| 1109 params.ipc_response_id, -1)); | |
| 1110 idb_object_store->openCursor( | |
| 1111 params.key_range, params.direction, callbacks.release(), | |
| 1112 params.task_type, | |
| 1113 *idb_transaction, ec); | |
| 1114 DCHECK(!ec); | |
| 1115 } | |
| 1116 | |
| 1117 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCount( | |
| 1118 const IndexedDBHostMsg_ObjectStoreCount_Params& params) { | |
| 1119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 1120 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | |
| 1121 &parent_->object_store_dispatcher_host_->map_, | |
| 1122 params.ipc_object_store_id); | |
| 1123 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1124 &parent_->transaction_dispatcher_host_->map_, params.ipc_transaction_id); | |
| 1125 if (!idb_transaction || !idb_object_store) | |
| 1126 return; | |
| 1127 | |
| 1128 WebKit::WebExceptionCode ec = 0; | |
| 1129 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 1130 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, | |
| 1131 params.ipc_thread_id, | |
| 1132 params.ipc_response_id)); | |
| 1133 idb_object_store->count( | |
| 1134 params.key_range, callbacks.release(), *idb_transaction, ec); | |
| 1135 DCHECK(!ec); | |
| 1136 } | |
| 1137 | |
| 1138 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | |
| 1139 int32 ipc_object_id) { | |
| 1140 parent_->DestroyObject(&map_, ipc_object_id); | |
| 1141 } | |
| 1142 | |
| 1143 ////////////////////////////////////////////////////////////////////// | 632 ////////////////////////////////////////////////////////////////////// |
| 1144 // IndexedDBDispatcherHost::CursorDispatcherHost | 633 // IndexedDBDispatcherHost::CursorDispatcherHost |
| 1145 // | 634 // |
| 1146 | 635 |
| 1147 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 636 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
| 1148 IndexedDBDispatcherHost* parent) | 637 IndexedDBDispatcherHost* parent) |
| 1149 : parent_(parent) { | 638 : parent_(parent) { |
| 1150 map_.set_check_on_null_data(true); | 639 map_.set_check_on_null_data(true); |
| 1151 } | 640 } |
| 1152 | 641 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 } | 776 } |
| 1288 } | 777 } |
| 1289 | 778 |
| 1290 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( | 779 bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( |
| 1291 const IPC::Message& message, bool* msg_is_ok) { | 780 const IPC::Message& message, bool* msg_is_ok) { |
| 1292 bool handled = true; | 781 bool handled = true; |
| 1293 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, | 782 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, |
| 1294 message, *msg_is_ok) | 783 message, *msg_is_ok) |
| 1295 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionCommit, OnCommit) | 784 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionCommit, OnCommit) |
| 1296 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionAbort, OnAbort) | 785 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionAbort, OnAbort) |
| 1297 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionObjectStore, OnObjectStore) | |
| 1298 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDidCompleteTaskEvents, | 786 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDidCompleteTaskEvents, |
| 1299 OnDidCompleteTaskEvents) | 787 OnDidCompleteTaskEvents) |
| 1300 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDestroyed, OnDestroyed) | 788 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_TransactionDestroyed, OnDestroyed) |
| 1301 IPC_MESSAGE_UNHANDLED(handled = false) | 789 IPC_MESSAGE_UNHANDLED(handled = false) |
| 1302 IPC_END_MESSAGE_MAP() | 790 IPC_END_MESSAGE_MAP() |
| 1303 return handled; | 791 return handled; |
| 1304 } | 792 } |
| 1305 | 793 |
| 1306 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( | 794 void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( |
| 1307 IPC::Message* message) { | 795 IPC::Message* message) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1330 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( | 818 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnAbort( |
| 1331 int32 ipc_transaction_id) { | 819 int32 ipc_transaction_id) { |
| 1332 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 820 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1333 &map_, ipc_transaction_id); | 821 &map_, ipc_transaction_id); |
| 1334 if (!idb_transaction) | 822 if (!idb_transaction) |
| 1335 return; | 823 return; |
| 1336 | 824 |
| 1337 idb_transaction->abort(); | 825 idb_transaction->abort(); |
| 1338 } | 826 } |
| 1339 | 827 |
| 1340 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( | |
| 1341 int32 ipc_transaction_id, int64 object_store_id, int32* ipc_object_store_id, | |
| 1342 WebKit::WebExceptionCode* ec) { | |
| 1343 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | |
| 1344 &map_, ipc_transaction_id); | |
| 1345 if (!idb_transaction) | |
| 1346 return; | |
| 1347 | |
| 1348 *ec = 0; | |
| 1349 WebIDBObjectStore* object_store = | |
| 1350 idb_transaction->objectStore(object_store_id, *ec); | |
| 1351 *ipc_object_store_id = object_store ? parent_->Add(object_store) : 0; | |
| 1352 } | |
| 1353 | |
| 1354 void IndexedDBDispatcherHost:: | 828 void IndexedDBDispatcherHost:: |
| 1355 TransactionDispatcherHost::OnDidCompleteTaskEvents(int ipc_transaction_id) { | 829 TransactionDispatcherHost::OnDidCompleteTaskEvents(int ipc_transaction_id) { |
| 1356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 830 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 1357 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 831 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
| 1358 &map_, ipc_transaction_id); | 832 &map_, ipc_transaction_id); |
| 1359 if (!idb_transaction) | 833 if (!idb_transaction) |
| 1360 return; | 834 return; |
| 1361 idb_transaction->didCompleteTaskEvents(); | 835 idb_transaction->didCompleteTaskEvents(); |
| 1362 } | 836 } |
| 1363 | 837 |
| 1364 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 838 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
| 1365 int32 ipc_object_id) { | 839 int32 ipc_object_id) { |
| 1366 // TODO(dgrogan): This doesn't seem to be happening with some version change | 840 // TODO(dgrogan): This doesn't seem to be happening with some version change |
| 1367 // transactions. Possibly introduced with integer version support. | 841 // transactions. Possibly introduced with integer version support. |
| 1368 transaction_ipc_size_map_.erase(ipc_object_id); | 842 transaction_ipc_size_map_.erase(ipc_object_id); |
| 1369 transaction_url_map_.erase(ipc_object_id); | 843 transaction_url_map_.erase(ipc_object_id); |
| 1370 parent_->DestroyObject(&map_, ipc_object_id); | 844 parent_->DestroyObject(&map_, ipc_object_id); |
| 1371 } | 845 } |
| 1372 | 846 |
| 1373 } // namespace content | 847 } // namespace content |
| OLD | NEW |