| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // the initial upgradeneeded event handler. | 276 // the initial upgradeneeded event handler. |
| 277 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id)) | 277 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id)) |
| 278 pending_database_callbacks_.Remove(ipc_database_callbacks_id); | 278 pending_database_callbacks_.Remove(ipc_database_callbacks_id); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction( | 281 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction( |
| 282 int32 ipc_database_id, | 282 int32 ipc_database_id, |
| 283 int64 transaction_id, | 283 int64 transaction_id, |
| 284 WebIDBDatabaseCallbacks* database_callbacks_ptr, | 284 WebIDBDatabaseCallbacks* database_callbacks_ptr, |
| 285 WebVector<long long> object_store_ids, | 285 WebVector<long long> object_store_ids, |
| 286 WebIDBDatabase::TransactionMode mode) { | 286 blink::WebIDBTransactionMode mode) { |
| 287 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( | 287 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( |
| 288 database_callbacks_ptr); | 288 database_callbacks_ptr); |
| 289 IndexedDBHostMsg_DatabaseCreateTransaction_Params params; | 289 IndexedDBHostMsg_DatabaseCreateTransaction_Params params; |
| 290 params.ipc_thread_id = CurrentWorkerId(); | 290 params.ipc_thread_id = CurrentWorkerId(); |
| 291 params.ipc_database_id = ipc_database_id; | 291 params.ipc_database_id = ipc_database_id; |
| 292 params.transaction_id = transaction_id; | 292 params.transaction_id = transaction_id; |
| 293 params.ipc_database_callbacks_id = | 293 params.ipc_database_callbacks_id = |
| 294 pending_database_callbacks_.Add(database_callbacks.release()); | 294 pending_database_callbacks_.Add(database_callbacks.release()); |
| 295 params.object_store_ids | 295 params.object_store_ids |
| 296 .assign(object_store_ids.data(), | 296 .assign(object_store_ids.data(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 320 Send(new IndexedDBHostMsg_DatabaseGet(params)); | 320 Send(new IndexedDBHostMsg_DatabaseGet(params)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void IndexedDBDispatcher::RequestIDBDatabasePut( | 323 void IndexedDBDispatcher::RequestIDBDatabasePut( |
| 324 int32 ipc_database_id, | 324 int32 ipc_database_id, |
| 325 int64 transaction_id, | 325 int64 transaction_id, |
| 326 int64 object_store_id, | 326 int64 object_store_id, |
| 327 const WebData& value, | 327 const WebData& value, |
| 328 const blink::WebVector<WebBlobInfo>& web_blob_info, | 328 const blink::WebVector<WebBlobInfo>& web_blob_info, |
| 329 const IndexedDBKey& key, | 329 const IndexedDBKey& key, |
| 330 WebIDBDatabase::PutMode put_mode, | 330 blink::WebIDBPutMode put_mode, |
| 331 WebIDBCallbacks* callbacks, | 331 WebIDBCallbacks* callbacks, |
| 332 const WebVector<long long>& index_ids, | 332 const WebVector<long long>& index_ids, |
| 333 const WebVector<WebVector<WebIDBKey> >& index_keys) { | 333 const WebVector<WebVector<WebIDBKey> >& index_keys) { |
| 334 | |
| 335 if (value.size() + key.size_estimate() > kMaxIDBValueSizeInBytes) { | 334 if (value.size() + key.size_estimate() > kMaxIDBValueSizeInBytes) { |
| 336 callbacks->onError(WebIDBDatabaseError( | 335 callbacks->onError(WebIDBDatabaseError( |
| 337 blink::WebIDBDatabaseExceptionUnknownError, | 336 blink::WebIDBDatabaseExceptionUnknownError, |
| 338 WebString::fromUTF8(base::StringPrintf( | 337 WebString::fromUTF8(base::StringPrintf( |
| 339 "The serialized value is too large" | 338 "The serialized value is too large" |
| 340 " (size=%" PRIuS " bytes, max=%" PRIuS " bytes).", | 339 " (size=%" PRIuS " bytes, max=%" PRIuS " bytes).", |
| 341 value.size(), | 340 value.size(), |
| 342 kMaxIDBValueSizeInBytes).c_str()))); | 341 kMaxIDBValueSizeInBytes).c_str()))); |
| 343 return; | 342 return; |
| 344 } | 343 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 383 |
| 385 Send(new IndexedDBHostMsg_DatabasePut(params)); | 384 Send(new IndexedDBHostMsg_DatabasePut(params)); |
| 386 } | 385 } |
| 387 | 386 |
| 388 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( | 387 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( |
| 389 int32 ipc_database_id, | 388 int32 ipc_database_id, |
| 390 int64 transaction_id, | 389 int64 transaction_id, |
| 391 int64 object_store_id, | 390 int64 object_store_id, |
| 392 int64 index_id, | 391 int64 index_id, |
| 393 const IndexedDBKeyRange& key_range, | 392 const IndexedDBKeyRange& key_range, |
| 394 WebIDBCursor::Direction direction, | 393 blink::WebIDBCursorDirection direction, |
| 395 bool key_only, | 394 bool key_only, |
| 396 WebIDBDatabase::TaskType task_type, | 395 blink::WebIDBTaskType task_type, |
| 397 WebIDBCallbacks* callbacks) { | 396 WebIDBCallbacks* callbacks) { |
| 398 ResetCursorPrefetchCaches(transaction_id, kAllCursors); | 397 ResetCursorPrefetchCaches(transaction_id, kAllCursors); |
| 399 IndexedDBHostMsg_DatabaseOpenCursor_Params params; | 398 IndexedDBHostMsg_DatabaseOpenCursor_Params params; |
| 400 init_params(¶ms, callbacks); | 399 init_params(¶ms, callbacks); |
| 401 params.ipc_database_id = ipc_database_id; | 400 params.ipc_database_id = ipc_database_id; |
| 402 params.transaction_id = transaction_id; | 401 params.transaction_id = transaction_id; |
| 403 params.object_store_id = object_store_id; | 402 params.object_store_id = object_store_id; |
| 404 params.index_id = index_id; | 403 params.index_id = index_id; |
| 405 params.key_range = key_range; | 404 params.key_range = key_range; |
| 406 params.direction = direction; | 405 params.direction = direction; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; | 791 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; |
| 793 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 792 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 794 if (i->first == ipc_exception_cursor_id || | 793 if (i->first == ipc_exception_cursor_id || |
| 795 i->second->transaction_id() != transaction_id) | 794 i->second->transaction_id() != transaction_id) |
| 796 continue; | 795 continue; |
| 797 i->second->ResetPrefetchCache(); | 796 i->second->ResetPrefetchCache(); |
| 798 } | 797 } |
| 799 } | 798 } |
| 800 | 799 |
| 801 } // namespace content | 800 } // namespace content |
| OLD | NEW |