Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 16573003: Remove content/browser dependency on WebKit::WebIDBCallbacks and WebKit::WebIDBDatabaseCallbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove more #includes and forward declarations Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/process.h" 11 #include "base/process.h"
12 #include "base/process_util.h" 12 #include "base/process_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
15 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" 15 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h"
16 #include "content/browser/indexed_db/indexed_db_context_impl.h" 16 #include "content/browser/indexed_db/indexed_db_context_impl.h"
17 #include "content/browser/indexed_db/webidbcursor_impl.h"
18 #include "content/browser/indexed_db/webidbcursor_impl.h"
19 #include "content/browser/indexed_db/webidbdatabase_impl.h"
17 #include "content/browser/renderer_host/render_message_filter.h" 20 #include "content/browser/renderer_host/render_message_filter.h"
18 #include "content/common/indexed_db/indexed_db_messages.h" 21 #include "content/common/indexed_db/indexed_db_messages.h"
19 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/user_metrics.h" 23 #include "content/public/browser/user_metrics.h"
21 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
22 #include "content/public/common/result_codes.h" 25 #include "content/public/common/result_codes.h"
23 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
24 #include "third_party/WebKit/public/platform/WebData.h" 27 #include "third_party/WebKit/public/platform/WebData.h"
25 #include "third_party/WebKit/public/platform/WebIDBCursor.h"
26 #include "third_party/WebKit/public/platform/WebIDBDatabase.h" 28 #include "third_party/WebKit/public/platform/WebIDBDatabase.h"
27 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h"
28 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" 29 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"
29 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 30 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
30 #include "third_party/WebKit/public/platform/WebIDBFactory.h"
31 #include "third_party/WebKit/public/platform/WebIDBMetadata.h" 31 #include "third_party/WebKit/public/platform/WebIDBMetadata.h"
32 #include "third_party/WebKit/public/platform/WebString.h" 32 #include "third_party/WebKit/public/platform/WebString.h"
33 #include "third_party/WebKit/public/platform/WebVector.h" 33 #include "third_party/WebKit/public/platform/WebVector.h"
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;
41 using WebKit::WebIDBCursor;
42 using WebKit::WebIDBDatabase;
43 using WebKit::WebIDBDatabaseError; 40 using WebKit::WebIDBDatabaseError;
44 using WebKit::WebIDBKey; 41 using WebKit::WebIDBKey;
45 using WebKit::WebIDBMetadata; 42 using WebKit::WebIDBMetadata;
46 using WebKit::WebString; 43 using WebKit::WebString;
47 using WebKit::WebVector; 44 using WebKit::WebVector;
48 45
49 namespace content { 46 namespace content {
50 namespace { 47 namespace {
51 48
52 template <class T> 49 template <class T>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 OnIDBFactoryGetDatabaseNames) 119 OnIDBFactoryGetDatabaseNames)
123 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) 120 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen)
124 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, 121 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase,
125 OnIDBFactoryDeleteDatabase) 122 OnIDBFactoryDeleteDatabase)
126 IPC_MESSAGE_UNHANDLED(handled = false) 123 IPC_MESSAGE_UNHANDLED(handled = false)
127 IPC_END_MESSAGE_MAP() 124 IPC_END_MESSAGE_MAP()
128 } 125 }
129 return handled; 126 return handled;
130 } 127 }
131 128
132 int32 IndexedDBDispatcherHost::Add(WebIDBCursor* idb_cursor) { 129 int32 IndexedDBDispatcherHost::Add(WebIDBCursorImpl* idb_cursor) {
133 if (!cursor_dispatcher_host_) { 130 if (!cursor_dispatcher_host_) {
134 delete idb_cursor; 131 delete idb_cursor;
135 return 0; 132 return 0;
136 } 133 }
137 return cursor_dispatcher_host_->map_.Add(idb_cursor); 134 return cursor_dispatcher_host_->map_.Add(idb_cursor);
138 } 135 }
139 136
140 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, 137 int32 IndexedDBDispatcherHost::Add(WebIDBDatabaseImpl* idb_database,
141 int32 ipc_thread_id, 138 int32 ipc_thread_id,
142 const GURL& origin_url) { 139 const GURL& origin_url) {
143 if (!database_dispatcher_host_) { 140 if (!database_dispatcher_host_) {
144 delete idb_database; 141 delete idb_database;
145 return 0; 142 return 0;
146 } 143 }
147 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database); 144 int32 ipc_database_id = database_dispatcher_host_->map_.Add(idb_database);
148 Context()->ConnectionOpened(origin_url, idb_database); 145 Context()->ConnectionOpened(origin_url, idb_database);
149 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url; 146 database_dispatcher_host_->database_url_map_[ipc_database_id] = origin_url;
150 return ipc_database_id; 147 return ipc_database_id;
(...skipping 19 matching lines...) Expand all
170 return transaction_id | (static_cast<uint64>(pid) << 32); 167 return transaction_id | (static_cast<uint64>(pid) << 32);
171 } 168 }
172 169
173 int64 IndexedDBDispatcherHost::RendererTransactionId( 170 int64 IndexedDBDispatcherHost::RendererTransactionId(
174 int64 host_transaction_id) { 171 int64 host_transaction_id) {
175 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle())) 172 DCHECK(host_transaction_id >> 32 == base::GetProcId(peer_handle()))
176 << "Invalid renderer target for transaction id"; 173 << "Invalid renderer target for transaction id";
177 return host_transaction_id & 0xffffffff; 174 return host_transaction_id & 0xffffffff;
178 } 175 }
179 176
180 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { 177 WebIDBCursorImpl* IndexedDBDispatcherHost::GetCursorFromId(
178 int32 ipc_cursor_id) {
181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
182 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); 180 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id);
183 } 181 }
184 182
185 IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( 183 IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata(
186 const WebIDBMetadata& web_metadata) { 184 const WebIDBMetadata& web_metadata) {
187 IndexedDBDatabaseMetadata metadata; 185 IndexedDBDatabaseMetadata metadata;
188 metadata.id = web_metadata.id; 186 metadata.id = web_metadata.id;
189 metadata.name = web_metadata.name; 187 metadata.name = web_metadata.name;
190 metadata.version = web_metadata.version; 188 metadata.version = web_metadata.version;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() { 340 void IndexedDBDispatcherHost::DatabaseDispatcherHost::CloseAll() {
343 // Abort outstanding transactions started by connections in the associated 341 // Abort outstanding transactions started by connections in the associated
344 // front-end to unblock later transactions. This should only occur on unclean 342 // front-end to unblock later transactions. This should only occur on unclean
345 // (crash) or abrupt (process-kill) shutdowns. 343 // (crash) or abrupt (process-kill) shutdowns.
346 for (TransactionIDToDatabaseIDMap::iterator iter = 344 for (TransactionIDToDatabaseIDMap::iterator iter =
347 transaction_database_map_.begin(); 345 transaction_database_map_.begin();
348 iter != transaction_database_map_.end();) { 346 iter != transaction_database_map_.end();) {
349 int64 transaction_id = iter->first; 347 int64 transaction_id = iter->first;
350 int32 ipc_database_id = iter->second; 348 int32 ipc_database_id = iter->second;
351 ++iter; 349 ++iter;
352 WebIDBDatabase* database = map_.Lookup(ipc_database_id); 350 WebIDBDatabaseImpl* database = map_.Lookup(ipc_database_id);
353 if (database) { 351 if (database) {
354 database->abort( 352 database->abort(
355 transaction_id, 353 transaction_id,
356 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError)); 354 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError));
357 } 355 }
358 } 356 }
359 DCHECK(transaction_database_map_.empty()); 357 DCHECK(transaction_database_map_.empty());
360 358
361 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); 359 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin();
362 iter != database_url_map_.end(); 360 iter != database_url_map_.end();
363 iter++) { 361 iter++) {
364 WebIDBDatabase* database = map_.Lookup(iter->first); 362 WebIDBDatabaseImpl* database = map_.Lookup(iter->first);
365 if (database) { 363 if (database) {
366 database->close(); 364 database->close();
367 parent_->Context()->ConnectionClosed(iter->second, database); 365 parent_->Context()->ConnectionClosed(iter->second, database);
368 } 366 }
369 } 367 }
370 } 368 }
371 369
372 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( 370 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
373 const IPC::Message& message, 371 const IPC::Message& message,
374 bool* msg_is_ok) { 372 bool* msg_is_ok) {
(...skipping 27 matching lines...) Expand all
402 } 400 }
403 401
404 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send( 402 void IndexedDBDispatcherHost::DatabaseDispatcherHost::Send(
405 IPC::Message* message) { 403 IPC::Message* message) {
406 parent_->Send(message); 404 parent_->Send(message);
407 } 405 }
408 406
409 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore( 407 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
410 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) { 408 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) {
411 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 409 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
412 WebIDBDatabase* database = 410 WebIDBDatabaseImpl* database =
413 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 411 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
414 if (!database) 412 if (!database)
415 return; 413 return;
416 414
417 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 415 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
418 database->createObjectStore(host_transaction_id, 416 database->createObjectStore(host_transaction_id,
419 params.object_store_id, 417 params.object_store_id,
420 params.name, 418 params.name,
421 params.key_path, 419 params.key_path,
422 params.auto_increment); 420 params.auto_increment);
423 if (parent_->Context()->IsOverQuota( 421 if (parent_->Context()->IsOverQuota(
424 database_url_map_[params.ipc_database_id])) { 422 database_url_map_[params.ipc_database_id])) {
425 database->abort( 423 database->abort(
426 host_transaction_id, 424 host_transaction_id,
427 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); 425 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError));
428 } 426 }
429 } 427 }
430 428
431 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( 429 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
432 int32 ipc_database_id, 430 int32 ipc_database_id,
433 int64 transaction_id, 431 int64 transaction_id,
434 int64 object_store_id) { 432 int64 object_store_id) {
435 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
436 WebIDBDatabase* database = 434 WebIDBDatabaseImpl* database =
437 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 435 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
438 if (!database) 436 if (!database)
439 return; 437 return;
440 438
441 database->deleteObjectStore(parent_->HostTransactionId(transaction_id), 439 database->deleteObjectStore(parent_->HostTransactionId(transaction_id),
442 object_store_id); 440 object_store_id);
443 } 441 }
444 442
445 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( 443 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction(
446 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) { 444 const IndexedDBHostMsg_DatabaseCreateTransaction_Params& params) {
447 WebIDBDatabase* database = 445 WebIDBDatabaseImpl* database =
448 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 446 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
449 if (!database) 447 if (!database)
450 return; 448 return;
451 449
452 WebVector<long long> object_stores(params.object_store_ids.size()); 450 WebVector<long long> object_stores(params.object_store_ids.size());
453 for (size_t i = 0; i < params.object_store_ids.size(); ++i) 451 for (size_t i = 0; i < params.object_store_ids.size(); ++i)
454 object_stores[i] = params.object_store_ids[i]; 452 object_stores[i] = params.object_store_ids[i];
455 453
456 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 454 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
457 455
458 database->createTransaction( 456 database->createTransaction(
459 host_transaction_id, 457 host_transaction_id,
460 new IndexedDBDatabaseCallbacks( 458 new IndexedDBDatabaseCallbacks(
461 parent_, params.ipc_thread_id, params.ipc_database_callbacks_id), 459 parent_, params.ipc_thread_id, params.ipc_database_callbacks_id),
462 object_stores, 460 object_stores,
463 params.mode); 461 params.mode);
464 transaction_database_map_[host_transaction_id] = params.ipc_database_id; 462 transaction_database_map_[host_transaction_id] = params.ipc_database_id;
465 parent_->RegisterTransactionId(host_transaction_id, 463 parent_->RegisterTransactionId(host_transaction_id,
466 database_url_map_[params.ipc_database_id]); 464 database_url_map_[params.ipc_database_id]);
467 } 465 }
468 466
469 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( 467 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose(
470 int32 ipc_database_id) { 468 int32 ipc_database_id) {
471 WebIDBDatabase* database = 469 WebIDBDatabaseImpl* database =
472 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 470 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
473 if (!database) 471 if (!database)
474 return; 472 return;
475 database->close(); 473 database->close();
476 } 474 }
477 475
478 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( 476 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
479 int32 ipc_object_id) { 477 int32 ipc_object_id) {
480 WebIDBDatabase* database = map_.Lookup(ipc_object_id); 478 WebIDBDatabaseImpl* database = map_.Lookup(ipc_object_id);
481 parent_->Context() 479 parent_->Context()
482 ->ConnectionClosed(database_url_map_[ipc_object_id], database); 480 ->ConnectionClosed(database_url_map_[ipc_object_id], database);
483 database_url_map_.erase(ipc_object_id); 481 database_url_map_.erase(ipc_object_id);
484 parent_->DestroyObject(&map_, ipc_object_id); 482 parent_->DestroyObject(&map_, ipc_object_id);
485 } 483 }
486 484
487 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( 485 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet(
488 const IndexedDBHostMsg_DatabaseGet_Params& params) { 486 const IndexedDBHostMsg_DatabaseGet_Params& params) {
489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
490 WebIDBDatabase* database = 488 WebIDBDatabaseImpl* database =
491 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 489 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
492 if (!database) 490 if (!database)
493 return; 491 return;
494 492
495 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( 493 scoped_ptr<IndexedDBCallbacksBase> callbacks(new IndexedDBCallbacks<WebData>(
496 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); 494 parent_, params.ipc_thread_id, params.ipc_callbacks_id));
497 database->get(parent_->HostTransactionId(params.transaction_id), 495 database->get(parent_->HostTransactionId(params.transaction_id),
498 params.object_store_id, 496 params.object_store_id,
499 params.index_id, 497 params.index_id,
500 params.key_range, 498 params.key_range,
501 params.key_only, 499 params.key_only,
502 callbacks.release()); 500 callbacks.release());
503 } 501 }
504 502
505 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( 503 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut(
506 const IndexedDBHostMsg_DatabasePut_Params& params) { 504 const IndexedDBHostMsg_DatabasePut_Params& params) {
507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
508 506
509 WebIDBDatabase* database = 507 WebIDBDatabaseImpl* database =
510 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 508 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
511 if (!database) 509 if (!database)
512 return; 510 return;
513 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebIDBKey>( 511 scoped_ptr<IndexedDBCallbacksBase> callbacks(
514 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); 512 new IndexedDBCallbacks<WebIDBKey>(
513 parent_, params.ipc_thread_id, params.ipc_callbacks_id));
515 // Be careful with empty vectors. 514 // Be careful with empty vectors.
516 WebData value; 515 WebData value;
517 if (params.value.size()) 516 if (params.value.size())
518 value.assign(&params.value.front(), params.value.size()); 517 value.assign(&params.value.front(), params.value.size());
519 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 518 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
520 database->put(host_transaction_id, 519 database->put(host_transaction_id,
521 params.object_store_id, 520 params.object_store_id,
522 value, 521 value,
523 params.key, 522 params.key,
524 params.put_mode, 523 params.put_mode,
525 callbacks.release(), 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 = 537 WebIDBDatabaseImpl* database =
539 parent_->GetOrTerminateProcess(&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( 544 database->abort(
546 host_transaction_id, 545 host_transaction_id,
547 WebIDBDatabaseError( 546 WebIDBDatabaseError(
548 WebKit::WebIDBDatabaseExceptionUnknownError, 547 WebKit::WebIDBDatabaseExceptionUnknownError,
549 "Malformed IPC message: index_ids.size() != index_keys.size()")); 548 "Malformed IPC message: index_ids.size() != index_keys.size()"));
550 return; 549 return;
551 } 550 }
552 551
553 database->setIndexKeys(host_transaction_id, 552 database->setIndexKeys(host_transaction_id,
554 params.object_store_id, 553 params.object_store_id,
555 params.primary_key, 554 params.primary_key,
556 params.index_ids, 555 params.index_ids,
557 params.index_keys); 556 params.index_keys);
558 } 557 }
559 558
560 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady( 559 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexesReady(
561 int32 ipc_database_id, 560 int32 ipc_database_id,
562 int64 transaction_id, 561 int64 transaction_id,
563 int64 object_store_id, 562 int64 object_store_id,
564 const std::vector<int64>& index_ids) { 563 const std::vector<int64>& index_ids) {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
566 WebIDBDatabase* database = 565 WebIDBDatabaseImpl* database =
567 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 566 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
568 if (!database) 567 if (!database)
569 return; 568 return;
570 569
571 database->setIndexesReady(parent_->HostTransactionId(transaction_id), 570 database->setIndexesReady(parent_->HostTransactionId(transaction_id),
572 object_store_id, 571 object_store_id,
573 WebVector<long long>(index_ids)); 572 WebVector<long long>(index_ids));
574 } 573 }
575 574
576 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( 575 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor(
577 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) { 576 const IndexedDBHostMsg_DatabaseOpenCursor_Params& params) {
578 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
579 WebIDBDatabase* database = 578 WebIDBDatabaseImpl* database =
580 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 579 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
581 if (!database) 580 if (!database)
582 return; 581 return;
583 582
584 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebIDBCursor>( 583 scoped_ptr<IndexedDBCallbacksBase> callbacks(
585 parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); 584 new IndexedDBCallbacks<WebIDBCursorImpl>(
585 parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1));
586 database->openCursor(parent_->HostTransactionId(params.transaction_id), 586 database->openCursor(parent_->HostTransactionId(params.transaction_id),
587 params.object_store_id, 587 params.object_store_id,
588 params.index_id, 588 params.index_id,
589 params.key_range, 589 params.key_range,
590 params.direction, 590 params.direction,
591 params.key_only, 591 params.key_only,
592 params.task_type, 592 params.task_type,
593 callbacks.release()); 593 callbacks.release());
594 } 594 }
595 595
596 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( 596 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount(
597 const IndexedDBHostMsg_DatabaseCount_Params& params) { 597 const IndexedDBHostMsg_DatabaseCount_Params& params) {
598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
599 WebIDBDatabase* database = 599 WebIDBDatabaseImpl* database =
600 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 600 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
601 if (!database) 601 if (!database)
602 return; 602 return;
603 603
604 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( 604 scoped_ptr<IndexedDBCallbacksBase> callbacks(new IndexedDBCallbacks<WebData>(
605 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); 605 parent_, params.ipc_thread_id, params.ipc_callbacks_id));
606 database->count(parent_->HostTransactionId(params.transaction_id), 606 database->count(parent_->HostTransactionId(params.transaction_id),
607 params.object_store_id, 607 params.object_store_id,
608 params.index_id, 608 params.index_id,
609 params.key_range, 609 params.key_range,
610 callbacks.release()); 610 callbacks.release());
611 } 611 }
612 612
613 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( 613 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange(
614 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { 614 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) {
615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 615 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
616 WebIDBDatabase* database = 616 WebIDBDatabaseImpl* database =
617 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 617 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
618 if (!database) 618 if (!database)
619 return; 619 return;
620 620
621 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( 621 scoped_ptr<IndexedDBCallbacksBase> callbacks(new IndexedDBCallbacks<WebData>(
622 parent_, params.ipc_thread_id, params.ipc_callbacks_id)); 622 parent_, params.ipc_thread_id, params.ipc_callbacks_id));
623 database->deleteRange(parent_->HostTransactionId(params.transaction_id), 623 database->deleteRange(parent_->HostTransactionId(params.transaction_id),
624 params.object_store_id, 624 params.object_store_id,
625 params.key_range, 625 params.key_range,
626 callbacks.release()); 626 callbacks.release());
627 } 627 }
628 628
629 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( 629 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear(
630 int32 ipc_thread_id, 630 int32 ipc_thread_id,
631 int32 ipc_callbacks_id, 631 int32 ipc_callbacks_id,
632 int32 ipc_database_id, 632 int32 ipc_database_id,
633 int64 transaction_id, 633 int64 transaction_id,
634 int64 object_store_id) { 634 int64 object_store_id) {
635 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 635 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
636 WebIDBDatabase* database = 636 WebIDBDatabaseImpl* database =
637 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 637 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
638 if (!database) 638 if (!database)
639 return; 639 return;
640 640
641 scoped_ptr<WebIDBCallbacks> callbacks(new IndexedDBCallbacks<WebData>( 641 scoped_ptr<IndexedDBCallbacksBase> callbacks(new IndexedDBCallbacks<WebData>(
642 parent_, ipc_thread_id, ipc_callbacks_id)); 642 parent_, ipc_thread_id, ipc_callbacks_id));
643 643
644 database->clear(parent_->HostTransactionId(transaction_id), 644 database->clear(parent_->HostTransactionId(transaction_id),
645 object_store_id, 645 object_store_id,
646 callbacks.release()); 646 callbacks.release());
647 } 647 }
648 648
649 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( 649 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort(
650 int32 ipc_database_id, 650 int32 ipc_database_id,
651 int64 transaction_id) { 651 int64 transaction_id) {
652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
653 WebIDBDatabase* database = 653 WebIDBDatabaseImpl* database =
654 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 654 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
655 if (!database) 655 if (!database)
656 return; 656 return;
657 657
658 database->abort(parent_->HostTransactionId(transaction_id)); 658 database->abort(parent_->HostTransactionId(transaction_id));
659 } 659 }
660 660
661 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit( 661 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCommit(
662 int32 ipc_database_id, 662 int32 ipc_database_id,
663 int64 transaction_id) { 663 int64 transaction_id) {
664 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 664 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
665 WebIDBDatabase* database = 665 WebIDBDatabaseImpl* database =
666 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 666 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
667 if (!database) 667 if (!database)
668 return; 668 return;
669 669
670 int64 host_transaction_id = parent_->HostTransactionId(transaction_id); 670 int64 host_transaction_id = parent_->HostTransactionId(transaction_id);
671 int64 transaction_size = transaction_size_map_[host_transaction_id]; 671 int64 transaction_size = transaction_size_map_[host_transaction_id];
672 if (transaction_size && 672 if (transaction_size &&
673 parent_->Context()->WouldBeOverQuota( 673 parent_->Context()->WouldBeOverQuota(
674 transaction_url_map_[host_transaction_id], transaction_size)) { 674 transaction_url_map_[host_transaction_id], transaction_size)) {
675 database->abort( 675 database->abort(
676 host_transaction_id, 676 host_transaction_id,
677 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); 677 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError));
678 return; 678 return;
679 } 679 }
680 680
681 database->commit(host_transaction_id); 681 database->commit(host_transaction_id);
682 } 682 }
683 683
684 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( 684 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex(
685 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { 685 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) {
686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
687 WebIDBDatabase* database = 687 WebIDBDatabaseImpl* database =
688 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 688 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
689 if (!database) 689 if (!database)
690 return; 690 return;
691 691
692 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 692 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
693 database->createIndex(host_transaction_id, 693 database->createIndex(host_transaction_id,
694 params.object_store_id, 694 params.object_store_id,
695 params.index_id, 695 params.index_id,
696 params.name, 696 params.name,
697 params.key_path, 697 params.key_path,
698 params.unique, 698 params.unique,
699 params.multi_entry); 699 params.multi_entry);
700 if (parent_->Context()->IsOverQuota( 700 if (parent_->Context()->IsOverQuota(
701 database_url_map_[params.ipc_database_id])) { 701 database_url_map_[params.ipc_database_id])) {
702 database->abort( 702 database->abort(
703 host_transaction_id, 703 host_transaction_id,
704 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); 704 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError));
705 } 705 }
706 } 706 }
707 707
708 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( 708 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex(
709 int32 ipc_database_id, 709 int32 ipc_database_id,
710 int64 transaction_id, 710 int64 transaction_id,
711 int64 object_store_id, 711 int64 object_store_id,
712 int64 index_id) { 712 int64 index_id) {
713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
714 WebIDBDatabase* database = 714 WebIDBDatabaseImpl* database =
715 parent_->GetOrTerminateProcess(&map_, ipc_database_id); 715 parent_->GetOrTerminateProcess(&map_, ipc_database_id);
716 if (!database) 716 if (!database)
717 return; 717 return;
718 718
719 database->deleteIndex( 719 database->deleteIndex(
720 parent_->HostTransactionId(transaction_id), object_store_id, index_id); 720 parent_->HostTransactionId(transaction_id), object_store_id, index_id);
721 } 721 }
722 722
723 ////////////////////////////////////////////////////////////////////// 723 //////////////////////////////////////////////////////////////////////
724 // IndexedDBDispatcherHost::CursorDispatcherHost 724 // IndexedDBDispatcherHost::CursorDispatcherHost
(...skipping 27 matching lines...) Expand all
752 IPC::Message* message) { 752 IPC::Message* message) {
753 parent_->Send(message); 753 parent_->Send(message);
754 } 754 }
755 755
756 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( 756 void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance(
757 int32 ipc_cursor_id, 757 int32 ipc_cursor_id,
758 int32 ipc_thread_id, 758 int32 ipc_thread_id,
759 int32 ipc_callbacks_id, 759 int32 ipc_callbacks_id,
760 unsigned long count) { 760 unsigned long count) {
761 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 761 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
762 WebIDBCursor* idb_cursor = 762 WebIDBCursorImpl* idb_cursor =
763 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); 763 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id);
764 if (!idb_cursor) 764 if (!idb_cursor)
765 return; 765 return;
766 766
767 idb_cursor->advance( 767 idb_cursor->advance(
768 count, 768 count,
769 new IndexedDBCallbacks<WebIDBCursor>( 769 new IndexedDBCallbacks<WebIDBCursorImpl>(
770 parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); 770 parent_, ipc_thread_id, ipc_callbacks_id, 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 = 779 WebIDBCursorImpl* idb_cursor =
780 parent_->GetOrTerminateProcess(&map_, 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, 785 key,
786 new IndexedDBCallbacks<WebIDBCursor>( 786 new IndexedDBCallbacks<WebIDBCursorImpl>(
787 parent_, ipc_thread_id, ipc_callbacks_id, 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 = 796 WebIDBCursorImpl* idb_cursor =
797 parent_->GetOrTerminateProcess(&map_, 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, 802 n,
803 new IndexedDBCallbacks<WebIDBCursor>( 803 new IndexedDBCallbacks<WebIDBCursorImpl>(
804 parent_, ipc_thread_id, ipc_callbacks_id, 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, 808 int32 ipc_cursor_id,
809 int used_prefetches, 809 int used_prefetches,
810 int unused_prefetches) { 810 int unused_prefetches) {
811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 811 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
812 WebIDBCursor* idb_cursor = 812 WebIDBCursorImpl* idb_cursor =
813 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id); 813 parent_->GetOrTerminateProcess(&map_, ipc_cursor_id);
814 if (!idb_cursor) 814 if (!idb_cursor)
815 return; 815 return;
816 816
817 idb_cursor->prefetchReset(used_prefetches, unused_prefetches); 817 idb_cursor->prefetchReset(used_prefetches, unused_prefetches);
818 } 818 }
819 819
820 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 820 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
821 int32 ipc_object_id) { 821 int32 ipc_object_id) {
822 parent_->DestroyObject(&map_, ipc_object_id); 822 parent_->DestroyObject(&map_, ipc_object_id);
823 } 823 }
824 824
825 } // namespace content 825 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698