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

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

Issue 17915004: IndexedDB: Remove uses of WebKit API types from back-end code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 5 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/indexed_db/indexed_db_dispatcher_host.h" 5 #include "content/browser/indexed_db/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/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/process.h" 12 #include "base/process.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/indexed_db/indexed_db_callbacks.h" 15 #include "content/browser/indexed_db/indexed_db_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/indexed_db_database_callbacks.h" 17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
18 #include "content/browser/indexed_db/indexed_db_metadata.h" 18 #include "content/browser/indexed_db/indexed_db_metadata.h"
19 #include "content/browser/indexed_db/webidbcursor_impl.h" 19 #include "content/browser/indexed_db/webidbcursor_impl.h"
20 #include "content/browser/indexed_db/webidbcursor_impl.h" 20 #include "content/browser/indexed_db/webidbcursor_impl.h"
21 #include "content/browser/indexed_db/webidbdatabase_impl.h" 21 #include "content/browser/indexed_db/webidbdatabase_impl.h"
22 #include "content/browser/renderer_host/render_message_filter.h" 22 #include "content/browser/renderer_host/render_message_filter.h"
23 #include "content/common/indexed_db/indexed_db_messages.h" 23 #include "content/common/indexed_db/indexed_db_messages.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/user_metrics.h" 25 #include "content/public/browser/user_metrics.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "content/public/common/result_codes.h" 27 #include "content/public/common/result_codes.h"
28 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
29 #include "third_party/WebKit/public/platform/WebIDBDatabase.h" 29 #include "third_party/WebKit/public/platform/WebIDBDatabase.h"
30 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"
31 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 30 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
32 #include "webkit/browser/database/database_util.h" 31 #include "webkit/browser/database/database_util.h"
33 #include "webkit/common/database/database_identifier.h" 32 #include "webkit/common/database/database_identifier.h"
34 33
35 using webkit_database::DatabaseUtil; 34 using webkit_database::DatabaseUtil;
36 using WebKit::WebIDBDatabaseError;
37 using WebKit::WebIDBKey; 35 using WebKit::WebIDBKey;
38 36
39 namespace content { 37 namespace content {
40 38
41 IndexedDBDispatcherHost::IndexedDBDispatcherHost( 39 IndexedDBDispatcherHost::IndexedDBDispatcherHost(
42 int ipc_process_id, 40 int ipc_process_id,
43 IndexedDBContextImpl* indexed_db_context) 41 IndexedDBContextImpl* indexed_db_context)
44 : indexed_db_context_(indexed_db_context), 42 : indexed_db_context_(indexed_db_context),
45 database_dispatcher_host_(new DatabaseDispatcherHost(this)), 43 database_dispatcher_host_(new DatabaseDispatcherHost(this)),
46 cursor_dispatcher_host_(new CursorDispatcherHost(this)), 44 cursor_dispatcher_host_(new CursorDispatcherHost(this)),
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 212 }
215 213
216 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 214 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
217 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 215 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
218 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 216 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
219 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 217 base::FilePath indexed_db_path = indexed_db_context_->data_path();
220 218
221 Context()->GetIDBFactory()->getDatabaseNames( 219 Context()->GetIDBFactory()->getDatabaseNames(
222 new IndexedDBCallbacks<std::vector<string16> >( 220 new IndexedDBCallbacks<std::vector<string16> >(
223 this, params.ipc_thread_id, params.ipc_callbacks_id), 221 this, params.ipc_thread_id, params.ipc_callbacks_id),
224 WebKit::WebString::fromUTF8(params.database_identifier), 222 base::UTF8ToUTF16(params.database_identifier),
225 indexed_db_path.AsUTF16Unsafe()); 223 indexed_db_path.AsUTF16Unsafe());
226 } 224 }
227 225
228 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 226 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
229 const IndexedDBHostMsg_FactoryOpen_Params& params) { 227 const IndexedDBHostMsg_FactoryOpen_Params& params) {
230 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 228 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
231 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 229 base::FilePath indexed_db_path = indexed_db_context_->data_path();
232 230
233 GURL origin_url = 231 GURL origin_url =
234 webkit_database::GetOriginFromIdentifier(params.database_identifier); 232 webkit_database::GetOriginFromIdentifier(params.database_identifier);
235 233
236 int64 host_transaction_id = HostTransactionId(params.transaction_id); 234 int64 host_transaction_id = HostTransactionId(params.transaction_id);
237 235
238 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore 236 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
239 // created) if this origin is already over quota. 237 // created) if this origin is already over quota.
240 Context()->GetIDBFactory() 238 Context()->GetIDBFactory()
241 ->open(params.name, 239 ->open(params.name,
242 params.version, 240 params.version,
243 host_transaction_id, 241 host_transaction_id,
244 new IndexedDBCallbacksDatabase(this, 242 new IndexedDBCallbacksDatabase(this,
245 params.ipc_thread_id, 243 params.ipc_thread_id,
246 params.ipc_callbacks_id, 244 params.ipc_callbacks_id,
247 params.ipc_database_callbacks_id, 245 params.ipc_database_callbacks_id,
248 host_transaction_id, 246 host_transaction_id,
249 origin_url), 247 origin_url),
250 new IndexedDBDatabaseCallbacks( 248 new IndexedDBDatabaseCallbacks(
251 this, params.ipc_thread_id, params.ipc_database_callbacks_id), 249 this, params.ipc_thread_id, params.ipc_database_callbacks_id),
252 WebKit::WebString::fromUTF8(params.database_identifier), 250 base::UTF8ToUTF16(params.database_identifier),
253 indexed_db_path.AsUTF16Unsafe()); 251 indexed_db_path.AsUTF16Unsafe());
254 } 252 }
255 253
256 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 254 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
257 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 255 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
258 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 256 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
259 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 257 base::FilePath indexed_db_path = indexed_db_context_->data_path();
260 258
261 Context()->GetIDBFactory() 259 Context()->GetIDBFactory()
262 ->deleteDatabase(params.name, 260 ->deleteDatabase(params.name,
263 new IndexedDBCallbacks<std::vector<char> >( 261 new IndexedDBCallbacks<std::vector<char> >(
264 this, params.ipc_thread_id, params.ipc_callbacks_id), 262 this, params.ipc_thread_id, params.ipc_callbacks_id),
265 WebKit::WebString::fromUTF8(params.database_identifier), 263 base::UTF8ToUTF16(params.database_identifier),
266 indexed_db_path.AsUTF16Unsafe()); 264 indexed_db_path.AsUTF16Unsafe());
267 } 265 }
268 266
269 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id, 267 void IndexedDBDispatcherHost::FinishTransaction(int64 host_transaction_id,
270 bool committed) { 268 bool committed) {
271 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 269 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
272 TransactionIDToURLMap& transaction_url_map = 270 TransactionIDToURLMap& transaction_url_map =
273 database_dispatcher_host_->transaction_url_map_; 271 database_dispatcher_host_->transaction_url_map_;
274 TransactionIDToSizeMap& transaction_size_map = 272 TransactionIDToSizeMap& transaction_size_map =
275 database_dispatcher_host_->transaction_size_map_; 273 database_dispatcher_host_->transaction_size_map_;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 for (TransactionIDToDatabaseIDMap::iterator iter = 341 for (TransactionIDToDatabaseIDMap::iterator iter =
344 transaction_database_map_.begin(); 342 transaction_database_map_.begin();
345 iter != transaction_database_map_.end();) { 343 iter != transaction_database_map_.end();) {
346 int64 transaction_id = iter->first; 344 int64 transaction_id = iter->first;
347 int32 ipc_database_id = iter->second; 345 int32 ipc_database_id = iter->second;
348 ++iter; 346 ++iter;
349 WebIDBDatabaseImpl* database = map_.Lookup(ipc_database_id); 347 WebIDBDatabaseImpl* database = map_.Lookup(ipc_database_id);
350 if (database) { 348 if (database) {
351 database->abort( 349 database->abort(
352 transaction_id, 350 transaction_id,
353 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError)); 351 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError));
354 } 352 }
355 } 353 }
356 DCHECK(transaction_database_map_.empty()); 354 DCHECK(transaction_database_map_.empty());
357 355
358 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); 356 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin();
359 iter != database_url_map_.end(); 357 iter != database_url_map_.end();
360 iter++) { 358 iter++) {
361 WebIDBDatabaseImpl* database = map_.Lookup(iter->first); 359 WebIDBDatabaseImpl* database = map_.Lookup(iter->first);
362 if (database) { 360 if (database) {
363 database->close(); 361 database->close();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 IndexedDBDatabaseError(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( 433 DCHECK(
436 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 434 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
437 WebIDBDatabaseImpl* database = 435 WebIDBDatabaseImpl* database =
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 542 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
545 WebIDBDatabaseImpl* database = 543 WebIDBDatabaseImpl* database =
546 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 544 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
547 if (!database) 545 if (!database)
548 return; 546 return;
549 547
550 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 548 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
551 if (params.index_ids.size() != params.index_keys.size()) { 549 if (params.index_ids.size() != params.index_keys.size()) {
552 database->abort( 550 database->abort(
553 host_transaction_id, 551 host_transaction_id,
554 WebIDBDatabaseError( 552 IndexedDBDatabaseError(
555 WebKit::WebIDBDatabaseExceptionUnknownError, 553 WebKit::WebIDBDatabaseExceptionUnknownError,
556 "Malformed IPC message: index_ids.size() != index_keys.size()")); 554 "Malformed IPC message: index_ids.size() != index_keys.size()"));
557 return; 555 return;
558 } 556 }
559 557
560 database->setIndexKeys(host_transaction_id, 558 database->setIndexKeys(host_transaction_id,
561 params.object_store_id, 559 params.object_store_id,
562 params.primary_key, 560 params.primary_key,
563 params.index_ids, 561 params.index_ids,
564 params.index_keys); 562 params.index_keys);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if (!database) 682 if (!database)
685 return; 683 return;
686 684
687 int64 host_transaction_id = parent_->HostTransactionId(transaction_id); 685 int64 host_transaction_id = parent_->HostTransactionId(transaction_id);
688 int64 transaction_size = transaction_size_map_[host_transaction_id]; 686 int64 transaction_size = transaction_size_map_[host_transaction_id];
689 if (transaction_size && 687 if (transaction_size &&
690 parent_->Context()->WouldBeOverQuota( 688 parent_->Context()->WouldBeOverQuota(
691 transaction_url_map_[host_transaction_id], transaction_size)) { 689 transaction_url_map_[host_transaction_id], transaction_size)) {
692 database->abort( 690 database->abort(
693 host_transaction_id, 691 host_transaction_id,
694 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); 692 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError));
695 return; 693 return;
696 } 694 }
697 695
698 database->commit(host_transaction_id); 696 database->commit(host_transaction_id);
699 } 697 }
700 698
701 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex( 699 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex(
702 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) { 700 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) {
703 DCHECK( 701 DCHECK(
704 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 702 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
705 WebIDBDatabaseImpl* database = 703 WebIDBDatabaseImpl* database =
706 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); 704 parent_->GetOrTerminateProcess(&map_, params.ipc_database_id);
707 if (!database) 705 if (!database)
708 return; 706 return;
709 707
710 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); 708 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id);
711 database->createIndex(host_transaction_id, 709 database->createIndex(host_transaction_id,
712 params.object_store_id, 710 params.object_store_id,
713 params.index_id, 711 params.index_id,
714 params.name, 712 params.name,
715 params.key_path, 713 params.key_path,
716 params.unique, 714 params.unique,
717 params.multi_entry); 715 params.multi_entry);
718 if (parent_->Context()->IsOverQuota( 716 if (parent_->Context()->IsOverQuota(
719 database_url_map_[params.ipc_database_id])) { 717 database_url_map_[params.ipc_database_id])) {
720 database->abort( 718 database->abort(
721 host_transaction_id, 719 host_transaction_id,
722 WebIDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError)); 720 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionQuotaError));
723 } 721 }
724 } 722 }
725 723
726 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex( 724 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex(
727 int32 ipc_database_id, 725 int32 ipc_database_id,
728 int64 transaction_id, 726 int64 transaction_id,
729 int64 object_store_id, 727 int64 object_store_id,
730 int64 index_id) { 728 int64 index_id) {
731 DCHECK( 729 DCHECK(
732 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 730 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 } 842 }
845 843
846 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 844 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
847 int32 ipc_object_id) { 845 int32 ipc_object_id) {
848 DCHECK( 846 DCHECK(
849 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 847 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
850 parent_->DestroyObject(&map_, ipc_object_id); 848 parent_->DestroyObject(&map_, ipc_object_id);
851 } 849 }
852 850
853 } // namespace content 851 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_unittest.cc ('k') | content/browser/indexed_db/indexed_db_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698