OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { | 142 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { |
143 if (!cursor_dispatcher_host_.get()) { | 143 if (!cursor_dispatcher_host_.get()) { |
144 delete idb_cursor; | 144 delete idb_cursor; |
145 return 0; | 145 return 0; |
146 } | 146 } |
147 return cursor_dispatcher_host_->map_.Add(idb_cursor); | 147 return cursor_dispatcher_host_->map_.Add(idb_cursor); |
148 } | 148 } |
149 | 149 |
150 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, | 150 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, |
| 151 int32 thread_id, |
151 const GURL& origin_url) { | 152 const GURL& origin_url) { |
152 if (!database_dispatcher_host_.get()) { | 153 if (!database_dispatcher_host_.get()) { |
153 delete idb_database; | 154 delete idb_database; |
154 return 0; | 155 return 0; |
155 } | 156 } |
156 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database); | 157 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database); |
157 Context()->ConnectionOpened(origin_url); | 158 Context()->ConnectionOpened(origin_url); |
158 database_dispatcher_host_->database_url_map_[idb_database_id] = origin_url; | 159 database_dispatcher_host_->database_url_map_[idb_database_id] = origin_url; |
159 return idb_database_id; | 160 return idb_database_id; |
160 } | 161 } |
(...skipping 12 matching lines...) Expand all Loading... |
173 if (!object_store_dispatcher_host_.get()) { | 174 if (!object_store_dispatcher_host_.get()) { |
174 delete idb_object_store; | 175 delete idb_object_store; |
175 return 0; | 176 return 0; |
176 } | 177 } |
177 if (!idb_object_store) | 178 if (!idb_object_store) |
178 return 0; | 179 return 0; |
179 return object_store_dispatcher_host_->map_.Add(idb_object_store); | 180 return object_store_dispatcher_host_->map_.Add(idb_object_store); |
180 } | 181 } |
181 | 182 |
182 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction, | 183 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction, |
| 184 int32 thread_id, |
183 const GURL& url) { | 185 const GURL& url) { |
184 if (!transaction_dispatcher_host_.get()) { | 186 if (!transaction_dispatcher_host_.get()) { |
185 delete idb_transaction; | 187 delete idb_transaction; |
186 return 0; | 188 return 0; |
187 } | 189 } |
188 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); | 190 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); |
189 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); | 191 idb_transaction->setCallbacks( |
| 192 new IndexedDBTransactionCallbacks(this, thread_id, id)); |
190 transaction_dispatcher_host_->transaction_url_map_[id] = url; | 193 transaction_dispatcher_host_->transaction_url_map_[id] = url; |
191 return id; | 194 return id; |
192 } | 195 } |
193 | 196 |
194 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { | 197 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { |
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
196 return cursor_dispatcher_host_->map_.Lookup(cursor_id); | 199 return cursor_dispatcher_host_->map_.Lookup(cursor_id); |
197 } | 200 } |
198 | 201 |
199 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 202 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
(...skipping 10 matching lines...) Expand all Loading... |
210 // to add some toString method to WebSecurityOrigin that doesn't | 213 // to add some toString method to WebSecurityOrigin that doesn't |
211 // return null for them. Look at | 214 // return null for them. Look at |
212 // DatabaseUtil::GetOriginFromIdentifier. | 215 // DatabaseUtil::GetOriginFromIdentifier. |
213 WebSecurityOrigin origin( | 216 WebSecurityOrigin origin( |
214 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 217 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
215 GURL origin_url(origin.toString()); | 218 GURL origin_url(origin.toString()); |
216 | 219 |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
218 | 221 |
219 Context()->GetIDBFactory()->getDatabaseNames( | 222 Context()->GetIDBFactory()->getDatabaseNames( |
220 new IndexedDBCallbacks<WebDOMStringList>(this, params.response_id), | 223 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id, |
221 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); | 224 params.response_id), origin, NULL, |
| 225 webkit_glue::FilePathToWebString(indexed_db_path)); |
222 } | 226 } |
223 | 227 |
224 void IndexedDBDispatcherHost::OnIDBFactoryOpen( | 228 void IndexedDBDispatcherHost::OnIDBFactoryOpen( |
225 const IndexedDBHostMsg_FactoryOpen_Params& params) { | 229 const IndexedDBHostMsg_FactoryOpen_Params& params) { |
226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
227 FilePath base_path = webkit_context_->data_path(); | 231 FilePath base_path = webkit_context_->data_path(); |
228 FilePath indexed_db_path; | 232 FilePath indexed_db_path; |
229 if (!base_path.empty()) { | 233 if (!base_path.empty()) { |
230 indexed_db_path = base_path.Append( | 234 indexed_db_path = base_path.Append( |
231 IndexedDBContext::kIndexedDBDirectory); | 235 IndexedDBContext::kIndexedDBDirectory); |
232 } | 236 } |
233 | 237 |
234 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need | 238 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need |
235 // to add some toString method to WebSecurityOrigin that doesn't | 239 // to add some toString method to WebSecurityOrigin that doesn't |
236 // return null for them. Look at | 240 // return null for them. Look at |
237 // DatabaseUtil::GetOriginFromIdentifier. | 241 // DatabaseUtil::GetOriginFromIdentifier. |
238 WebSecurityOrigin origin( | 242 WebSecurityOrigin origin( |
239 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); | 243 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); |
240 GURL origin_url(origin.toString()); | 244 GURL origin_url(origin.toString()); |
241 | 245 |
242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
243 | 247 |
244 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore | 248 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore |
245 // created) if this origin is already over quota. | 249 // created) if this origin is already over quota. |
246 Context()->GetIDBFactory()->open( | 250 Context()->GetIDBFactory()->open( |
247 params.name, | 251 params.name, |
248 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, | 252 new IndexedDBCallbacks<WebIDBDatabase>(this, params.thread_id, |
249 origin_url), | 253 params.response_id, origin_url), |
250 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); | 254 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); |
251 } | 255 } |
252 | 256 |
253 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 257 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
254 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 258 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
255 FilePath base_path = webkit_context_->data_path(); | 259 FilePath base_path = webkit_context_->data_path(); |
256 FilePath indexed_db_path; | 260 FilePath indexed_db_path; |
257 if (!base_path.empty()) { | 261 if (!base_path.empty()) { |
258 indexed_db_path = base_path.Append( | 262 indexed_db_path = base_path.Append( |
259 IndexedDBContext::kIndexedDBDirectory); | 263 IndexedDBContext::kIndexedDBDirectory); |
260 } | 264 } |
261 | 265 |
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
263 Context()->GetIDBFactory()->deleteDatabase( | 267 Context()->GetIDBFactory()->deleteDatabase( |
264 params.name, | 268 params.name, |
265 new IndexedDBCallbacks<WebSerializedScriptValue>(this, | 269 new IndexedDBCallbacks<WebSerializedScriptValue>(this, |
| 270 params.thread_id, |
266 params.response_id), | 271 params.response_id), |
267 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, | 272 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, |
268 webkit_glue::FilePathToWebString(indexed_db_path)); | 273 webkit_glue::FilePathToWebString(indexed_db_path)); |
269 } | 274 } |
270 | 275 |
271 void IndexedDBDispatcherHost::TransactionComplete(int32 transaction_id) { | 276 void IndexedDBDispatcherHost::TransactionComplete(int32 transaction_id) { |
272 Context()->TransactionComplete( | 277 Context()->TransactionComplete( |
273 transaction_dispatcher_host_->transaction_url_map_[transaction_id]); | 278 transaction_dispatcher_host_->transaction_url_map_[transaction_id]); |
274 } | 279 } |
275 | 280 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 416 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
412 if (!idb_database || !idb_transaction) | 417 if (!idb_database || !idb_transaction) |
413 return; | 418 return; |
414 | 419 |
415 *ec = 0; | 420 *ec = 0; |
416 idb_database->deleteObjectStore(name, *idb_transaction, *ec); | 421 idb_database->deleteObjectStore(name, *idb_transaction, *ec); |
417 } | 422 } |
418 | 423 |
419 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( | 424 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetVersion( |
420 int32 idb_database_id, | 425 int32 idb_database_id, |
| 426 int32 thread_id, |
421 int32 response_id, | 427 int32 response_id, |
422 const string16& version, | 428 const string16& version, |
423 WebKit::WebExceptionCode* ec) { | 429 WebKit::WebExceptionCode* ec) { |
424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
425 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( | 431 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( |
426 &map_, idb_database_id); | 432 &map_, idb_database_id); |
427 if (!idb_database) | 433 if (!idb_database) |
428 return; | 434 return; |
429 | 435 |
430 *ec = 0; | 436 *ec = 0; |
431 idb_database->setVersion( | 437 idb_database->setVersion( |
432 version, | 438 version, |
433 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id, | 439 new IndexedDBCallbacks<WebIDBTransaction>(parent_, thread_id, response_id, |
434 database_url_map_[idb_database_id]), | 440 database_url_map_[idb_database_id]), |
435 *ec); | 441 *ec); |
436 } | 442 } |
437 | 443 |
438 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( | 444 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( |
| 445 int32 thread_id, |
439 int32 idb_database_id, | 446 int32 idb_database_id, |
440 const std::vector<string16>& names, | 447 const std::vector<string16>& names, |
441 int32 mode, | 448 int32 mode, |
442 int32* idb_transaction_id, | 449 int32* idb_transaction_id, |
443 WebKit::WebExceptionCode* ec) { | 450 WebKit::WebExceptionCode* ec) { |
444 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 451 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
445 &map_, idb_database_id); | 452 &map_, idb_database_id); |
446 if (!database) | 453 if (!database) |
447 return; | 454 return; |
448 | 455 |
449 WebDOMStringList object_stores; | 456 WebDOMStringList object_stores; |
450 for (std::vector<string16>::const_iterator it = names.begin(); | 457 for (std::vector<string16>::const_iterator it = names.begin(); |
451 it != names.end(); ++it) { | 458 it != names.end(); ++it) { |
452 object_stores.append(*it); | 459 object_stores.append(*it); |
453 } | 460 } |
454 | 461 |
455 *ec = 0; | 462 *ec = 0; |
456 WebIDBTransaction* transaction = database->transaction( | 463 WebIDBTransaction* transaction = database->transaction( |
457 object_stores, mode, *ec); | 464 object_stores, mode, *ec); |
458 DCHECK(!transaction != !*ec); | 465 DCHECK(!transaction != !*ec); |
459 *idb_transaction_id = | 466 *idb_transaction_id = |
460 *ec ? 0 : parent_->Add(transaction, database_url_map_[idb_database_id]); | 467 *ec ? 0 : parent_->Add(transaction, thread_id, |
| 468 database_url_map_[idb_database_id]); |
461 } | 469 } |
462 | 470 |
463 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen( | 471 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen( |
464 int32 idb_database_id, int32 response_id) { | 472 int32 idb_database_id, int32 thread_id, int32 response_id) { |
465 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 473 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
466 &map_, idb_database_id); | 474 &map_, idb_database_id); |
467 if (!database) | 475 if (!database) |
468 return; | 476 return; |
469 database->open(new IndexedDBDatabaseCallbacks(parent_, response_id)); | 477 database->open(new IndexedDBDatabaseCallbacks(parent_, thread_id, |
| 478 response_id)); |
470 } | 479 } |
471 | 480 |
472 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( | 481 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( |
473 int32 idb_database_id) { | 482 int32 idb_database_id) { |
474 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 483 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
475 &map_, idb_database_id); | 484 &map_, idb_database_id); |
476 if (!database) | 485 if (!database) |
477 return; | 486 return; |
478 database->close(); | 487 database->close(); |
479 } | 488 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 561 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
553 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 562 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
554 &map_, params.idb_index_id); | 563 &map_, params.idb_index_id); |
555 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 564 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
556 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 565 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
557 if (!idb_transaction || !idb_index) | 566 if (!idb_transaction || !idb_index) |
558 return; | 567 return; |
559 | 568 |
560 *ec = 0; | 569 *ec = 0; |
561 scoped_ptr<WebIDBCallbacks> callbacks( | 570 scoped_ptr<WebIDBCallbacks> callbacks( |
562 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); | 571 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
| 572 params.response_id, -1)); |
563 idb_index->openObjectCursor( | 573 idb_index->openObjectCursor( |
564 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 574 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
565 params.upper_open), | 575 params.upper_open), |
566 params.direction, callbacks.release(), *idb_transaction, *ec); | 576 params.direction, callbacks.release(), *idb_transaction, *ec); |
567 } | 577 } |
568 | 578 |
569 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( | 579 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( |
570 const IndexedDBHostMsg_IndexOpenCursor_Params& params, | 580 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
571 WebKit::WebExceptionCode* ec) { | 581 WebKit::WebExceptionCode* ec) { |
572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
573 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 583 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
574 &map_, params.idb_index_id); | 584 &map_, params.idb_index_id); |
575 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 585 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
576 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 586 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
577 if (!idb_transaction || !idb_index) | 587 if (!idb_transaction || !idb_index) |
578 return; | 588 return; |
579 | 589 |
580 *ec = 0; | 590 *ec = 0; |
581 scoped_ptr<WebIDBCallbacks> callbacks( | 591 scoped_ptr<WebIDBCallbacks> callbacks( |
582 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); | 592 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
| 593 params.response_id, -1)); |
583 idb_index->openKeyCursor( | 594 idb_index->openKeyCursor( |
584 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 595 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
585 params.upper_open), | 596 params.upper_open), |
586 params.direction, callbacks.release(), *idb_transaction, *ec); | 597 params.direction, callbacks.release(), *idb_transaction, *ec); |
587 } | 598 } |
588 | 599 |
589 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 600 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
590 int idb_index_id, | 601 int idb_index_id, |
| 602 int32 thread_id, |
591 int32 response_id, | 603 int32 response_id, |
592 const IndexedDBKey& key, | 604 const IndexedDBKey& key, |
593 int32 transaction_id, | 605 int32 transaction_id, |
594 WebKit::WebExceptionCode* ec) { | 606 WebKit::WebExceptionCode* ec) { |
595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
596 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 608 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
597 &map_, idb_index_id); | 609 &map_, idb_index_id); |
598 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 610 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
599 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 611 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
600 if (!idb_transaction || !idb_index) | 612 if (!idb_transaction || !idb_index) |
601 return; | 613 return; |
602 | 614 |
603 *ec = 0; | 615 *ec = 0; |
604 scoped_ptr<WebIDBCallbacks> callbacks( | 616 scoped_ptr<WebIDBCallbacks> callbacks( |
605 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 617 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 618 response_id)); |
606 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); | 619 idb_index->getObject(key, callbacks.release(), *idb_transaction, *ec); |
607 } | 620 } |
608 | 621 |
609 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( | 622 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetKey( |
610 int idb_index_id, | 623 int idb_index_id, |
| 624 int32 thread_id, |
611 int32 response_id, | 625 int32 response_id, |
612 const IndexedDBKey& key, | 626 const IndexedDBKey& key, |
613 int32 transaction_id, | 627 int32 transaction_id, |
614 WebKit::WebExceptionCode* ec) { | 628 WebKit::WebExceptionCode* ec) { |
615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 629 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
616 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 630 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
617 &map_, idb_index_id); | 631 &map_, idb_index_id); |
618 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 632 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
619 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 633 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
620 if (!idb_transaction || !idb_index) | 634 if (!idb_transaction || !idb_index) |
621 return; | 635 return; |
622 | 636 |
623 *ec = 0; | 637 *ec = 0; |
624 scoped_ptr<WebIDBCallbacks> callbacks( | 638 scoped_ptr<WebIDBCallbacks> callbacks( |
625 new IndexedDBCallbacks<WebIDBKey>(parent_, response_id)); | 639 new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id)); |
626 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); | 640 idb_index->getKey(key, callbacks.release(), *idb_transaction, *ec); |
627 } | 641 } |
628 | 642 |
629 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( | 643 void IndexedDBDispatcherHost::IndexDispatcherHost::OnDestroyed( |
630 int32 object_id) { | 644 int32 object_id) { |
631 parent_->DestroyObject(&map_, object_id); | 645 parent_->DestroyObject(&map_, object_id); |
632 } | 646 } |
633 | 647 |
634 ////////////////////////////////////////////////////////////////////// | 648 ////////////////////////////////////////////////////////////////////// |
635 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost | 649 // IndexedDBDispatcherHost::ObjectStoreDispatcherHost |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 return; | 706 return; |
693 | 707 |
694 WebDOMStringList web_index_names = idb_object_store->indexNames(); | 708 WebDOMStringList web_index_names = idb_object_store->indexNames(); |
695 index_names->reserve(web_index_names.length()); | 709 index_names->reserve(web_index_names.length()); |
696 for (unsigned i = 0; i < web_index_names.length(); ++i) | 710 for (unsigned i = 0; i < web_index_names.length(); ++i) |
697 index_names->push_back(web_index_names.item(i)); | 711 index_names->push_back(web_index_names.item(i)); |
698 } | 712 } |
699 | 713 |
700 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( | 714 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnGet( |
701 int idb_object_store_id, | 715 int idb_object_store_id, |
| 716 int32 thread_id, |
702 int32 response_id, | 717 int32 response_id, |
703 const IndexedDBKey& key, | 718 const IndexedDBKey& key, |
704 int32 transaction_id, | 719 int32 transaction_id, |
705 WebKit::WebExceptionCode* ec) { | 720 WebKit::WebExceptionCode* ec) { |
706 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
707 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 722 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
708 &map_, idb_object_store_id); | 723 &map_, idb_object_store_id); |
709 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 724 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
710 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 725 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
711 if (!idb_transaction || !idb_object_store) | 726 if (!idb_transaction || !idb_object_store) |
712 return; | 727 return; |
713 | 728 |
714 *ec = 0; | 729 *ec = 0; |
715 scoped_ptr<WebIDBCallbacks> callbacks( | 730 scoped_ptr<WebIDBCallbacks> callbacks( |
716 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 731 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 732 response_id)); |
717 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); | 733 idb_object_store->get(key, callbacks.release(), *idb_transaction, *ec); |
718 } | 734 } |
719 | 735 |
720 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( | 736 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnPut( |
721 const IndexedDBHostMsg_ObjectStorePut_Params& params, | 737 const IndexedDBHostMsg_ObjectStorePut_Params& params, |
722 WebKit::WebExceptionCode* ec) { | 738 WebKit::WebExceptionCode* ec) { |
723 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 739 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
724 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 740 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
725 &map_, params.idb_object_store_id); | 741 &map_, params.idb_object_store_id); |
726 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 742 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
727 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 743 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
728 if (!idb_transaction || !idb_object_store) | 744 if (!idb_transaction || !idb_object_store) |
729 return; | 745 return; |
730 | 746 |
731 *ec = 0; | 747 *ec = 0; |
732 scoped_ptr<WebIDBCallbacks> callbacks( | 748 scoped_ptr<WebIDBCallbacks> callbacks( |
733 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); | 749 new IndexedDBCallbacks<WebIDBKey>(parent_, params.thread_id, |
| 750 params.response_id)); |
734 idb_object_store->put(params.serialized_value, params.key, params.put_mode, | 751 idb_object_store->put(params.serialized_value, params.key, params.put_mode, |
735 callbacks.release(), *idb_transaction, *ec); | 752 callbacks.release(), *idb_transaction, *ec); |
736 if (*ec) | 753 if (*ec) |
737 return; | 754 return; |
738 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); | 755 int64 size = UTF16ToUTF8(params.serialized_value.data()).size(); |
739 WebIDBTransactionIDToSizeMap* map = | 756 WebIDBTransactionIDToSizeMap* map = |
740 &parent_->transaction_dispatcher_host_->transaction_size_map_; | 757 &parent_->transaction_dispatcher_host_->transaction_size_map_; |
741 (*map)[params.transaction_id] += size; | 758 (*map)[params.transaction_id] += size; |
742 } | 759 } |
743 | 760 |
744 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( | 761 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( |
745 int idb_object_store_id, | 762 int idb_object_store_id, |
| 763 int32 thread_id, |
746 int32 response_id, | 764 int32 response_id, |
747 const IndexedDBKey& key, | 765 const IndexedDBKey& key, |
748 int32 transaction_id, | 766 int32 transaction_id, |
749 WebKit::WebExceptionCode* ec) { | 767 WebKit::WebExceptionCode* ec) { |
750 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 768 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
751 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 769 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
752 &map_, idb_object_store_id); | 770 &map_, idb_object_store_id); |
753 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 771 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
754 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 772 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
755 if (!idb_transaction || !idb_object_store) | 773 if (!idb_transaction || !idb_object_store) |
756 return; | 774 return; |
757 | 775 |
758 *ec = 0; | 776 *ec = 0; |
759 scoped_ptr<WebIDBCallbacks> callbacks( | 777 scoped_ptr<WebIDBCallbacks> callbacks( |
760 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 778 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 779 response_id)); |
761 idb_object_store->deleteFunction( | 780 idb_object_store->deleteFunction( |
762 key, callbacks.release(), *idb_transaction, *ec); | 781 key, callbacks.release(), *idb_transaction, *ec); |
763 } | 782 } |
764 | 783 |
765 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnClear( | 784 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnClear( |
766 int idb_object_store_id, | 785 int idb_object_store_id, |
| 786 int32 thread_id, |
767 int32 response_id, | 787 int32 response_id, |
768 int32 transaction_id, | 788 int32 transaction_id, |
769 WebKit::WebExceptionCode* ec) { | 789 WebKit::WebExceptionCode* ec) { |
770 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
771 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 791 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
772 &map_, idb_object_store_id); | 792 &map_, idb_object_store_id); |
773 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 793 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
774 &parent_->transaction_dispatcher_host_->map_, transaction_id); | 794 &parent_->transaction_dispatcher_host_->map_, transaction_id); |
775 if (!idb_transaction || !idb_object_store) | 795 if (!idb_transaction || !idb_object_store) |
776 return; | 796 return; |
777 | 797 |
778 *ec = 0; | 798 *ec = 0; |
779 scoped_ptr<WebIDBCallbacks> callbacks( | 799 scoped_ptr<WebIDBCallbacks> callbacks( |
780 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id)); | 800 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 801 response_id)); |
781 idb_object_store->clear(callbacks.release(), *idb_transaction, *ec); | 802 idb_object_store->clear(callbacks.release(), *idb_transaction, *ec); |
782 } | 803 } |
783 | 804 |
784 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( | 805 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnCreateIndex( |
785 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, | 806 const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params, |
786 int32* index_id, WebKit::WebExceptionCode* ec) { | 807 int32* index_id, WebKit::WebExceptionCode* ec) { |
787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 808 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
788 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 809 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
789 &map_, params.idb_object_store_id); | 810 &map_, params.idb_object_store_id); |
790 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 811 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 865 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
845 &parent_->object_store_dispatcher_host_->map_, | 866 &parent_->object_store_dispatcher_host_->map_, |
846 params.idb_object_store_id); | 867 params.idb_object_store_id); |
847 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 868 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
848 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 869 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
849 if (!idb_transaction || !idb_object_store) | 870 if (!idb_transaction || !idb_object_store) |
850 return; | 871 return; |
851 | 872 |
852 *ec = 0; | 873 *ec = 0; |
853 scoped_ptr<WebIDBCallbacks> callbacks( | 874 scoped_ptr<WebIDBCallbacks> callbacks( |
854 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); | 875 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.thread_id, |
| 876 params.response_id, -1)); |
855 idb_object_store->openCursor( | 877 idb_object_store->openCursor( |
856 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 878 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
857 params.upper_open), | 879 params.upper_open), |
858 params.direction, callbacks.release(), *idb_transaction, *ec); | 880 params.direction, callbacks.release(), *idb_transaction, *ec); |
859 } | 881 } |
860 | 882 |
861 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 883 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
862 int32 object_id) { | 884 int32 object_id) { |
863 parent_->DestroyObject(&map_, object_id); | 885 parent_->DestroyObject(&map_, object_id); |
864 } | 886 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 content::SerializedScriptValue* script_value) { | 953 content::SerializedScriptValue* script_value) { |
932 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); | 954 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); |
933 if (!idb_cursor) | 955 if (!idb_cursor) |
934 return; | 956 return; |
935 | 957 |
936 *script_value = content::SerializedScriptValue(idb_cursor->value()); | 958 *script_value = content::SerializedScriptValue(idb_cursor->value()); |
937 } | 959 } |
938 | 960 |
939 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( | 961 void IndexedDBDispatcherHost::CursorDispatcherHost::OnUpdate( |
940 int32 cursor_id, | 962 int32 cursor_id, |
| 963 int32 thread_id, |
941 int32 response_id, | 964 int32 response_id, |
942 const content::SerializedScriptValue& value, | 965 const content::SerializedScriptValue& value, |
943 WebKit::WebExceptionCode* ec) { | 966 WebKit::WebExceptionCode* ec) { |
944 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 967 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
945 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 968 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
946 if (!idb_cursor) | 969 if (!idb_cursor) |
947 return; | 970 return; |
948 | 971 |
949 *ec = 0; | 972 *ec = 0; |
950 idb_cursor->update( | 973 idb_cursor->update( |
951 value, new IndexedDBCallbacks<WebIDBKey>(parent_, response_id), *ec); | 974 value, new IndexedDBCallbacks<WebIDBKey>(parent_, thread_id, response_id), |
| 975 *ec); |
952 } | 976 } |
953 | 977 |
954 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( | 978 void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( |
955 int32 cursor_id, | 979 int32 cursor_id, |
| 980 int32 thread_id, |
956 int32 response_id, | 981 int32 response_id, |
957 const IndexedDBKey& key, | 982 const IndexedDBKey& key, |
958 WebKit::WebExceptionCode* ec) { | 983 WebKit::WebExceptionCode* ec) { |
959 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 984 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
960 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 985 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
961 if (!idb_cursor) | 986 if (!idb_cursor) |
962 return; | 987 return; |
963 | 988 |
964 *ec = 0; | 989 *ec = 0; |
965 idb_cursor->continueFunction( | 990 idb_cursor->continueFunction( |
966 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id, | 991 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, thread_id, response_id, |
967 cursor_id), *ec); | 992 cursor_id), *ec); |
968 } | 993 } |
969 | 994 |
970 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( | 995 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( |
971 int32 cursor_id, | 996 int32 cursor_id, |
| 997 int32 thread_id, |
972 int32 response_id, | 998 int32 response_id, |
973 int n, | 999 int n, |
974 WebKit::WebExceptionCode* ec) { | 1000 WebKit::WebExceptionCode* ec) { |
975 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 1001 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
976 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 1002 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
977 if (!idb_cursor) | 1003 if (!idb_cursor) |
978 return; | 1004 return; |
979 | 1005 |
980 *ec = 0; | 1006 *ec = 0; |
981 idb_cursor->prefetchContinue( | 1007 idb_cursor->prefetchContinue( |
982 n, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id, | 1008 n, new IndexedDBCallbacks<WebIDBCursor>(parent_, thread_id, response_id, |
983 cursor_id), *ec); | 1009 cursor_id), *ec); |
984 } | 1010 } |
985 | 1011 |
986 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( | 1012 void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( |
987 int32 cursor_id, int used_prefetches, int unused_prefetches) { | 1013 int32 cursor_id, int used_prefetches, int unused_prefetches) { |
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 1014 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
989 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 1015 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
990 if (!idb_cursor) | 1016 if (!idb_cursor) |
991 return; | 1017 return; |
992 | 1018 |
993 idb_cursor->prefetchReset(used_prefetches, unused_prefetches); | 1019 idb_cursor->prefetchReset(used_prefetches, unused_prefetches); |
994 } | 1020 } |
995 | 1021 |
996 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( | 1022 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( |
997 int32 cursor_id, | 1023 int32 cursor_id, |
| 1024 int32 thread_id, |
998 int32 response_id, | 1025 int32 response_id, |
999 WebKit::WebExceptionCode* ec) { | 1026 WebKit::WebExceptionCode* ec) { |
1000 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 1027 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
1001 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 1028 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
1002 if (!idb_cursor) | 1029 if (!idb_cursor) |
1003 return; | 1030 return; |
1004 | 1031 |
1005 *ec = 0; | 1032 *ec = 0; |
1006 idb_cursor->deleteFunction( | 1033 idb_cursor->deleteFunction( |
1007 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, response_id), *e
c); | 1034 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, thread_id, |
| 1035 response_id), *ec); |
1008 } | 1036 } |
1009 | 1037 |
1010 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1038 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1011 int32 object_id) { | 1039 int32 object_id) { |
1012 parent_->DestroyObject(&map_, object_id); | 1040 parent_->DestroyObject(&map_, object_id); |
1013 } | 1041 } |
1014 | 1042 |
1015 ////////////////////////////////////////////////////////////////////// | 1043 ////////////////////////////////////////////////////////////////////// |
1016 // IndexedDBDispatcherHost::TransactionDispatcherHost | 1044 // IndexedDBDispatcherHost::TransactionDispatcherHost |
1017 // | 1045 // |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 } | 1131 } |
1104 idb_transaction->didCompleteTaskEvents(); | 1132 idb_transaction->didCompleteTaskEvents(); |
1105 } | 1133 } |
1106 | 1134 |
1107 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1135 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1108 int32 object_id) { | 1136 int32 object_id) { |
1109 transaction_size_map_.erase(object_id); | 1137 transaction_size_map_.erase(object_id); |
1110 transaction_url_map_.erase(object_id); | 1138 transaction_url_map_.erase(object_id); |
1111 parent_->DestroyObject(&map_, object_id); | 1139 parent_->DestroyObject(&map_, object_id); |
1112 } | 1140 } |
OLD | NEW |