| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches, | 208 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches, |
| 209 int unused_prefetches, | 209 int unused_prefetches, |
| 210 int32 ipc_cursor_id) { | 210 int32 ipc_cursor_id) { |
| 211 Send(new IndexedDBHostMsg_CursorPrefetchReset( | 211 Send(new IndexedDBHostMsg_CursorPrefetchReset( |
| 212 ipc_cursor_id, used_prefetches, unused_prefetches)); | 212 ipc_cursor_id, used_prefetches, unused_prefetches)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void IndexedDBDispatcher::RequestIDBFactoryOpen( | 215 void IndexedDBDispatcher::RequestIDBFactoryOpen( |
| 216 const string16& name, | 216 const base::string16& name, |
| 217 int64 version, | 217 int64 version, |
| 218 int64 transaction_id, | 218 int64 transaction_id, |
| 219 WebIDBCallbacks* callbacks_ptr, | 219 WebIDBCallbacks* callbacks_ptr, |
| 220 WebIDBDatabaseCallbacks* database_callbacks_ptr, | 220 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 221 const std::string& database_identifier) { | 221 const std::string& database_identifier) { |
| 222 ResetCursorPrefetchCaches(); | 222 ResetCursorPrefetchCaches(); |
| 223 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 223 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 224 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( | 224 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( |
| 225 database_callbacks_ptr); | 225 database_callbacks_ptr); |
| 226 | 226 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 243 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 243 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 244 | 244 |
| 245 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; | 245 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; |
| 246 params.ipc_thread_id = CurrentWorkerId(); | 246 params.ipc_thread_id = CurrentWorkerId(); |
| 247 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 247 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 248 params.database_identifier = database_identifier; | 248 params.database_identifier = database_identifier; |
| 249 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); | 249 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( | 252 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( |
| 253 const string16& name, | 253 const base::string16& name, |
| 254 WebIDBCallbacks* callbacks_ptr, | 254 WebIDBCallbacks* callbacks_ptr, |
| 255 const std::string& database_identifier) { | 255 const std::string& database_identifier) { |
| 256 ResetCursorPrefetchCaches(); | 256 ResetCursorPrefetchCaches(); |
| 257 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 257 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 258 | 258 |
| 259 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; | 259 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; |
| 260 params.ipc_thread_id = CurrentWorkerId(); | 260 params.ipc_thread_id = CurrentWorkerId(); |
| 261 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 261 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); |
| 262 params.database_identifier = database_identifier; | 262 params.database_identifier = database_identifier; |
| 263 params.name = name; | 263 params.name = name; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 480 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 481 if (!callbacks) | 481 if (!callbacks) |
| 482 return; | 482 return; |
| 483 callbacks->onSuccess(WebIDBKeyBuilder::Build(key)); | 483 callbacks->onSuccess(WebIDBKeyBuilder::Build(key)); |
| 484 pending_callbacks_.Remove(ipc_callbacks_id); | 484 pending_callbacks_.Remove(ipc_callbacks_id); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void IndexedDBDispatcher::OnSuccessStringList( | 487 void IndexedDBDispatcher::OnSuccessStringList( |
| 488 int32 ipc_thread_id, | 488 int32 ipc_thread_id, |
| 489 int32 ipc_callbacks_id, | 489 int32 ipc_callbacks_id, |
| 490 const std::vector<string16>& value) { | 490 const std::vector<base::string16>& value) { |
| 491 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 491 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 492 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 492 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 493 if (!callbacks) | 493 if (!callbacks) |
| 494 return; | 494 return; |
| 495 callbacks->onSuccess(WebVector<WebString>(value)); | 495 callbacks->onSuccess(WebVector<WebString>(value)); |
| 496 pending_callbacks_.Remove(ipc_callbacks_id); | 496 pending_callbacks_.Remove(ipc_callbacks_id); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, | 499 void IndexedDBDispatcher::OnSuccessValue(int32 ipc_thread_id, |
| 500 int32 ipc_callbacks_id, | 500 int32 ipc_callbacks_id, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 p.old_version, | 645 p.old_version, |
| 646 databases_[p.ipc_database_id], | 646 databases_[p.ipc_database_id], |
| 647 metadata, | 647 metadata, |
| 648 static_cast<blink::WebIDBDataLoss>(p.data_loss), | 648 static_cast<blink::WebIDBDataLoss>(p.data_loss), |
| 649 WebString::fromUTF8(p.data_loss_message)); | 649 WebString::fromUTF8(p.data_loss_message)); |
| 650 } | 650 } |
| 651 | 651 |
| 652 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, | 652 void IndexedDBDispatcher::OnError(int32 ipc_thread_id, |
| 653 int32 ipc_callbacks_id, | 653 int32 ipc_callbacks_id, |
| 654 int code, | 654 int code, |
| 655 const string16& message) { | 655 const base::string16& message) { |
| 656 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 656 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 657 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); | 657 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(ipc_callbacks_id); |
| 658 if (!callbacks) | 658 if (!callbacks) |
| 659 return; | 659 return; |
| 660 if (message.empty()) | 660 if (message.empty()) |
| 661 callbacks->onError(WebIDBDatabaseError(code)); | 661 callbacks->onError(WebIDBDatabaseError(code)); |
| 662 else | 662 else |
| 663 callbacks->onError(WebIDBDatabaseError(code, message)); | 663 callbacks->onError(WebIDBDatabaseError(code, message)); |
| 664 pending_callbacks_.Remove(ipc_callbacks_id); | 664 pending_callbacks_.Remove(ipc_callbacks_id); |
| 665 } | 665 } |
| 666 | 666 |
| 667 void IndexedDBDispatcher::OnAbort(int32 ipc_thread_id, | 667 void IndexedDBDispatcher::OnAbort(int32 ipc_thread_id, |
| 668 int32 ipc_database_callbacks_id, | 668 int32 ipc_database_callbacks_id, |
| 669 int64 transaction_id, | 669 int64 transaction_id, |
| 670 int code, | 670 int code, |
| 671 const string16& message) { | 671 const base::string16& message) { |
| 672 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); | 672 DCHECK_EQ(ipc_thread_id, CurrentWorkerId()); |
| 673 WebIDBDatabaseCallbacks* callbacks = | 673 WebIDBDatabaseCallbacks* callbacks = |
| 674 pending_database_callbacks_.Lookup(ipc_database_callbacks_id); | 674 pending_database_callbacks_.Lookup(ipc_database_callbacks_id); |
| 675 if (!callbacks) | 675 if (!callbacks) |
| 676 return; | 676 return; |
| 677 if (message.empty()) | 677 if (message.empty()) |
| 678 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code)); | 678 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code)); |
| 679 else | 679 else |
| 680 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code, message)); | 680 callbacks->onAbort(transaction_id, WebIDBDatabaseError(code, message)); |
| 681 } | 681 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 int32 ipc_exception_cursor_id) { | 719 int32 ipc_exception_cursor_id) { |
| 720 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 720 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 721 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 721 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 722 if (i->first == ipc_exception_cursor_id) | 722 if (i->first == ipc_exception_cursor_id) |
| 723 continue; | 723 continue; |
| 724 i->second->ResetPrefetchCache(); | 724 i->second->ResetPrefetchCache(); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace content | 728 } // namespace content |
| OLD | NEW |